SObjectizer  5.5
Namespaces | Typedefs | Functions
so_5::api Namespace Reference

Public API functions of SObjectizer-5. More...

Namespaces

 impl
 Internal implemetation details of public API functions.
 

Typedefs

typedef void(* pfn_so_environment_init_t) (so_5::environment_t &)
 Typedef for a simple SObjectizer-initialization function. More...
 
typedef std::function< void(so_5::environment_t &) > generic_simple_init_t
 Generic type for a simple SObjectizer-initialization function. More...
 
typedef std::function< void(so_5::environment_params_t &) > generic_simple_so_env_params_tuner_t
 Generic type for a simple SO Environment paramenters tuning function. More...
 

Functions

void run_so_environment (generic_simple_init_t init_routine, so_5::environment_params_t &&env_params)
 Launch a SObjectizer Environment with arguments. More...
 
void run_so_environment (generic_simple_init_t init_routine)
 Launch a SObjectizer Environment with default arguments. More...
 
void run_so_environment (generic_simple_init_t init_routine, generic_simple_so_env_params_tuner_t params_tuner)
 Launch a SObjectizer Environment with arguments. More...
 
template<class Init , class Param_Type >
void run_so_environment_with_parameter (Init init_func, const Param_Type &param, so_5::environment_params_t &&env_params)
 
template<class Init , class Param_Type >
void run_so_environment_with_parameter (Init init_func, const Param_Type &param)
 
template<class Object , class Method >
void run_so_environment_on_object (Object &obj, Method init_func, so_5::environment_params_t &&env_params)
 
template<class Object , class Method >
void run_so_environment_on_object (Object &obj, Method init_func)
 Launch a SObjectizer Environment by a class method. More...
 

Detailed Description

Public API functions of SObjectizer-5.

Typedef Documentation

◆ generic_simple_init_t

typedef std::function< void(so_5::environment_t &) > so_5::api::generic_simple_init_t

Generic type for a simple SObjectizer-initialization function.

Since
v.5.3.0

◆ generic_simple_so_env_params_tuner_t

Generic type for a simple SO Environment paramenters tuning function.

Since
v.5.3.0

◆ pfn_so_environment_init_t

typedef void(* so_5::api::pfn_so_environment_init_t) (so_5::environment_t &)

Typedef for a simple SObjectizer-initialization function.

Function Documentation

◆ run_so_environment() [1/3]

void so_5::api::run_so_environment ( generic_simple_init_t  init_routine,
so_5::environment_params_t &&  env_params 
)
inline

Launch a SObjectizer Environment with arguments.

Example:

void
init( so_5::environment_t & env )
{
auto coop = env.create_coop( "main_coop" );
coop->make_agent< a_main_t >();
env.register_coop( std::move( coop ) );
}
...
int
main( int argc, char * argv[] )
{
&init,
std::move(
.mbox_mutex_pool_size( 16 )
.agent_coop_mutex_pool_size( 16 )
.agent_event_queue_mutex_pool_size( 16 ) ) );
return 0;
}
Deprecated:
Obsolete in v.5.5.0. Use so_5::launch() instead.
Parameters
init_routineInitialization routine.
env_paramsEnvironment's parameters.

◆ run_so_environment() [2/3]

void so_5::api::run_so_environment ( generic_simple_init_t  init_routine)
inline

Launch a SObjectizer Environment with default arguments.

Example:

void
init( so_5::environment_t & env )
{
auto coop = env.create_coop( "main_coop" );
coop->make_agent< a_main_t >();
env.register_coop( std::move( coop ) );
}
...
int
main( int argc, char * argv[] )
{
try
{
}
catch( const std::exception & ex )
{
std::cerr << "Error: " << ex.what() << std::endl;
return 1;
}
return 0;
}
Deprecated:
Obsolete in v.5.5.0. Use so_5::launch() instead.
Parameters
init_routineInitialization routine.

◆ run_so_environment() [3/3]

void so_5::api::run_so_environment ( generic_simple_init_t  init_routine,
generic_simple_so_env_params_tuner_t  params_tuner 
)
inline

Launch a SObjectizer Environment with arguments.

Since
v.5.3.0

A lambda-functions could be used as for starting actions and as environment parameters tunning.

Example:

void
init( so_5::environment_t & env )
{
auto coop = env.create_coop( "main_coop" );
coop->make_agent< a_main_t >();
env.register_coop( std::move( coop ) );
}
...
int
main( int argc, char * argv[] )
{
&init,
params.mbox_mutex_pool_size( 16 )
.agent_coop_mutex_pool_size( 16 )
.agent_event_queue_mutex_pool_size( 16 );
} );
return 0;
}
Deprecated:
Obsolete in v.5.5.0. Use so_5::launch() instead.
Parameters
init_routineInitialization routine.
params_tunerEnvironment's parameters tuner.

◆ run_so_environment_on_object() [1/2]

template<class Object , class Method >
void so_5::api::run_so_environment_on_object ( Object &  obj,
Method  init_func,
so_5::environment_params_t &&  env_params 
)

