2
3
6
7
8
9
10
12#include <so_5/experimental/testing/v1/all.hpp>
14#include <so_5/details/safe_cv_wait_for.hpp>
16#include <so_5/impl/enveloped_msg_details.hpp>
31 std::type_index msg_type,
32 mbox_id_t src_mbox_id )
59 completion_function_t joined_version =
60 [old_fn = m_completion, new_fn = std::move(fn)]
81 activation_function_t joined_version =
82 [old_fn = m_activation, new_fn = std::move(fn)]
98 const incident_info_t & info )
const noexcept
129
130
131
132
136 using preactivate_actions_container_t =
137 std::vector< preactivate_action_t >;
150
151
152
153
154
155
156
157
161
162
163
164
165
171
172
179
180
181
182
183
192 :
m_name( std::move(name) )
211 const scenario_in_progress_accessor_t & scenario_accessor,
212 const incident_info_t & info,
213 const message_ref_t & incoming_msg )
noexcept override
231 const scenario_in_progress_accessor_t & scenario_accessor,
232 token_t token )
noexcept override
257 const scenario_in_progress_accessor_t & scenario_accessor,
258 const incident_info_t & info,
259 const message_ref_t & incoming_msg )
noexcept override
280 preactivate_action_t action )
override
287 trigger_container_t triggers,
288 std::size_t triggers_to_activate )
noexcept override
302 constraint_container_t constraints )
noexcept override
313
314
315
316
317
318
319
349
350
355 const incident_info_t & info )
const noexcept
358 if( !c->
check( incident_status
, info
) )
370 const incident_info_t & info )
noexcept
384 static_cast<trigger_container_t::iterator::difference_type>(
387 auto it = std::find_if(
389 [incident_status, &info]
390 ( trigger_unique_ptr_t & trigger ) {
391 return trigger->
check( incident_status
, info
);
397 trigger_t * active_trigger = it->get();
414 result = token_t
{ active_trigger
};
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
466
467
468
469
475
476
477
487
488
492
493
494
495
503
504
505 using state_name_map_t = std::map<
506 std::pair< std::string, std::string >,
511
512
513 using inspection_result_map_t = std::map<
514 std::pair< std::string, std::string >,
522
523
528
529
537
538
539
550 std::lock_guard< std::mutex > lock{
m_lock };
554 "new testing scenario step can be defined only when "
555 "scenario is not started yet" );
558 std::make_unique< real_scenario_step_t >(
568 std::lock_guard< std::mutex > lock{
m_lock };
577 run_for( std::chrono::steady_clock::duration run_time )
override
579 std::unique_lock< std::mutex > lock{
m_lock };
608 const incident_info_t & info,
609 const message_ref_t & incoming_msg )
noexcept override
613 std::lock_guard< std::mutex > lock{
m_lock };
628 token_t token )
noexcept override
630 std::lock_guard< std::mutex > lock{
m_lock };
657 const incident_info_t & info,
658 const message_ref_t & incoming_msg )
noexcept override
660 std::lock_guard< std::mutex > lock{
m_lock };
673 const scenario_in_progress_accessor_t & ,
675 const std::string & tag,
676 const std::string & state_name )
override
683 const scenario_in_progress_accessor_t & ,
685 const std::string & tag,
686 const std::string & inspection_result )
override
695 const std::string & step_name,
696 const std::string & tag )
const override
698 std::lock_guard< std::mutex > lock{
m_lock };
703 "scenario must be completed before call to "
704 "stored_state_name()" );
707 std::make_pair(step_name, tag) );
711 "unable to find stored state name for <" +
712 step_name +
"," + tag +
">" );
720 const std::string & step_name,
721 const std::string & tag )
const override
723 std::lock_guard< std::mutex > lock{
m_lock };
728 "scenario must be completed before call to "
729 "stored_state_name()" );
732 std::make_pair(step_name, tag) );
738 const std::string & step_name,
739 const std::string & tag )
const override
741 std::lock_guard< std::mutex > lock{
m_lock };
746 "scenario must be completed before call to "
747 "stored_msg_inspection_result()" );
750 std::make_pair(step_name, tag) );
754 "unable to find stored msg inspection result for <" +
755 step_name +
"," + tag +
">" );
763 const std::string & step_name,
764 const std::string & tag )
const override
766 std::lock_guard< std::mutex > lock{
m_lock };
771 "scenario must be completed before call to "
772 "has_stored_msg_inspection_result()" );
776 std::make_pair(step_name, tag) );
790 const incident_info_t & info,
791 const message_ref_t & incoming_msg )
noexcept
807 result = token_t
{ &step_to_check
, std::move(step_token)
};
834 const incident_info_t & info,
835 const message_ref_t & incoming_msg )
noexcept
892 std::ostringstream ss;
895 ss <<
"preactivated step:"
898 ss <<
"all steps handled";
904 ss <<
" active steps:{";
905 bool need_comma =
false;
920 ss <<
" stored states:{";
921 bool need_comma =
false;
929 ss <<
"[" << p.first.first <<
", "
930 << p.first.second <<
"]="
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
1010 class pre_handler_hook_invoker_t
final :
public handler_invoker_t
1030 invoke(
const payload_info_t & payload )
noexcept override
1048 class no_handler_invoker_t
final :
public handler_invoker_t
1061 invoke(
const payload_info_t & payload )
noexcept override
1075 class invoker_for_message_extraction_t
final
1117 auto & nested_envelope =
1151 no_handler_invoker_t invoker_no_handler_hook
{
1154 invoker_for_message_extraction_t special_invoker
{
1167 access_context_t context,
1169 handler_invoker_t & invoker )
noexcept override
1177 pre_handler_hook_invoker_t pre_handler_hook_invoker
{
1185 invoker_for_message_extraction_t special_invoker
{
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1268
1269
1294 std::lock_guard< std::mutex > lock{
m_lock };
1297 m_buffer.push_back( std::move(demand) );
1322 message_ref_t new_env{
1323 std::make_unique< special_envelope_t >(
1357 std::lock_guard< std::mutex > lock{
m_lock };
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388class stop_guard_for_unfreezer_t
final
1390 ,
public std::enable_shared_from_this< stop_guard_for_unfreezer_t >
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429class special_event_queue_hook_t
final
1444
1445
1446
1447
1448
1449
1450
1451
1466 std::lock_guard< std::mutex > lock{
m_lock };
1468 auto sq = std::make_unique< special_event_queue_t >(
1476 return sq.release();
1498 std::lock_guard< std::mutex > lock{
m_lock };
1508 for(
auto * sq : tmp )
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1532
1533
1534
1535
1536
1563 event_queue_hook_unique_ptr_t{
1572 so_5::generic_simple_so_env_params_tuner_t env_params_tuner )
1575 env_params_tuner( result );
1590 ::msg_catcher_map_layer_t;
1592 std::make_unique< msg_catcher_map_layer_t >()
);
1594 return std::move(params);
1622 std::chrono::steady_clock::duration run_time )
1629 const std::string & step_name,
1630 const std::string & tag )
const
1637 const std::string & step_name,
1638 const std::string & tag )
const
1645 const std::string & step_name,
1646 const std::string & tag )
const
1653 const std::string & step_name,
1654 const std::string & tag )
const
1667 so_5::generic_simple_so_env_params_tuner_t env_params_tuner )
1724 std::make_shared<
impl::stop_guard_for_unfreezer_t >(
virtual mbox_id_t id() const =0
Unique ID of this mbox.
static demand_handler_pfn_t get_demand_handler_on_message_ptr() noexcept
const mbox_t & so_direct_mbox() const
Get the agent's direct mbox.
static demand_handler_pfn_t get_demand_handler_on_enveloped_msg_ptr() noexcept
An interface of envelope with some message/signal inside.
virtual void access_hook(access_context_t context, handler_invoker_t &invoker) noexcept=0
An extended version of handling_context which can be used for calling event handler.
virtual void invoke(const payload_info_t &payload) noexcept=0
Call an actual handler for the enveloped message/signal.
An information about payload inside envelope.
message_ref_t & message() const noexcept
payload_info_t(message_ref_t message)
Initializing constructor.
Parameters for the SObjectizer Environment initialization.
void event_queue_hook(event_queue_hook_unique_ptr_t hook)
Set event_queue_hook object.
environment_params_t & add_layer(std::unique_ptr< SO_Layer > layer_ptr)
Add an additional layer to the SObjectizer Environment.
environment_params_t()
Constructor.
void remove_stop_guard(stop_guard_shptr_t guard)
Remove stop_guard and complete the stop operation if necessary.
stop_guard_t::setup_result_t setup_stop_guard(stop_guard_shptr_t guard, stop_guard_t::what_if_stop_in_progress_t reaction_on_stop_in_progress=stop_guard_t::what_if_stop_in_progress_t::throw_exception)
Set up a new stop_guard.
Interface of event_queue_hook object.
static void noop_deleter(event_queue_hook_t *) noexcept
An implementation of no-op deleter.
An interface of event queue for agent.
virtual void push(execution_demand_t demand)=0
Enqueue new event to the queue.
trigger_t & trigger() const noexcept
Get a reference to activated trigger.
token_t(trigger_t *trigger) noexcept
bool valid() const noexcept
An interface of testing scenario step.
virtual void no_handler_hook(const scenario_in_progress_accessor_t &scenario_accessor, const incident_info_t &info, const message_ref_t &incoming_msg) noexcept=0
virtual const std::string & name() const noexcept=0
Get the name of the step.
virtual void post_handler_hook(const scenario_in_progress_accessor_t &scenario_accessor, token_t token) noexcept=0
Hook that should be called just after completion of event-handler.
virtual void preactivate() noexcept=0
Perform preactivation of the step.
virtual token_t pre_handler_hook(const scenario_in_progress_accessor_t &scenario_accessor, const incident_info_t &info, const message_ref_t &incoming_msg) noexcept=0
Hook that should be called before invocation of event-handler.
virtual status_t status() const noexcept=0
Get the current status of the step.
abstract_scenario_step_t & activated_step() const noexcept
abstract_scenario_step_t::token_t step_token() const noexcept
token_t(abstract_scenario_step_t *activated_step, abstract_scenario_step_t::token_t step_token)
bool valid() const noexcept
An interface of testing scenario.
scenario_in_progress_accessor_t make_accessor() noexcept
Helper method for creation of scenario_in_progress_accessor instance.
virtual void run_for(std::chrono::steady_clock::duration run_time)=0
Run the scenario until completion or for specific amount of time.
virtual token_t pre_handler_hook(const incident_info_t &info, const message_ref_t &incoming_msg) noexcept=0
Hook that should be called before invocation of event-handler.
virtual std::string stored_msg_inspection_result(const std::string &step_name, const std::string &tag) const =0
Get a value of stored msg inspection result.
virtual void post_handler_hook(token_t token) noexcept=0
Hook that should be called just after completion of event-handler.
virtual void no_handler_hook(const incident_info_t &info, const message_ref_t &incoming_msg) noexcept=0
virtual bool has_stored_state_name(const std::string &step_name, const std::string &tag) const =0
Check presence of the stored state name.
virtual std::string stored_state_name(const std::string &step_name, const std::string &tag) const =0
Get the stored state name.
virtual scenario_result_t result() const noexcept=0
Get the result of scenario execution.
virtual step_definition_proxy_t define_step(nonempty_name_t step_name)=0
Create a new step and return proxy for it.
virtual bool has_stored_msg_inspection_result(const std::string &step_name, const std::string &tag) const =0
Is there the inspection result?
An interface for object that will unfreeze all registered agents when testing scenario starts.
agent_unfreezer_t(const agent_unfreezer_t &)=delete
agent_unfreezer_t & operator=(const agent_unfreezer_t &)=delete
agent_unfreezer_t()=default
virtual void unfreeze() noexcept=0
Issue a command to unfreeze all frozen agents.
agent_unfreezer_t(agent_unfreezer_t &&)=delete
agent_unfreezer_t & operator=(agent_unfreezer_t &&)=delete
virtual ~agent_unfreezer_t()=default
virtual void start() noexcept=0
Hook for step preactivation.
virtual bool check(const incident_status_t incident_status, const incident_info_t &info) const noexcept=0
Check for fulfillment of constraint.
virtual void finish() noexcept=0
Hook for step completion.
msg_catcher_map_layer_t()
~msg_catcher_map_layer_t() noexcept override
preactivate_actions_container_t m_preactivate_actions
All preactivation actions.
std::size_t m_triggers_activated
Count of triggers those are activated.
void no_handler_hook(const scenario_in_progress_accessor_t &scenario_accessor, const incident_info_t &info, const message_ref_t &incoming_msg) noexcept override
token_t pre_handler_hook(const scenario_in_progress_accessor_t &scenario_accessor, const incident_info_t &info, const message_ref_t &incoming_msg) noexcept override
Hook that should be called before invocation of event-handler.
bool try_pass_constraints(const incident_status_t incident_status, const incident_info_t &info) const noexcept
An attempt to check constraints for a new incident.
void setup_constraints(constraint_container_t constraints) noexcept override
Setup constraints for the step.
void preactivate() noexcept override
Perform preactivation of the step.
const std::string m_name
Name of a step.
std::size_t m_last_non_activated_trigger
Index of last trigger in the first part of trigger's container.
std::size_t m_triggers_to_activate
status_t status() const noexcept override
Get the current status of the step.
std::size_t m_triggers_to_completion
Count of activated triggers those are not completed yet.
status_t m_status
The current state of the step.
void post_handler_hook(const scenario_in_progress_accessor_t &scenario_accessor, token_t token) noexcept override
Hook that should be called just after completion of event-handler.
const std::string & name() const noexcept override
Get the name of the step.
token_t try_activate(const trigger_activation_context_t &context, const incident_status_t incident_status, const incident_info_t &info) noexcept
An attempt to activate the step when a new incident arrives.
constraint_container_t m_constraints
All constraints.
trigger_container_t m_triggers
All triggers.
real_scenario_step_t(std::string name)
void add_preactivate_action(preactivate_action_t action) override
Add another preactivation action.
void setup_triggers(trigger_container_t triggers, std::size_t triggers_to_activate) noexcept override
Setup triggers for the step.
void change_status(status_t status) noexcept
void no_handler_hook(const incident_info_t &info, const message_ref_t &incoming_msg) noexcept override
std::string stored_msg_inspection_result(const std::string &step_name, const std::string &tag) const override
Get a value of stored msg inspection result.
bool has_stored_state_name(const std::string &step_name, const std::string &tag) const override
Check presence of the stored state name.
void check_scenario_completion() noexcept
std::size_t m_waiting_step_index
Index of the current preactivated step.
void switch_to_next_step_if_possible()
std::set< abstract_scenario_step_t * > m_active_steps
Set of active step those are not completed yet.
scenario_result_t result() const noexcept override
Get the result of scenario execution.
void store_msg_inspection_result(const scenario_in_progress_accessor_t &, const abstract_scenario_step_t &step, const std::string &tag, const std::string &inspection_result) override
Store msg inspection result in the scenario.
std::string describe_current_state() const
bool has_stored_msg_inspection_result(const std::string &step_name, const std::string &tag) const override
Is there the inspection result?
std::string stored_state_name(const std::string &step_name, const std::string &tag) const override
Get the stored state name.
token_t react_on_pre_handler_hook(const incident_info_t &info, const message_ref_t &incoming_msg) noexcept
std::condition_variable m_completion_cv
Condition variable for waiting completion of the scenario.
void react_on_no_handler_hook(const incident_info_t &info, const message_ref_t &incoming_msg) noexcept
void preactivate_current_step()
void post_handler_hook(token_t token) noexcept override
Hook that should be called just after completion of event-handler.
void run_for(std::chrono::steady_clock::duration run_time) override
Run the scenario until completion or for specific amount of time.
agent_unfreezer_t * m_unfreezer
Unfreezer for registered agents.
real_scenario_t()=default
void setup_unfreezer(agent_unfreezer_t &unfreezer) noexcept
Set the unfreezer for registered agents.
inspection_result_map_t m_stored_inspection_results
Container for holding stored inspection results for messages.
void store_state_name(const scenario_in_progress_accessor_t &, const abstract_scenario_step_t &step, const std::string &tag, const std::string &state_name) override
Store a name of an agent state in the scenario.
token_t pre_handler_hook(const incident_info_t &info, const message_ref_t &incoming_msg) noexcept override
Hook that should be called before invocation of event-handler.
std::mutex m_lock
Object lock.
step_definition_proxy_t define_step(nonempty_name_t step_name) override
Create a new step and return proxy for it.
state_name_map_t m_stored_states
Container for holding stored state names.
scenario_status_t m_status
The current state of the scenario.
std::vector< step_unique_ptr_t > m_steps
Scenario's steps.
activation_function_t m_activation
Optional function for activation of the trigger.
const std::type_index m_msg_type
Type of message/signal to activate the trigger.
completion_function_t m_completion
Optional function for completion of the trigger.
void set_completion(completion_function_t fn)
Setter for completion function.
void set_activation(activation_function_t fn)
Setter for activation function.
void activate(const trigger_activation_context_t &context) noexcept
Do activation of the trigger.
bool check(const incident_status_t incident_status, const incident_info_t &info) const noexcept
Check for activation of the trigger.
const mbox_id_t m_src_mbox_id
ID of source mbox of message/signal to activate the trigger.
trigger_t(incident_status_t incident_status, const agent_t &target, std::type_index msg_type, mbox_id_t src_mbox_id)
Initializing constructor.
const agent_t & target_agent() const noexcept
Get the reference of the target agent.
const incident_status_t m_incident_status
What should happen with initial message/signal.
bool requires_completion() const noexcept
Does this trigger require separate completion action?
const mbox_id_t m_target_id
The unique ID of target's direct mbox.
void complete(const trigger_completion_context_t &context) noexcept
Do completion of a trigger.
const agent_t & m_target_agent
A reference to the target agent.
void invoke(const payload_info_t &payload) noexcept override
Call an actual handler for the enveloped message/signal.
no_handler_invoker_t(outliving_reference_t< special_envelope_t > owner)
Initializing constructor.
outliving_reference_t< special_envelope_t > m_owner
Owner of this invoker.
outliving_reference_t< handler_invoker_t > m_actual_invoker
Invoker to be used to call the actual event handler.
void invoke(const payload_info_t &payload) noexcept override
Call an actual handler for the enveloped message/signal.
pre_handler_hook_invoker_t(outliving_reference_t< special_envelope_t > owner, outliving_reference_t< handler_invoker_t > actual_invoker)
Intializing constructor.
outliving_reference_t< special_envelope_t > m_owner
Owner of this invoker.
outliving_reference_t< details::abstract_scenario_t > m_scenario
A testing scenario for that envelope.
~special_envelope_t() noexcept override
@ delivered
Message delivered to the destination agent.
@ suppressed_by_envelope
Message suppressed by a nested envelope.
@ ignored
Message ignored by the destination agent.
special_envelope_t(outliving_reference_t< details::abstract_scenario_t > scenario, const execution_demand_t &demand)
Initializing constructor.
message_ref_t m_message
Enveloped message.
details::incident_info_t m_demand_info
Information about enveloped message.
void access_hook(access_context_t context, handler_invoker_t &invoker) noexcept override
delivery_result_t m_delivery_result
Was this message handled by a receiver?
void unfreeze() noexcept override
Issue a command to unfreeze all frozen agents.
std::mutex m_lock
Lock for this object.
outliving_reference_t< details::abstract_scenario_t > m_scenario
Testing scenario for that this object is created.
void on_unbind(agent_t *, event_queue_t *queue) noexcept override
A reaction to unbinding of an agent from some event_queue.
queue_mode_t m_mode
Mode of operation for new queues.
std::vector< special_event_queue_t * > m_created_queues
List of all queues created before unfreeze was called.
special_event_queue_hook_t(outliving_reference_t< details::abstract_scenario_t > scenario)
event_queue_t * on_bind(agent_t *, event_queue_t *original_queue) noexcept override
A reaction to binding of an agent to some event_queue.
std::vector< execution_demand_t > m_buffer
Local storage for demands to be used in buffered mode.
static bool is_ordinary_demand(const execution_demand_t &demand) noexcept
special_event_queue_t(outliving_reference_t< details::abstract_scenario_t > scenario, outliving_reference_t< event_queue_t > original_queue, queue_mode_t queue_mode)
void push_to_queue(execution_demand_t demand)
void push_evt_finish(execution_demand_t demand) noexcept override
Enqueue a demand for evt_finish event.
queue_mode_t m_mode
The current mode of operation.
std::mutex m_lock
Object lock.
void push_evt_start(execution_demand_t demand) override
Enqueue a demand for evt_start event.
outliving_reference_t< event_queue_t > m_original_queue
Original event_queue.
void switch_to_direct_mode()
void push(execution_demand_t demand) override
Enqueue new event to the queue.
outliving_reference_t< details::abstract_scenario_t > m_scenario
Testing scenario for that this queue was created.
stop_guard_for_unfreezer_t(outliving_reference_t< details::agent_unfreezer_t > unfreezer, outliving_reference_t< environment_t > env)
outliving_reference_t< details::agent_unfreezer_t > m_unfreezer
outliving_reference_t< environment_t > m_env
void stop() noexcept override
Perform stop-related actions.
step_definition_proxy_t define_step(nonempty_name_t step_name)
Start definition of a new scenario's step.
std::string stored_state_name(const std::string &step_name, const std::string &tag) const
Try to get stored name of an agent's state.
std::string stored_msg_inspection_result(const std::string &step_name, const std::string &tag) const
Try to get stored msg inspection result.
outliving_reference_t< details::abstract_scenario_t > m_scenario
bool has_stored_state_name(const std::string &step_name, const std::string &tag) const
Is there the inspection result?
bool has_stored_msg_inspection_result(const std::string &step_name, const std::string &tag) const
Is there the inspection result?
void run_for(std::chrono::steady_clock::duration run_time)
Runs the scenario for specified amount of time.
scenario_proxy_t(outliving_reference_t< details::abstract_scenario_t > scenario)
scenario_result_t result() const
Get the result of scenario execution.
The result of run of testing scenario.
scenario_result_t(scenario_status_t status)
The constructor for a case when there is only status of scenario.
scenario_result_t(scenario_status_t status, std::string description)
A special object that should be used for definition of a step of a testing scenario.
step_definition_proxy_t(details::abstract_scenario_step_t *step)
Initializing constructor.
A special testing environment that should be used for testing of agents.
void stop()
Send stop signal to environment.
environment_t & environment() const
Access to wrapped environment.
testing_env_t()
Default constructor.
testing_env_t(environment_params_t &&env_params)
void wait_init_completion()
scenario_proxy_t scenario() noexcept
Access to the associated scenario.
void join()
Wait for complete finish of environment's work.
wrapped_env_t m_sobjectizer
std::unique_ptr< internals_t > m_internals
void tune_environment_on_start(environment_t &env)
void stop_then_join()
Send stop signal and wait for complete finish of environment's work.
testing_env_t(so_5::generic_simple_so_env_params_tuner_t env_params_tuner)
A constructor that allows to tune environment's parameters.
T * operator->() const noexcept
intrusive_ptr_t(const intrusive_ptr_t &o) noexcept
Copy constructor.
intrusive_ptr_t & operator=(intrusive_ptr_t &&o) noexcept
Move operator.
A base class for agent messages.
friend message_kind_t message_kind(const so_5::intrusive_ptr_t< message_t > &what)
Helper method for quering kind of the message.
A class for the name which cannot be empty.
std::string giveout_value() noexcept(noexcept(std::string{ std::move(m_nonempty_name) }))
Get the value away from the object.
Helper class for indication of long-lived reference via its type.
outliving_reference_t(outliving_reference_t const &o) noexcept
An interface of stop_guard entity.
void stop()
Send stop signal to environment.
void stop_then_join()
Send stop signal and wait for complete finish of environment's work.
wrapped_env_t(so_5::generic_simple_init_t init_func, environment_params_t &¶ms)
void join()
Wait for complete finish of environment's work.
environment_t & environment() const
Access to wrapped environment.
#define SO_5_THROW_EXCEPTION(error_code, desc)
Some reusable and low-level classes/functions which can be used in public header files.
bool wait_for_big_interval(std::unique_lock< std::mutex > &lock, std::condition_variable &cv, std::chrono::steady_clock::duration timeout, Predicate pred)
Helper function for safe call of condition_variable::wait_for with possible big timeouts.
auto invoke_noexcept_code(L lambda) noexcept -> decltype(lambda())
envelope_t & message_to_envelope(const message_ref_t &src_msg)
A helper function for casting message instance to envelope instance.
access_context_t
Information about context on that enveloped message is handled.
incident_status_t
What happened with source of an event.
@ handled
Message or signal has been handled.
@ ignored
Message or signal has been ignored.
environment_params_t make_special_params(outliving_reference_t< testing_env_t::internals_t > internals, environment_params_t &¶ms)
void setup_special_queue_hook(outliving_reference_t< testing_env_t::internals_t > internals, environment_params_t &to)
environment_params_t make_tuned_params(so_5::generic_simple_so_env_params_tuner_t env_params_tuner)
queue_mode_t
A mode of work for special_event_queue.
@ direct
All messages should go to the original queue without buffering.
@ buffer
All messages must be stored locally.
scenario_status_t
Status of testing scenario.
@ completed
Testing scenario is successfuly completed.
Private part of message limit implementation.
const int rc_scenario_must_be_completed
Testing scenario must be completed before an attempt to do the current operation.
const int rc_stored_msg_inspection_result_not_found
There is no stored msg inspection result in the testing scenario.
@ user_type_message
Message is an user type message.
@ enveloped_msg
Message is an envelope with some other message inside.
const int rc_stored_state_name_not_found
There is no stored state name in the testing scenario.
const int rc_unable_to_define_new_step
New step can't be defined if testing scenario is already started or finished.
outliving_reference_t< T > outliving_mutable(T &r)
Make outliving_reference wrapper for mutable reference.
A description of event execution demand.
mbox_id_t m_mbox_id
ID of mbox.
demand_handler_pfn_t m_demand_handler
Demand handler.
agent_t * m_receiver
Receiver of demand.
message_ref_t m_message_ref
Event incident.
std::type_index m_msg_type
Type of the message.
const agent_t * m_agent
Target of an event.
const std::type_index m_msg_type
Type of message or signal.
incident_info_t(const agent_t *agent, const std::type_index &msg_type, mbox_id_t src_mbox_id)
mbox_id_t m_src_mbox_id
ID of mbox from that message/signal was received.
Description of context on that an attempt to activate a trigger is performing.
Description of context on that a trigger is completed.
A helper object for synchronization between helper worker where testing environment is launched and u...
std::promise< void > m_completed
Internal data for testing environment.
impl::init_completed_data_t m_init_completed
impl::special_event_queue_hook_t m_special_hook
details::real_scenario_t m_scenario
static std::unique_ptr< internals_t > make()