#include <iostream>
#include <time.h>
{
struct greeting_message
{
const std::string m_greeting;
};
const state_t st_1{ this, "state_1" };
const state_t st_2{ this, "state_2" };
const state_t st_3{ this, "state_3" };
const state_t st_shutdown{ this, "shutdown" };
public:
{}
{
.
event( [
this]( mhood_t< change_state_signal > ) { st_1.activate(); } )
.event( []( const greeting_message & msg ) {
std::cout << "*** 0) greeting: " << msg.m_greeting
<< ", ptr: " << &msg << std::endl;
} );
st_1
.
event( [
this]( mhood_t< change_state_signal > ) { st_2.activate(); } );
st_2
.
event( [
this]( mhood_t< change_state_signal > ) { st_3.activate(); } )
.event( []( const greeting_message & msg ) {
std::cout << "*** 2) greeting: " << msg.m_greeting
<< ", ptr: " << &msg << std::endl;
} );
st_3
.
event( [
this]( mhood_t< change_state_signal > ) { st_shutdown.activate(); } );
st_shutdown
.
event( [
this]( mhood_t< change_state_signal > ) {
.event( []( const greeting_message & msg ) {
std::cout << "*** F) greeting: " << msg.m_greeting
<< ", ptr: " << &msg << std::endl;
} );
}
{
*this,
std::chrono::milliseconds{ 50 },
std::chrono::milliseconds{ 100 },
"Hello, World!" );
*this,
std::chrono::milliseconds{ 80 },
std::chrono::milliseconds{ 100 } );
}
private:
};
int main()
{
try
{
} );
},
params.message_delivery_tracer(
} );
}
catch( const std::exception & ex )
{
std::cerr << "Error: " << ex.what() << std::endl;
return 1;
}
return 0;
}
A helper header file for including all public SObjectizer stuff.
virtual void so_define_agent()
Hook on define agent for SObjectizer.
void so_deregister_agent_coop_normally()
A helper method for deregistering agent's coop in case of normal deregistration.
const state_t & so_default_state() const
Access to the agent's default state.
virtual void so_evt_start()
Hook on agent start inside SObjectizer.
Agent * make_agent(Args &&... args)
Helper method for simplification of agents creation.
Parameters for the SObjectizer Environment initialization.
decltype(auto) introduce_coop(Args &&... args)
Helper method for simplification of cooperation creation and registration.
A base class for agent signals.
const state_t & event(Args &&... args) const
Helper for subscription of event handler in this state.
An indentificator for the timer.
SO_5_FUNC tracer_unique_ptr_t std_cout_tracer()
Factory for tracer which uses std::cout stream.
void launch(Init_Routine &&init_routine)
Launch a SObjectizer Environment with default parameters.
timer_id_t send_periodic(Target &&target, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period, Args &&... args)
A utility function for creating and delivering a periodic message to the specified destination.