#include <iostream>
#include <sstream>
#include <ace/OS.h>
#include <ace/Log_Msg.h>
class a_disp_user_t
:
{
public:
a_disp_user_t(
const std::string & name )
:
base_type_t( env ),
m_name( name )
{}
virtual ~a_disp_user_t()
{}
virtual void
virtual void
private:
const std::string m_name;
};
#define AGENT_MSG( s ) "TID:%t %T " s
void
a_disp_user_t::so_evt_start()
{
ACE_DEBUG(( LM_INFO,
AGENT_MSG( "%s.so_evt_start(): start pause\n" ), m_name.c_str() ));
ACE_OS::sleep( 1 );
ACE_DEBUG(( LM_INFO,
AGENT_MSG( "%s.so_evt_start(): finish pause\n" ), m_name.c_str() ));
}
void
a_disp_user_t::so_evt_finish()
{
ACE_DEBUG(( LM_INFO,
AGENT_MSG( "%s.so_evt_finish(): start pause\n" ), m_name.c_str() ));
ACE_OS::sleep( 1 );
ACE_DEBUG(( LM_INFO,
AGENT_MSG( "%s.so_evt_finish(): finish pause\n" ), m_name.c_str() ));
}
std::string
create_agent_name( const std::string & base, int i )
{
std::ostringstream sout;
sout << base << "_" << i;
return sout.str();
}
void
{
for( int i = 0; i < 4; ++i )
{
const std::string name = create_agent_name( "default_disp", i+1 );
coop->add_agent(
new a_disp_user_t( env, name ) ) );
}
for( int i = 0; i < 3; ++i )
{
const std::string name = create_agent_name( "single_thread", i+1 );
coop->add_agent(
"single_thread" ) );
}
for( int i = 0; i < 2; ++i )
{
const std::string name = create_agent_name( "active_group_A", i+1 );
coop->add_agent(
"active_group",
"A" ) );
}
for( int i = 0; i < 2; ++i )
{
const std::string name = create_agent_name( "active_group_B", i+1 );
coop->add_agent(
"active_group",
"B" ) );
}
for( int i = 0; i < 4; ++i )
{
const std::string name = create_agent_name( "active_obj", i+1 );
coop->add_agent(
"active_obj" ) );
}
}
int
main( int, char ** argv )
{
ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR);
try
{
&init,
.add_named_dispatcher(
.add_named_dispatcher(
.add_named_dispatcher(
}
catch( const std::exception & ex )
{
std::cerr << "Error: " << ex.what() << std::endl;
return 1;
}
return 0;
}