Launch a SObjectizer Environment by a class method and with specified Environment parameters.


Example:

struct client_data_t
{
std::string m_server_addr;
protocol_parser_t m_protocol_parser;
void
init( so_5::environment_t & env )
{
// Make a cooperation.
"test_client_application",
"active_obj" ) );
so_5_transport::socket::connector_controller_creator_t
connector_creator( env );
using so_5_transport::a_server_transport_agent_t;
auto ta = coop->make_agent< a_server_transport_agent_t >(
a_server_transport_agent_t(
acceptor_creator.create( server_addr ) ) );
coop->make_agent< a_main_t >(
ta->query_notificator_mbox(),
m_protocol_parser );
// Register the cooperation.
env.register_coop( coop );
}
};
// ...
int
main( int argc, char ** argv )
{
if( 3 == argc )
{
client_data_t client_data;
client_data.m_server_addr = argv[ 1 ];
client_data.m_protocol_parser = create_protocol( argv[ 2 ] );
client_data,
&client_data_t::init,
std::move(
.add_named_dispatcher( "active_obj",
.add_layer(
std::unique_ptr< so_5_transport::reactor_layer_t >(
new so_5_transport::reactor_layer_t ) ) ) );
}
else
std::cerr << "sample.client <port> <protocol_version>" << std::endl;
return 0;
}
Deprecated:
Obsolete in v.5.5.0. Use so_5::launch() instead.
Parameters
objInitialization object. Its method should be used as the initialization routine.
init_funcInitialization routine.
env_paramsSObjectizer Environment parameters.

◆ run_so_environment_on_object() [2/2]

template<class Object , class Method >
void so_5::api::run_so_environment_on_object ( Object &  obj,
Method  init_func 
)

Launch a SObjectizer Environment by a class method.

Deprecated:
Obsolete in v.5.5.0. Use so_5::launch() instead.
Parameters
objInitialization object. Its method should be used as the initialization routine.
init_funcInitialization routine.

◆ run_so_environment_with_parameter() [1/2]

template<class Init , class Param_Type >
void so_5::api::run_so_environment_with_parameter ( Init  init_func,
const Param_Type &  param,
so_5::environment_params_t &&  env_params 
)

Launch a SObjectizer Environment with the parametrized initialization routine and Enviroment parameters.


Allows to pass an additional argument to the initialization process.

void
init(
const std::string & server_addr )
{
// Make a cooperation.
"test_server_application",
"active_obj" ) );
so_5_transport::socket::acceptor_controller_creator_t
acceptor_creator( env );
using so_5_transport::a_server_transport_agent_t;
auto ta = coop->make_agent< a_server_transport_agent_t >(
a_server_transport_agent_t(
acceptor_creator.create( server_addr ) ) );
coop->make_agent< a_main_t >( ta->query_notificator_mbox() );
// Register the cooperation.
env.register_coop( coop );
}
// ...
int
main( int argc, char ** argv )
{
if( 2 == argc )
{
std::string server_addr( argv[ 1 ] );
&init,
server_addr,
std::move(
.add_named_dispatcher( "active_obj",
.add_layer(
std::unique_ptr< so_5_transport::reactor_layer_t >(
new so_5_transport::reactor_layer_t ) ) ) );
}
else
std::cerr << "sample.server <port>" << std::endl;
return 0;
}
Deprecated:
Obsolete in v.5.5.0. Use so_5::launch() instead.
Parameters
init_funcInitialization routine. The prototype: void init( env, my_param ) is required.
paramInitialization routine argument.
env_paramsSObjectizer Environment parameters.

◆ run_so_environment_with_parameter() [2/2]

template<class Init , class Param_Type >
void so_5::api::run_so_environment_with_parameter ( Init  init_func,
const Param_Type &  param 
)

Launch a SObjectizer Environment with the parametrized initialization routine.


Allows to pass an additional argument to the initialization process.

void
init(
const std::string & server_addr )
{
// Make a cooperation.
"test_server_application",
"active_obj" ) );
so_5_transport::socket::acceptor_controller_creator_t
acceptor_creator( env );
using so_5_transport::a_server_transport_agent_t;
auto ta = coop->make_agent< a_server_transport_agent_t >(
a_server_transport_agent_t(
acceptor_creator.create( server_addr ) ) );
coop->make_agent< a_main_t >( ta->query_notificator_mbox() );
// Register the cooperation.
env.register_coop( coop );
}
// ...
int
main( int argc, char ** argv )
{
if( 2 == argc )
{
std::string server_addr( argv[ 1 ] );
&init,
server_addr,
std::move(
.add_named_dispatcher( "active_obj",
.add_layer(
std::unique_ptr< so_5_transport::reactor_layer_t >(
new so_5_transport::reactor_layer_t ) ) ) );
}
else
std::cerr << "sample.server <port>" << std::endl;
return 0;
}
Deprecated:
Obsolete in v.5.5.0. Use so_5::launch() instead.
Parameters
init_funcInitialization routine. The prototype: void init( env, my_param ) is required.
paramInitialization routine argument.