A message wrapped to be used as type of argument for event handlers.
More...
#include <mhood.hpp>
template<typename M>
class so_5::mhood_t< M >
A message wrapped to be used as type of argument for event handlers.
- Since
- v.5.5.14
- Template Parameters
-
M | type of message or signal. |
- Note
- This class provides different sets of methods in dependency of type M. If M is a type derived from so_5::message_t, then there will be the following methods for immutable message M:
const M * get() const;
const M * operator->() const;
const M & operator*() const;
If M is a type derived from so_5::signal_t, then there will no be methods at all. It is because there is no actual message object for a signal. If M is user-type message then there will be the following methods for immutable message M: const M * get() const;
const M * operator->() const;
const M & operator*() const;
For mutable message M there will be the following methods is M is derived from so_5::message_t: M * get();
M * operator->();
M & operator*();
If mutable message M is not derived from so_5::message_t then there will be the following methods: M * get();
M * operator->();
M & operator*();
-
Method make_holder() uses so_5::message_ownership_t::autodetected by default.
- Attention
- Methods make_reference() for mhood_t<mutable_msg<M>> will leave mhood object in nullptr state. It means that mhood must not be used after calling make_reference().
-
Methods make_holder() for mhood_t<mutable_msg<M>> will leave the mhood object empty always. Regardless of Ownership parameter. Methods make_holder() for mhood_t<M> and mhood_t<immutable_msg<M>> will leave value for mhood object regardless of Ownership parameter. For example:
class demo : public agent_t {
void on_immutable_msg(mhood_t<some_msg> cmd) {
auto v = cmd->some_value();
...
}
...
void on_mutable_msg(
mhood_t< mutable_msg<another_msg> > cmd) {
auto v = cmd->some_value();
}
};
- Note
- Class mhood_t can be used for redirection of messages of user types. For example (since v.5.5.19):
{
...
void some_event( mhood_t< std::string > evt ) {
}
};
If mhood_t<mutable_msg<M>> is used then a redirection must be done this way: {
...
void some_event(
mhood_t< mutable_msg<std::string> > evt ) {
}
};
- Examples:
- so_5/delivery_filters/main.cpp, so_5/make_pipeline/main.cpp, so_5/mchain_handler_formats/main.cpp, so_5/news_board/main.cpp, and so_5/wrapped_env_demo_3/main.cpp.
◆ base_type_t
◆ mhood_t()
The documentation for this class was generated from the following file: