2
3
6
7
8
9
10
14#include <so_5/mchain_select_ifaces.hpp>
16#include <so_5/details/at_scope_exit.hpp>
17#include <so_5/details/invoke_noexcept_code.hpp>
18#include <so_5/details/remaining_time_counter.hpp>
19#include <so_5/details/safe_cv_wait_for.hpp>
24#if defined(__clang__
) && (__clang_major__
>= 16
)
25#pragma clang diagnostic push
26#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
49
50
51
52
76 std::size_t extracted,
82 std::size_t closed )
noexcept
110
111
117
118
124
125
131
132
138
139
152
153
154
155
156
157
158
159
161class mchain_select_params_t
final
164 mchain_select_params_t< Msg_Count_Status > >
168 mchain_select_params_t< Msg_Count_Status > >;
178 if constexpr( New_Msg_Count_Status != Msg_Count_Status )
179 return mchain_select_params_t< New_Msg_Count_Status >{
191 typename base_type::data_type data )
192 : base_type{ std::move(data) }
200
201
202
203
204
205
206
207
208
209
210
211
212
227
228
229
230
231
232
233
234
235
291
292
293
294
295
296
297
298
299
312 std::type_index msg_type,
313 message_ref_t message )
360
361
370
371
372
373
374template< std::size_t N >
382
383
384
385 template<
typename... Handlers >
390 Handlers &&... handlers )
419
420
421
422
423
424
425
426
427
428
429
430template<
typename On_Success_Handler >
441 std::type_index msg_type,
442 message_ref_t message,
443 const On_Success_Handler & success_handler )
452 std::type_index msg_type,
453 message_ref_t message,
454 On_Success_Handler && success_handler )
472
473
474
475
476
477
478
479
480template< std::size_t Cases_Count >
484 using array_type_t = std::array< select_case_unique_ptr_t, Cases_Count >;
525
526
528 set_case( std::size_t index, select_case_unique_ptr_t c )
noexcept
540
541
544 using actual_it_t =
typename array_type_t::const_iterator;
549 using difference_type = std::ptrdiff_t;
551 using pointer =
const value_type*;
552 using reference =
const value_type&;
553 using iterator_category = std::forward_iterator_tag;
559 { ++
m_it;
return *
this; }
589template<
typename Holder >
594 select_case_unique_ptr_t c )
599template<
typename Holder,
typename... Cases >
604 select_case_unique_ptr_t c,
605 Cases &&... other_cases )
613
614
615
616
617
618
619
629
630
631
632
633
634
635
636
637
638
639
640template< std::size_t Cases_Count >
651 const mchain_select_params_t<
664 template<
typename... Cases >
666 mchain_select_params_t<
668 Cases && ...cases )
noexcept
672 "Cases_Count and sizeof...(Cases) mismatch" );
678 friend class activation_locker_t;
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
725 "an activate prepared-select "
726 "that is already active" );
731 ~activation_locker_t()
noexcept
740 params()
const noexcept
742 return m_data.get().m_params;
746 cases()
const noexcept
748 return m_data.get().m_cases;
757
758
759
760
761
762
763
764
768 using array_type_t = std::vector< select_case_unique_ptr_t >;
794 std::size_t initial_capacity )
796 if( 0u != initial_capacity )
797 m_cases.reserve( initial_capacity );
817
818
822 m_cases.push_back( std::move(c) );
831
832
835 using actual_it_t =
typename array_type_t::const_iterator;
840 using difference_type = std::ptrdiff_t;
842 using pointer =
const value_type*;
843 using reference =
const value_type&;
844 using iterator_category = std::forward_iterator_tag;
850 { ++
m_it;
return *
this; }
862 {
return m_it->get(); }
879template<
typename... Cases >
883 select_case_unique_ptr_t c,
884 Cases &&... other_cases )
894
895
896
897
898
899
900
910
911
912
913
914
915
916
917
918
919
920
921
932 const mchain_select_params_t<
946 mchain_select_params_t<
953 friend class modification_locker_t;
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
987 modification_locker_t(
995 "an attempt to modify extensible-select "
996 "that is already active" );
1001 cases()
const noexcept
1007 friend class activation_locker_t;
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1044 activation_locker_t(
1054 "an activate extensible-select "
1055 "that is already active" );
1060 ~activation_locker_t()
noexcept
1069 params()
const noexcept
1075 cases()
const noexcept
1082#if defined(__clang__
)
1083#pragma clang diagnostic push
1084#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
1091
1092
1093
1094
1105
1106
1116
1117
1118
1119
1120
1121
1122
1123 template<
typename Fwd_it >
1141 std::lock_guard< std::mutex > lock{
m_lock };
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1165 std::lock_guard< std::mutex > lock{
m_lock };
1170
1171
1172
1173
1174
1175
1176
1181 duration_t wait_time )
1183 std::unique_lock< std::mutex > lock{
m_lock };
1189 [
this]{
return m_tail !=
nullptr; }
);
1198#if defined(__clang__
)
1199#pragma clang diagnostic pop
1206
1207
1208
1209
1210
1211
1212template<
typename Holder >
1226
1227
1228
1229
1230
1231
1232
1243 const Holder & select_cases )
1251 c.on_select_finish();
1285 friend struct select_result_handler_t;
1286 struct select_result_handler_t
final
1305 auto * current = ready_chain;
1309 select_result_handler_t{
this, current },
1380 [&handler, current] {
1414template<
typename Holder >
1418 const Holder & select_cases )
1430 const duration_t this_iteration_wait_time = std::min(
1434 performer.handle_next( this_iteration_wait_time );
1436 performer.last_extraction_status() )
1439 wait_incoming_time =
1448 while( total_time_counter
1449 && wait_incoming_time
1450 && performer.can_continue() );
1452 return performer.make_result();
1455template<
typename Holder >
1459 const Holder & select_cases )
1470 performer.last_extraction_status() )
1486 while( wait_time && performer.can_continue() );
1488 return performer.make_result();
1495
1496
1497
1498
1499template<
typename Cases_Holder >
1505 const Cases_Holder & cases_holder )
1508 return do_adv_select_without_total_time( params, cases_holder );
1510 return do_adv_select_with_total_time( params, cases_holder );
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531template<
typename... Handlers >
1538 Handlers &&... handlers )
1553
1554
1555
1556
1557
1558
1559
1563 typename On_Success_Handler >
1571 On_Success_Handler && handler )
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1693 const mchain_select_params_t< Msg_Count_Status > & params,
1699 "message count to be processed/extracted should be defined "
1700 "by using handle_all()/handle_n()/extract_n() methods" );
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739template< std::size_t Cases_Count >
1747 mchain_select_params_t< Msg_Count_Status > params,
1748 Cases &&... cases );
1752
1753
1754
1755
1756
1757
1764
1765
1766
1767 template<
typename... Cases >
1769 mchain_select_params_t<
1809
1810
1815
1816
1817
1821
1822
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1890 mchain_select_params_t< Msg_Count_Status > params,
1896 "message count to be processed/extracted should be defined "
1897 "by using handle_all()/handle_n()/extract_n() methods" );
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936template< std::size_t Cases_Count >
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1982 mchain_select_params_t< Msg_Count_Status > params,
1983 Cases &&... cases );
1991 :
m_data{ std::move(data) }
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2053
2054
2055
2059
2060
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2114 mchain_select_params_t< Msg_Count_Status > params,
2120 "message count to be processed/extracted should be defined "
2121 "by using handle_all()/handle_n()/extract_n() methods" );
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161template<
typename... Cases >
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2223#if defined(__clang__
) && (__clang_major__
>= 16
)
2224#pragma clang diagnostic pop
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 state_t & so_current_state() const
Access to the current agent state.
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
It's a kind of strong typedef for coop's deregistration reason.
Type of smart handle for a cooperation.
Template class for storing bunch of message handlers.
Helper class for calculating remaining time.
duration remaining() const
remaining_time_counter_t(duration remaining)
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
trigger_t * m_trigger
Activated trigger.
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
abstract_scenario_step_t & operator=(const abstract_scenario_step_t &)=delete
virtual ~abstract_scenario_step_t()=default
virtual void add_preactivate_action(preactivate_action_t action)=0
Add another preactivation action.
virtual void setup_triggers(trigger_container_t triggers, std::size_t triggers_to_activate) noexcept=0
Setup triggers for the step.
abstract_scenario_step_t(abstract_scenario_step_t &&)=delete
virtual void setup_constraints(constraint_container_t constraints) noexcept=0
Setup constraints for the step.
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.
abstract_scenario_step_t & operator=(abstract_scenario_step_t &&)=delete
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.
abstract_scenario_step_t(const abstract_scenario_step_t &)=delete
virtual status_t status() const noexcept=0
Get the current status of the step.
abstract_scenario_step_t()=default
abstract_scenario_step_t & activated_step() const noexcept
abstract_scenario_step_t::token_t m_step_token
abstract_scenario_step_t::token_t step_token() const noexcept
abstract_scenario_step_t * m_activated_step
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.
virtual 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)=0
Store msg inspection result in the scenario.
scenario_in_progress_accessor_t make_accessor() noexcept
Helper method for creation of scenario_in_progress_accessor instance.
abstract_scenario_t(abstract_scenario_t &&)=delete
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.
abstract_scenario_t()=default
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 ~abstract_scenario_t()=default
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
abstract_scenario_t & operator=(const abstract_scenario_t &)=delete
virtual 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)=0
Store a name of an agent state in the scenario.
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.
abstract_scenario_t & operator=(abstract_scenario_t &&)=delete
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.
abstract_scenario_t(const abstract_scenario_t &)=delete
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
An interface of step's constraints.
constraint_t & operator=(constraint_t &&)=delete
virtual void start() noexcept=0
Hook for step preactivation.
constraint_t & operator=(const constraint_t &)=delete
virtual ~constraint_t() noexcept=default
constraint_t(constraint_t &&)=delete
constraint_t(const constraint_t &)=delete
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.
const mbox_t m_from
Source for a message.
void so_define_agent() override
Hook on define agent for SObjectizer.
void evt_msg_arrived(mhood_t< Msg >)
a_msg_catcher_t(context_t ctx, mbox_t from)
std::mutex m_lock
The lock for thread safety.
msg_catcher_map_layer_t()
~msg_catcher_map_layer_t() noexcept override
agents_map_t m_agents
The map of already created catcher agents.
const agent_t * register_new_catcher(const so_5::mbox_t &from) const
Helper for registration of a new agent.
catcher_info_t catcher_for_mbox(const so_5::mbox_t &from)
void start() noexcept override
Hook for step preactivation.
const std::chrono::steady_clock::duration m_pause
Value to be used.
void finish() noexcept override
Hook for step completion.
std::chrono::steady_clock::time_point m_started_at
Time point of step preactivation.
bool check(const incident_status_t, const incident_info_t &) const noexcept override
Check for fulfillment of constraint.
not_after_constraint_t(std::chrono::steady_clock::duration pause)
void start() noexcept override
Hook for step preactivation.
std::chrono::steady_clock::time_point m_started_at
Time point of step preactivation.
const std::chrono::steady_clock::duration m_pause
Value to be used.
void finish() noexcept override
Hook for step completion.
bool check(const incident_status_t, const incident_info_t &) const noexcept override
Check for fulfillment of constraint.
not_before_constraint_t(std::chrono::steady_clock::duration pause)
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.
scenario_in_progress_accessor_t & operator=(scenario_in_progress_accessor_t &&)=delete
scenario_in_progress_accessor_t(outliving_reference_t< abstract_scenario_t > scenario)
scenario_in_progress_accessor_t(scenario_in_progress_accessor_t &&)=delete
abstract_scenario_t & scenario() const noexcept
scenario_in_progress_accessor_t & operator=(const scenario_in_progress_accessor_t &)=delete
scenario_in_progress_accessor_t(const scenario_in_progress_accessor_t &)=delete
outliving_reference_t< abstract_scenario_t > m_scenario
trigger_holder_t(const trigger_holder_t &)=delete
trigger_holder_t & operator=(trigger_holder_t &&) noexcept=default
trigger_holder_t & operator=(const trigger_holder_t &)=delete
trigger_holder_t(trigger_holder_t &&) noexcept=default
trigger_holder_t(trigger_unique_ptr_t trigger) noexcept
trigger_unique_ptr_t m_trigger
trigger_unique_ptr_t giveout_trigger() noexcept
Get the trigger object from the holder.
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.
trigger_t(trigger_t &&)=delete
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.
trigger_t(const trigger_t &)=delete
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)
scenario_status_t m_status
optional< std::string > m_description
bool operator!=(const scenario_result_t &o) const noexcept
Check for inequality.
bool operator==(const scenario_result_t &o) const noexcept
Check for equality.
A special object that should be used for definition of a step of a testing scenario.
details::abstract_scenario_step_t * m_step
step_definition_proxy_t(details::abstract_scenario_step_t *step)
Initializing constructor.
step_definition_proxy_t & impact(Lambda &&lambda)
Add preactivation action in form of lambda-object.
step_definition_proxy_t & when_all(details::trigger_holder_t< Status > event, Args &&...args)
Add a list of tiggers for activation of that step.
void append_constraint_to(details::constraint_container_t &)
void append_trigger_to(details::trigger_container_t &to, details::trigger_holder_t< Status > event, Args &&...args)
void append_constraint_to(details::constraint_container_t &to, details::constraint_unique_ptr_t head, Args &&...tail)
step_definition_proxy_t & impact(Target &&target, Args &&...args)
Define a preactivation action in form of sending a message/signal to the specified target.
void append_trigger_to(details::trigger_container_t &)
step_definition_proxy_t & constraints(details::constraint_unique_ptr_t head, Args &&...tail)
Add a list of constraints for that step.
step_definition_proxy_t & when_any(details::trigger_holder_t< Status > event, Args &&...args)
Add a list of tiggers for activation of that step.
step_definition_proxy_t & when(details::trigger_holder_t< Status > event)
Add a tigger for activation of that step.
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.
Special container for holding select parameters and select cases.
extensible_select_t & operator=(extensible_select_t &&other) noexcept
Move operator.
extensible_select_t()=default
Default constructor.
extensible_select_t(extensible_select_t &&other) noexcept
Move constructor.
friend void swap(extensible_select_t &a, extensible_select_t &b) noexcept
Swap operation.
bool empty() const noexcept
Is this handle empty?
std::unique_ptr< mchain_props::details::extensible_select_data_t > m_data
Actual data for that extensible-select.
auto & data() const noexcept
extensible_select_t & operator=(const extensible_select_t &)=delete
extensible_select_t(const extensible_select_t &)=delete
extensible_select_t(std::unique_ptr< mchain_props::details::extensible_select_data_t > data)
Actual initializing constructor.
friend extensible_select_t make_extensible_select(mchain_select_params_t< Msg_Count_Status > params, Cases &&... cases)
Creation of extensible-select instance.
intrusive_ptr_t(intrusive_ptr_t &&o) noexcept
Move constructor.
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.
An interface of the additional SObjectizer Environment layer.
Basic parameters for advanced receive from mchain and for multi chain select.
Actual implementation of one multi chain select case.
actual_receive_select_case_t(mchain_t chain, Handlers &&... handlers)
Initializing constructor.
so_5::details::handlers_bunch_t< N > m_handlers
mchain_receive_result_t try_handle_extracted_message(demand_t &demand) override
Attempt to handle extracted message.
Actual implementation of notificator for multi chain select.
select_case_t * m_tail
Queue of already notified select_cases.
actual_select_notificator_t(Fwd_it b, Fwd_it e)
Initializing constructor.
void push_to_notified_chain(select_case_t &what) noexcept
select_case_t * wait(duration_t wait_time)
Wait for any notified select_case.
std::condition_variable m_condition
void return_to_ready_chain(select_case_t &what) noexcept
Return specifed select_case object to the chain of 'notified select_cases'.
void notify(select_case_t &what) noexcept override
The actual implementation of select_case for the case of sending a message.
void on_successful_push() override
Hook for handling successful push attempt.
actual_send_select_case_t(mchain_t chain, std::type_index msg_type, message_ref_t message, const On_Success_Handler &success_handler)
Initializing constructor for the case when success_handler is a const lvalue.
On_Success_Handler m_success_handler
Actual handler of successful send attempt.
actual_send_select_case_t(mchain_t chain, std::type_index msg_type, message_ref_t message, On_Success_Handler &&success_handler)
Initializing constructor for the case when success_handler is a rvalue.
Iterator class for accessing select_cases.
bool operator!=(const const_iterator &o) const noexcept
const_iterator & operator++() noexcept
select_case_t & operator*() const noexcept
bool operator==(const const_iterator &o) const noexcept
select_case_t * operator->() const noexcept
const_iterator(actual_it_t it) noexcept
const_iterator operator++(int) noexcept
A holder for serie of select_cases for the case of extensible select.
array_type_t m_cases
Storage for select_cases.
extensible_select_cases_holder_t(const extensible_select_cases_holder_t &)=delete
extensible_select_cases_holder_t & operator=(extensible_select_cases_holder_t &&o) noexcept
Move operator.
extensible_select_cases_holder_t & operator=(const extensible_select_cases_holder_t &)=delete
extensible_select_cases_holder_t(extensible_select_cases_holder_t &&o) noexcept
Move constructor.
extensible_select_cases_holder_t()
Default constructor.
friend void swap(extensible_select_cases_holder_t &a, extensible_select_cases_holder_t &b) noexcept
Swap operation.
extensible_select_cases_holder_t(std::size_t initial_capacity)
Constructor with initial capacity.
const_iterator end() const noexcept
Get iterator for the item just behind the last item in select_cases_holder.
std::size_t size() const noexcept
Get count of select_cases in holder.
const_iterator begin() const noexcept
Get iterator for the first item in select_cases_holder.
void add_case(select_case_unique_ptr_t c)
Helper method for setting up specific select_case.
Special class for locking extensible-select instance for activation inside select() call.
activation_locker_t(activation_locker_t &&)=delete
activation_locker_t(const activation_locker_t &)=delete
outliving_reference_t< extensible_select_data_t > m_data
Special class for locking extensible-select instance for modification.
outliving_reference_t< extensible_select_data_t > m_data
modification_locker_t(modification_locker_t &&)=delete
modification_locker_t(const modification_locker_t &)=delete
std::lock_guard< std::mutex > m_lock
A data for extensible-select instance.
std::mutex m_lock
The object's lock.
const mchain_select_params_t< mchain_props::msg_count_status_t::defined > m_params
Parameters for select.
extensible_select_status_t m_status
The current status of extensible-select object.
extensible_select_cases_holder_t m_cases
A list of cases for extensible-select operation.
extensible_select_data_t(const extensible_select_data_t &)=delete
extensible_select_data_t(extensible_select_data_t &&)=delete
extensible_select_data_t(mchain_select_params_t< msg_count_status_t::defined > &¶ms, extensible_select_cases_holder_t &&cases) noexcept
Initializing constructor.
std::size_t to_handle() const noexcept
Get limit for count of message to be handled.
const mchain_props::duration_t & total_time() const noexcept
Get total time for the whole receive operation.
const stop_predicate_t & stop_on() const noexcept
Get user condition for stopping receive operation.
std::size_t to_extract() const noexcept
Get limit for count of messages to be extracted.
const chain_closed_handler_t & closed_handler() const noexcept
Get handler for chain-closed event.
const mchain_props::duration_t & empty_timeout() const noexcept
Get timeout for waiting on empty chain.
Special class for locking prepared-select instance for activation inside select() call.
activation_locker_t(activation_locker_t &&)=delete
outliving_reference_t< prepared_select_data_t > m_data
activation_locker_t(const activation_locker_t &)=delete
A data for prepared-select instance.
prepared_select_data_t(mchain_select_params_t< msg_count_status_t::defined > &¶ms, Cases &&...cases) noexcept
Initializing constructor.
prepared_select_data_t(prepared_select_data_t &&)=delete
select_cases_holder_t< Cases_Count > m_cases
A list of cases for extensible-select operation.
std::mutex m_lock
The object's lock.
prepared_select_data_t(const prepared_select_data_t &)=delete
prepared_select_status_t m_status
The current status of extensible-select object.
const mchain_select_params_t< mchain_props::msg_count_status_t::defined > m_params
Parameters for select.
A base class for implementations of select_case for the case of receiving messages.
virtual mchain_receive_result_t try_handle_extracted_message(demand_t &demand)=0
Attempt to handle extracted message.
handling_result_t try_handle(select_notificator_t ¬ificator) override
An attempt to handle this case.
Iterator class for accessing select_cases.
select_case_t & operator*() const noexcept
bool operator!=(const const_iterator &o) const noexcept
const_iterator(actual_it_t it) noexcept
select_case_t * operator->() const noexcept
bool operator==(const const_iterator &o) const noexcept
const_iterator & operator++() noexcept
const_iterator operator++(int) noexcept
A holder for serie of select_cases.
select_cases_holder_t & operator=(select_cases_holder_t &&o) noexcept
Move operator.
void set_case(std::size_t index, select_case_unique_ptr_t c) noexcept
Helper method for setting up specific select_case.
const_iterator end() const noexcept
Get iterator for the item just behind the last item in select_cases_holder.
select_cases_holder_t(const select_cases_holder_t &)=delete
select_cases_holder_t()
Default constructor.
friend void swap(select_cases_holder_t &a, select_cases_holder_t &b) noexcept
Swap operation.
const_iterator begin() const noexcept
Get iterator for the first item in select_cases_holder.
select_cases_holder_t(select_cases_holder_t &&o) noexcept
Move constructor.
array_type_t m_cases
Storage for select_cases.
select_cases_holder_t & operator=(const select_cases_holder_t &)=delete
std::size_t size() const noexcept
Get count of select_cases in holder.
A base class for implementations of select_case for the case of sending messages.
std::type_index m_msg_type
Type of message to be sent.
virtual void on_successful_push()=0
Hook for handling successful push attempt.
send_select_case_t(mchain_t chain, std::type_index msg_type, message_ref_t message)
Initializing constructor.
message_ref_t m_message
Message to be sent.
handling_result_t try_handle(select_notificator_t ¬ificator) override
An attempt to handle this case.
Base class for representation of one case in multi chain select.
const mchain_t & chain() const noexcept
Get the underlying mchain.
auto push(const std::type_index &msg_type, const message_ref_t &message)
Helper method for calling push method of the target mchain.
auto extract(demand_t &demand)
Helper method for calling extract method of the target mchain.
void set_next(select_case_t *next) noexcept
Set the next item in the current queue to which select_case belongs.
select_case_t(mchain_t chain)
Initialized constructor.
select_case_t * giveout_next() noexcept
virtual handling_result_t try_handle(select_notificator_t ¬ificator)=0
An attempt to handle this case.
select_notificator_t * m_notificator
Notificator to be used for notify sleeping thread.
An interface of select_case notificator.
A result of receive from mchain.
std::size_t extracted() const noexcept
Count of extracted messages.
mchain_props::extraction_status_t status() const noexcept
Extraction status (e.g. no messages, chain closed and so on).
std::size_t handled() const noexcept
Count of handled messages.
mchain_receive_result_t(std::size_t extracted, std::size_t handled, mchain_props::extraction_status_t status) noexcept
Initializing constructor.
mchain_select_params_t(typename base_type::data_type data)
Initializing constructor for the case of cloning.
mchain_select_params_t()=default
The default constructor.
decltype(auto) so5_clone_if_necessary() noexcept
A result of select from several mchains.
std::size_t m_closed
Count of closed chains.
std::size_t m_handled
Count of handled incoming messages.
std::size_t handled() const noexcept
Count of handled incoming messages.
bool was_extracted() const noexcept
mchain_select_result_t(std::size_t extracted, std::size_t handled, std::size_t sent, std::size_t closed) noexcept
Initializing constructor.
mchain_select_result_t() noexcept
Default constructor.
std::size_t m_sent
Count of messages sent.
bool was_sent_or_received() const noexcept
std::size_t closed() const noexcept
Count of closed chains.
std::size_t sent() const noexcept
Count of messages sent.
bool was_closed() const noexcept
std::size_t m_extracted
Count of extracted incoming messages.
std::size_t extracted() const noexcept
Count of extracted incoming messages.
bool was_sent() const noexcept
bool was_handled() const noexcept
A result of attempt of sending messages to a message chain.
mchain_props::push_status_t status() const noexcept
Status of send operation.
mchain_send_result_t(std::size_t sent, mchain_props::push_status_t status)
Initializing constructor.
std::size_t sent() const noexcept
Count of messages sent.
A class for holding an instance of a message.
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
Special container for holding select parameters and select cases.
auto & data() const noexcept
friend prepared_select_t< sizeof...(Cases) > prepare_select(mchain_select_params_t< Msg_Count_Status > params, Cases &&... cases)
Create prepared select statement to be used later.
prepared_select_t & operator=(prepared_select_t &&other) noexcept
Move operator.
prepared_select_t(prepared_select_t &&other) noexcept
Move constructor.
prepared_select_t & operator=(const prepared_select_t &)=delete
std::unique_ptr< mchain_props::details::prepared_select_data_t< Cases_Count > > m_data
The actual prepared-select object.
prepared_select_t(mchain_select_params_t< mchain_props::msg_count_status_t::defined > params, Cases &&... cases)
Initializing constructor.
prepared_select_t(const prepared_select_t &)=delete
bool empty() const noexcept
Is this handle empty?
friend void swap(prepared_select_t &a, prepared_select_t &b) noexcept
Swap operation.
std::string query_name() const
Get textual name of the state.
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.
trigger_holder_t< incident_status_t::handled > operator&(trigger_holder_t< incident_status_t::handled > &&old_holder, wait_event_handler_completion_t)
A helper operator to create a tigger that requires the completion of an event handler.
trigger_holder_t< Status > operator&(trigger_holder_t< Status > &&old_holder, store_msg_inspection_result_t inspection_info)
A helper operator to create a tigger that inspects the incoming message and stores the result into th...
trigger_holder_t< incident_status_t::handled > operator&(const mbox_t &from, receives_indicator_t< Msg >)
A helper operator to create a tigger that receives a message/signal from specified mbox.
trigger_holder_t< Status > operator&(const so_5::agent_t &agent, const trigger_source_t< Status > &src)
A helper operator to create a trigger for the specified agent.
incident_status_t
What happened with source of an event.
@ handled
Message or signal has been handled.
@ ignored
Message or signal has been ignored.
trigger_holder_t< incident_status_t::handled > operator&(trigger_holder_t< incident_status_t::handled > &&old_holder, store_agent_state_name_t data_to_store)
A helper operator to create a tigger that stores the name of the current agent's state.
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_result_t completed()
Create a value that means that scenario completed successfuly.
details::receives_indicator_t< Msg > receives()
Helper function to be used for a trigger that receives a message/singal from a mbox.
details::trigger_source_t< details::incident_status_t::ignored > ignores()
Define a trigger that activates when an agent rejects a message from the direct mbox.
scenario_status_t
Status of testing scenario.
@ completed
Testing scenario is successfuly completed.
details::constraint_unique_ptr_t not_after(std::chrono::steady_clock::duration pause)
Create a constraint not-after.
details::store_msg_inspection_result_t inspect_msg(std::string tag, Lambda &&inspector)
Create a special marker for a trigger for inspecting an incoming message and storing the inspection r...
details::store_agent_state_name_t store_state_name(std::string tag)
Create a special marker for a trigger for storing agent's state name inside scenario.
details::trigger_source_t< details::incident_status_t::handled > reacts_to()
Define a trigger that activates when an agent receives and handles a message from the direct mbox.
details::trigger_source_t< details::incident_status_t::handled > reacts_to(const so_5::mbox_t &mbox)
Define a trigger that activates when an agent receives and handles a message from the specific mbox.
details::constraint_unique_ptr_t not_before(std::chrono::steady_clock::duration pause)
Create a constraint not-before.
details::trigger_source_t< details::incident_status_t::ignored > ignores(const so_5::mbox_t &mbox)
Define a trigger that activates when an agent rejects a message from the direct mbox.
details::wait_event_handler_completion_t wait_event_handler_completion()
Create a special marker for a trigger that requires waiting for completion of an event handler.
bool is_infinite_wait_timevalue(duration_t v)
Is time value means 'infinite_wait'?
void fill_select_cases_holder(extensible_select_cases_holder_t &holder, select_case_unique_ptr_t c, Cases &&... other_cases)
mchain_select_result_t perform_select(const mchain_select_params_t< msg_count_status_t::defined > ¶ms, const Cases_Holder &cases_holder)
Helper function with implementation of main select action.
prepared_select_status_t
The current status of prepared-select instance.
@ passive
Prepared-select instance is not used in select() call.
@ active
Prepared-select instance is used in select() call now.
void fill_select_cases_holder(Holder &holder, std::size_t index, select_case_unique_ptr_t c, Cases &&... other_cases)
mchain_select_result_t do_adv_select_without_total_time(const mchain_select_params_t< msg_count_status_t::defined > ¶ms, const Holder &select_cases)
extensible_select_status_t
The current status of extensible-select instance.
@ passive
Extensible-select instance is not used in select() call.
@ active
Extensible-select instance is used in select() call now.
void fill_select_cases_holder(Holder &holder, std::size_t index, select_case_unique_ptr_t c)
mchain_select_result_t do_adv_select_with_total_time(const mchain_select_params_t< msg_count_status_t::defined > ¶ms, const Holder &select_cases)
void fill_select_cases_holder(extensible_select_cases_holder_t &)
Various properties and parameters of message chains.
msg_count_status_t
Status of limit for messages to be extracted/handled during a bulk operation on a mchain.
@ undefined
Message count limit is not set yet.
@ defined
Message count limit is set.
extraction_status_t
Result of extraction of message from a message chain.
@ msg_extracted
Message extracted successfully.
@ chain_closed
Message cannot be extracted because chain is closed.
@ no_messages
No available messages in the chain.
push_status_t
Result of attempt of pushing a message into a message chain.
@ not_stored
Message wasn't stored.
@ stored
Message stored into a message chain.
@ chain_closed
Message wasn't stored because chain is closed.
Private part of message limit implementation.
auto make_coop_reg_notificator(mbox_t target) noexcept
Create notificator about cooperation registration completion.
const int rc_scenario_must_be_completed
Testing scenario must be completed before an attempt to do the current operation.
const int rc_extensible_select_is_active_now
An attempt to modify or activate extensible-select when an operation on that extensible-select object...
void add_select_cases(extensible_select_t &extensible_select, Cases &&... cases)
Add a portion of cases to extensible-select instance.
mchain_select_params_t< mchain_props::msg_count_status_t::undefined > from_all()
Helper function for creation of mchain_select_params instance with default values.
mchain_select_result_t select(const mchain_select_params_t< Msg_Count_Status > ¶ms, Cases &&... cases)
An advanced form of multi chain select.
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.
mchain_select_result_t select(const extensible_select_t &extensible_select)
A select operation to be done on previously prepared extensible-select object.
const int rc_stored_state_name_not_found
There is no stored state name in the testing scenario.
void send(Target &&to, Args &&... args)
A utility function for creating and delivering a message or a signal.
const int rc_unable_to_define_new_step
New step can't be defined if testing scenario is already started or finished.
message_ownership_t
Type of ownership of a message instance inside message_holder.
mchain_props::select_case_unique_ptr_t receive_case(mchain_t chain, Handlers &&... handlers)
A helper for creation of select_case object for one multi chain select.
mchain_props::select_case_unique_ptr_t send_case(mchain_t chain, message_holder_t< Msg, Ownership > msg, On_Success_Handler &&handler)
A helper for creation of select_case object for one send-case of a multi chain select.
mchain_select_result_t select(const prepared_select_t< Cases_Count > &prepared)
A select operation to be done on previously prepared select params.
auto make_coop_dereg_notificator(mbox_t target) noexcept
Create notificator about cooperation deregistration completion.
outliving_reference_t< T > outliving_mutable(T &r)
Make outliving_reference wrapper for mutable reference.
prepared_select_t< sizeof...(Cases) > prepare_select(mchain_select_params_t< Msg_Count_Status > params, Cases &&... cases)
Create prepared select statement to be used later.
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.
catcher_info_t(const agent_t *target_agent)
Initializing constructor.
const agent_t * m_target_agent
Pointer to the agent.
Special indicator to be used in implementation of receives trigger.
A special data object for case of store-state-name completion action.
std::string m_tag
Name of tag for store-state-name action.
A special data object for case when a message inspector has to be used on an incoming message.
std::function< std::string(const message_ref_t &) > m_inspector
Inspector for a message.
std::string m_tag
Name of a tag for store-msg-inspection action.
Description of context on that an attempt to activate a trigger is performing.
const scenario_in_progress_accessor_t & m_scenario_accessor
Access to the running scenario.
abstract_scenario_step_t & m_step
The current step for that activation is being performed.
const message_ref_t & m_incoming_msg
Incoming message or signal.
Description of context on that a trigger is completed.
abstract_scenario_step_t & m_step
const scenario_in_progress_accessor_t & m_scenario_accessor
std::type_index m_msg_type
trigger_source_t(std::type_index msg_type)
optional< mbox_id_t > m_src_mbox_id
trigger_source_t(std::type_index msg_type, mbox_id_t src_mbox_id)
A special data object for case when a step should be completed only after returning from the event ha...
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()
Description of one demand in message chain.
A helper class for detection of payload type of message.
Message about cooperation deregistration completion.
msg_coop_deregistered(coop_handle_t coop, coop_dereg_reason_t reason) noexcept
msg_coop_deregistered & operator=(const msg_coop_deregistered &)=delete
msg_coop_deregistered(const msg_coop_deregistered &)=delete
msg_coop_deregistered & operator=(msg_coop_deregistered &&)=delete
msg_coop_deregistered(msg_coop_deregistered &&)=delete
const coop_handle_t m_coop
const coop_dereg_reason_t m_reason
Message about cooperation registration completion.
msg_coop_registered & operator=(msg_coop_registered &&)=delete
msg_coop_registered(const msg_coop_registered &)=delete
msg_coop_registered(coop_handle_t coop) noexcept
const coop_handle_t m_coop
msg_coop_registered & operator=(const msg_coop_registered &)=delete
msg_coop_registered(msg_coop_registered &&)=delete