-
Notifications
You must be signed in to change notification settings - Fork 47
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
Use so_default_state as a parent state for an another state #13
Comments
Good question! :) I think it's some heritage from ancient times. I don't think there are some reasons that prevent making |
There is a hidden underwater rock: a call to class demo final : public so_5::agent_t {
state_t st_parent{this, "parent"};
state_t st_child_1{initial_substate_of{st_parent}, "child_1"};
state_t st_child_2{substate_of{st_parent}, "child_2"};
...
void so_define_agent() override {
st_child.on_enter([]{ std::cout << "Hello, World!" << std::endl; });
...
this >>= st_parent;
}
}; In that case "Hello, World" would be printed at the start of demo agent. But in that case: class demo final : public so_5::agent_t {
state_t st_child_1{initial_substate_of{so_default_state()}, "child_1"};
state_t st_child_2{substate_of{so_default_state()}, "child_2"};
...
void so_define_agent() override {
st_child.on_enter([]{ std::cout << "Hello, World!" << std::endl; });
...
}
}; The enter handler for |
Hm... interesting case. In my opinion that's just "nice to know" thing, which shall be documented, if you want to allow For now locally I just created my own default state :) |
Hi!
Is it possible with SObjectizer to use default agent state (which is returned with
so_default_state
) as a parent state for another state? I am trying to do something like this:Unfortunately
initial_substate_of
takes a non-const reference butso_default_state
returns const reference, so it doesn't compile.Is there any workaround (except introducing own "default" state and making it as a parent for another events)? Is it a limitation by design?
Thank you.
The text was updated successfully, but these errors were encountered: