Comments (3)
Good question! :)
I think it's some heritage from ancient times. I don't think there are some reasons that prevent making agent_t::st_default
non-const member of agent_t
. I'll try to look deeper tomorrow (or Monday) and if there is no any other issues I'll change the st_default
and add a new overload for so_default_state
.
from sobjectizer.
There is a hidden underwater rock: a call to on_enter
handlers for child states. For example:
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 st_child
won't be called at the start of demo agent. It's because st_default
is already the current state for the agent and SObjectizer doesn't know about changes that should be taken into the account.
from sobjectizer.
Hm... interesting case. In my opinion that's just "nice to know" thing, which shall be documented, if you want to allow so_default_state
as a parent state in SObjectizer. In my case the example above doesn't matter at all.
For now locally I just created my own default state :)
from sobjectizer.
Related Issues (20)
- Asynchrony of register_coop HOT 4
- Documentation for message_holder_t has to be extended HOT 1
- A usage example for agent_t::limit_then_redirect method in API Reference HOT 1
- [Design] Your opinion on expressing agent intent HOT 2
- Deprecation of coop_t::deregister and coop_t::deregister_normally methods HOT 1
- [idea] An emergency stop of SOEnv on an exception in noexcept context HOT 1
- `so_evt_finish` not called until `so_evt_start` is running? HOT 2
- Should agent_t::so_drop_subscription* methods be marked as noexcept? HOT 1
- Should delivery filters be checked for noexcept-ness?
- bind_and_transform HOT 10
- so_5::details::make_message_instance_impl metafunction doesn't set message mutability flag properly HOT 1
- limit_then_transform for mutable messages HOT 1
- Allow `const auto &` as an argument for delivery filter in single/multi_sink_binding HOT 1
- Should there be agent_t::so_disp_binder() and agent_t::so_coop_default_disp_binder() methods? HOT 2
- [idea] Make so5extra's revocable timers the default implementation for timers in SObjectizer
- Another constructor for wrapped_env_t that waits completion of init-function HOT 1
- Use of message limits and state_t::time_limit
- Optional name for an agent? HOT 2
- New method `as_string_view` for so_5::stats::prefix_t and so_5::stats::suffix_t HOT 1
- SO_5_TYPE shouldn't be used for so_5::stats::messages::quantity
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sobjectizer.