#if defined( _MSC_VER )
#if defined( __clang__ )
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#endif
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <ctime>
struct msg_hello
{
std::string m_message;
};
{
public:
{}
void evt_hello_delay( const msg_hello & msg );
void evt_stop_signal();
private:
static void show_message( const std::string & what );
};
void a_hello_t::so_define_agent()
{
so_subscribe_self().event( &a_hello_t::evt_hello_delay );
so_subscribe_self().event< msg_stop_signal >( &a_hello_t::evt_stop_signal );
}
void a_hello_t::so_evt_start()
{
show_message( "a_hello_t::so_evt_start()" );
so_5::send_delayed< msg_hello >(
*this,
std::chrono::seconds( 2 ),
"Hello, world! This is SObjectizer v.5." );
}
void a_hello_t::evt_hello_delay( const msg_hello & msg )
{
show_message( msg.m_message );
so_5::send_delayed< msg_stop_signal >(
*this,
std::chrono::seconds( 2 ) );
}
void a_hello_t::evt_stop_signal()
{
show_message( "Stop SObjectizer..." );
so_environment().stop();
}
void a_hello_t::show_message( const std::string & what )
{
time_t t = time( nullptr );
std::cout << std::asctime( std::localtime( &t ) ) << what << std::endl;
}
int main()
{
try
{
{
} );
}
catch( const std::exception & ex )
{
std::cerr << "Error: " << ex.what() << std::endl;
return 1;
}
return 0;
}