-
Notifications
You must be signed in to change notification settings - Fork 38
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
Discussing on the possibility to implement a generalized block class #33
Comments
I agree. class Block
{
public:
enum class State
{
NotInitialized, Initialized, ...
};
private:
State m_state;
protected:
virtual bool customInitialization(std::weak_ptr<IParameterHandler> handler) {return true;};
public:
bool initialize(std::weak_ptr<IParameterHandler> handler)
{
m_state = State::NotInitialized;
if (customInitialization(handler))
{
m_state = State::Initialized;
return true;
}
return false;
};
State getState() const;
void bool close() {return true;};
virtual ~Block();
}; |
I agree on that, however, the user has to check the status of the flag and they may modified it |
That's why I put Also, in my opinion, if you define a specific meaning for a state, you should not let the user the ability to change it freely. There is quite a chance to introduce bugs. |
A block may also contain a virtual bool log(){return true}; This may be really useful for debugging purpose. |
General comment: I would strictly separate interfaces from class that have concrete methods and attributes. In my experience mixing the two concepts creates problems in the long run (sorry for not being verbose, if you are interested we can discuss more in depth). |
Thanks for the hint! |
I propose the block states as,
|
@prashanthr05 if you have already some use case in mind, feel free to open a PR. |
I notice that we are implementing the
initialize()
method for each class (i.e. here or here) and in general the class cannot be used till theinitialize()
method is called.Probably we can generalize the concept by designing a class named
block
(or another name). The other classes will inherit fromblock
.This is an example of the class
This issue is for discussing the possible strategies we can implement.
@traversaro @S-Dafarra @MiladShafiee @prashanthr05
The text was updated successfully, but these errors were encountered: