Skip to content

Commit

Permalink
Merge pull request #96 from rmpowell77/dev/rule_of_six_boilerplate
Browse files Browse the repository at this point in the history
Adding a boilerplate macro for some repeated code.
  • Loading branch information
rmpowell77 authored Mar 10, 2023
2 parents 69c185f + 1bd3ddd commit 4b9c806
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 75 deletions.
6 changes: 1 addition & 5 deletions include/wxUI/Bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ struct Bitmap : public details::WidgetDetails<Bitmap, wxStaticBitmap> {
return new underlying_t(parent, getIdentity(), bitmap, getPos(), getSize(), getStyle());
}

virtual ~Bitmap() = default;
Bitmap(Bitmap const&) = default;
Bitmap(Bitmap&&) = default;
auto operator=(Bitmap const&) -> Bitmap& = default;
auto operator=(Bitmap&&) -> Bitmap& = default;
RULE_OF_SIX_BOILERPLATE(Bitmap);

private:
wxBitmap bitmap;
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/BitmapButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ struct BitmapButton : public details::WidgetDetails<BitmapButton, wxBitmapButton
return details::BindWidgetToEvent { *this, wxEVT_BUTTON, func };
}

virtual ~BitmapButton() = default;
BitmapButton(BitmapButton const&) = default;
BitmapButton(BitmapButton&&) = default;
auto operator=(BitmapButton const&) -> BitmapButton& = default;
auto operator=(BitmapButton&&) -> BitmapButton& = default;
RULE_OF_SIX_BOILERPLATE(BitmapButton);

private:
wxBitmap bitmap;
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/BitmapComboBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ struct BitmapComboBox : public details::WidgetDetails<BitmapComboBox, wxBitmapCo
return details::BindWidgetToEvent { *this, wxEVT_COMBOBOX, func };
}

virtual ~BitmapComboBox() = default;
BitmapComboBox(BitmapComboBox const&) = default;
BitmapComboBox(BitmapComboBox&&) = default;
auto operator=(BitmapComboBox const&) -> BitmapComboBox& = default;
auto operator=(BitmapComboBox&&) -> BitmapComboBox& = default;
RULE_OF_SIX_BOILERPLATE(BitmapComboBox);

private:
std::vector<wxString> choices;
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/BitmapToggleButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ struct BitmapToggleButton : public details::WidgetDetails<BitmapToggleButton, wx
return details::BindWidgetToEvent { *this, wxEVT_TOGGLEBUTTON, func };
}

virtual ~BitmapToggleButton() = default;
BitmapToggleButton(BitmapToggleButton const&) = default;
BitmapToggleButton(BitmapToggleButton&&) = default;
auto operator=(BitmapToggleButton const&) -> BitmapToggleButton& = default;
auto operator=(BitmapToggleButton&&) -> BitmapToggleButton& = default;
RULE_OF_SIX_BOILERPLATE(BitmapToggleButton);

private:
wxBitmap bitmap;
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/Button.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ struct Button : public details::WidgetDetails<Button, wxButton> {
return details::BindWidgetToEvent { *this, wxEVT_BUTTON, func };
}

virtual ~Button() = default;
Button(Button const&) = default;
Button(Button&&) = default;
auto operator=(Button const&) -> Button& = default;
auto operator=(Button&&) -> Button& = default;
RULE_OF_SIX_BOILERPLATE(Button);

private:
std::string text;
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/CheckBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ struct CheckBox : public details::WidgetDetails<CheckBox, wxCheckBox> {
return details::BindWidgetToEvent { *this, wxEVT_CHECKBOX, func };
}

virtual ~CheckBox() = default;
CheckBox(CheckBox const&) = default;
CheckBox(CheckBox&&) = default;
auto operator=(CheckBox const&) -> CheckBox& = default;
auto operator=(CheckBox&&) -> CheckBox& = default;
RULE_OF_SIX_BOILERPLATE(CheckBox);

private:
std::string text;
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/Choice.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ struct Choice : public details::WidgetDetails<Choice, wxChoice> {
return details::BindWidgetToEvent { *this, wxEVT_CHOICE, func };
}

virtual ~Choice() = default;
Choice(Choice const&) = default;
Choice(Choice&&) = default;
auto operator=(Choice const&) -> Choice& = default;
auto operator=(Choice&&) -> Choice& = default;
RULE_OF_SIX_BOILERPLATE(Choice);

private:
std::vector<wxString> choices {};
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/ComboBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ struct ComboBox : public details::WidgetDetails<ComboBox, wxComboBox> {
return details::BindWidgetToEvent { *this, wxEVT_COMBOBOX, func };
}

