-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor the abstract class CreateConnectedElementI #1047
base: cpacs_creator_dev_merge
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,45 @@ | |
#define MODIFICATORSECTIONSWIDGET_H | ||
|
||
#include <QWidget> | ||
#include "CreateConnectedElementI.h" | ||
#include <string> | ||
#include "CCPACSFuselage.h" | ||
#include "CCPACSWing.h" | ||
|
||
namespace Ui | ||
{ | ||
|
||
// Interface-like structure to account for different possible object types whose member variables may be adapted by the CPACSCreator. | ||
// It is currently used for CCPACSFuselage and CCPACSWing. | ||
// Could be extended by Duct, Pylon, Tank, etc. in the future (observe: The respective classes need to define the listed functions). | ||
struct ElementModificatorInterface | ||
{ | ||
// Here, functions are defined as member variables calling the 'right' (depending on present data type) function from CCPACSFuselage, CCPACSWing, etc. via lambdas | ||
template <typename T> | ||
ElementModificatorInterface(T&& t) | ||
: CreateNewConnectedElementAfter( | ||
[&t](std::string str){ return t.CreateNewConnectedElementAfter(str); } | ||
) | ||
, CreateNewConnectedElementBefore( | ||
[&t](std::string str){ return t.CreateNewConnectedElementBefore(str); } | ||
) | ||
, CreateNewConnectedElementBetween( | ||
[&t](std::string str1, std::string str2){ return t.CreateNewConnectedElementBetween(str1, str2); } | ||
) | ||
, DeleteConnectedElement( | ||
[&t](std::string str){ return t.DeleteConnectedElement(str); } | ||
) | ||
, GetOrderedConnectedElement( | ||
[&t](){ return t.GetOrderedConnectedElement(); } | ||
) | ||
{} | ||
|
||
std::function<void(std::string)> CreateNewConnectedElementAfter; | ||
std::function<void(std::string)> CreateNewConnectedElementBefore; | ||
std::function<void(std::string, std::string)> CreateNewConnectedElementBetween; | ||
std::function<void(std::string)> DeleteConnectedElement; | ||
std::function<std::vector<std::string>()> GetOrderedConnectedElement; | ||
}; | ||
|
||
class ModificatorSectionsWidget; | ||
} | ||
|
||
|
@@ -42,11 +77,11 @@ public slots: | |
explicit ModificatorSectionsWidget(QWidget* parent = nullptr); | ||
~ModificatorSectionsWidget(); | ||
|
||
void setCreateConnectedElementI(tigl::CreateConnectedElementI& elementI); | ||
void setCreateConnectedElement(Ui::ElementModificatorInterface& element); | ||
|
||
private: | ||
Ui::ModificatorSectionsWidget* ui; | ||
tigl::CreateConnectedElementI* createConnectedElementI; | ||
Ui::ElementModificatorInterface* createConnectedElement; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe with the current changes, we should store by value here. The |
||
}; | ||
|
||
#endif // MODIFICATORSECTIONSWIDGET_H |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the argument be
const
?