virtual ~ComboBox() = default;
ComboBox(ComboBox const&) = default;
ComboBox(ComboBox&&) = default;
auto operator=(ComboBox const&) -> ComboBox& = default;
auto operator=(ComboBox&&) -> ComboBox& = default;
RULE_OF_SIX_BOILERPLATE(ComboBox);

private:
std::vector<wxString> choices;
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/Line.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ struct Line : public details::WidgetDetails<Line, wxStaticLine> {
return new underlying_t(parent, getIdentity(), getPos(), getSize(), getStyle());
}

virtual ~Line() = default;
Line(Line const&) = default;
Line(Line&&) = default;
auto operator=(Line const&) -> Line& = default;
auto operator=(Line&&) -> Line& = default;
RULE_OF_SIX_BOILERPLATE(Line);
};

inline auto HLine() -> Line
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/ListBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ struct ListBox : public details::WidgetDetails<ListBox, wxListBox> {
return details::BindWidgetToEvent { *this, wxEVT_LISTBOX, func };
}

virtual ~ListBox() = default;
ListBox(ListBox const&) = default;
ListBox(ListBox&&) = default;
auto operator=(ListBox const&) -> ListBox& = default;
auto operator=(ListBox&&) -> ListBox& = default;
RULE_OF_SIX_BOILERPLATE(ListBox);

private:
std::vector<wxString> choices {};
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/RadioBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ struct RadioBox : details::WidgetDetails<RadioBox, wxRadioBox> {
return details::BindWidgetToEvent { *this, wxEVT_RADIOBOX, func };
}

virtual ~RadioBox() = default;
RadioBox(RadioBox const&) = default;
RadioBox(RadioBox&&) = default;
auto operator=(RadioBox const&) -> RadioBox& = default;
auto operator=(RadioBox&&) -> RadioBox& = default;
RULE_OF_SIX_BOILERPLATE(RadioBox);

private:
std::string text;
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/Slider.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ struct Slider : public details::WidgetDetails<Slider, wxSlider> {
return details::BindWidgetToEvent { *this, wxEVT_SLIDER, func };
}

virtual ~Slider() = default;
Slider(Slider const&) = default;
Slider(Slider&&) = default;
auto operator=(Slider const&) -> Slider& = default;
auto operator=(Slider&&) -> Slider& = default;
RULE_OF_SIX_BOILERPLATE(Slider);

private:
std::optional<std::pair<int, int>> range;
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/SpinCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ struct SpinCtrl : public details::WidgetDetails<SpinCtrl, wxSpinCtrl> {
return details::BindWidgetToEvent { *this, wxEVT_SPINCTRL, func };
}

virtual ~SpinCtrl() = default;
SpinCtrl(SpinCtrl const&) = default;
SpinCtrl(SpinCtrl&&) = default;
auto operator=(SpinCtrl const&) -> SpinCtrl& = default;
auto operator=(SpinCtrl&&) -> SpinCtrl& = default;
RULE_OF_SIX_BOILERPLATE(SpinCtrl);

private:
std::optional<std::pair<int, int>> range;
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/Text.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ struct Text : public details::WidgetDetails<Text, wxStaticText> {
return new underlying_t(parent, getIdentity(), text, getPos(), getSize(), getStyle());
}

virtual ~Text() = default;
Text(Text const&) = default;
Text(Text&&) = default;
auto operator=(Text const&) -> Text& = default;
auto operator=(Text&&) -> Text& = default;
RULE_OF_SIX_BOILERPLATE(Text);

private:
std::string text;
Expand Down
6 changes: 1 addition & 5 deletions include/wxUI/TextCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ struct TextCtrl : public details::WidgetDetails<TextCtrl, wxTextCtrl> {
return details::BindWidgetToEvent { *this, wxEVT_TEXT, func };
}

virtual ~TextCtrl() = default;
TextCtrl(TextCtrl const&) = default;
TextCtrl(TextCtrl&&) = default;
auto operator=(TextCtrl const&) -> TextCtrl& = default;
auto operator=(TextCtrl&&) -> TextCtrl& = default;
RULE_OF_SIX_BOILERPLATE(TextCtrl);

private:
std::string text;
Expand Down
7 changes: 7 additions & 0 deletions include/wxUI/Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,11 @@ struct WidgetDetails {
Underlying** windowHandle {};
};

#define RULE_OF_SIX_BOILERPLATE(WIDGET) \
virtual ~WIDGET() = default; \
WIDGET(WIDGET const&) = default; \
WIDGET(WIDGET&&) = default; \
auto operator=(WIDGET const&)->WIDGET& = default; \
auto operator=(WIDGET&&)->WIDGET& = default;

}

0 comments on commit 4b9c806

Please sign in to comment.