SObjectizer  5.8
Loading...
Searching...
No Matches
bind_transformer_helpers.hpp
Go to the documentation of this file.
1/*
2 * SObjectizer-5
3 */
4
5/*!
6 * \file
7 * \brief Helpers to simplify usage of transform_then_redirect_sink.
8 *
9 * \since v.5.8.1
10 */
11
12#pragma once
13
14#include <so_5/msinks/transform_then_redirect.hpp>
15
16#include <so_5/single_sink_binding.hpp>
17#include <so_5/multi_sink_binding.hpp>
18
19namespace so_5
20{
21
23{
24
25} /* namespace bind_then_redirect_impl */
26
27/*!
28 * \brief Helper function to add transform_then_redirect msink to a binding
29 * object.
30 *
31 * Type of source message is automatically deduced from the type of
32 * \a transformer argument.
33 *
34 * Usage example:
35 * \code
36 * struct part { ... };
37 * struct compound {
38 * part m_first;
39 * part m_second;
40 * };
41 *
42 * ...
43 * so_5::mbox_t src_mbox = ...;
44 * so_5::mbox_t dest_mbox = ...;
45 *
46 * so_5::single_sink_binding_t binding;
47 * so_5::bind_transformer(binding, src_mbox,
48 * [dest_mbox](const compound & msg) {
49 * return so_5::make_transformed<part>(
50 * dest_mbox, // Destination for the transformed message.
51 * msg.m_first // Initializer for the new `part` instance.
52 * );
53 * });
54 * \endcode
55 *
56 * The \a transformer is expected to return a so_5::transformed_message_t
57 * or std::optional<so_5::transformed_message_t>:
58 * \code
59 * so_5::bind_transformer(binding, src_mbox,
60 * [dest_mbox](const compound & msg)
61 * -> std::optional<so_5::transformed_message_t<part>>
62 * {
63 * if(should_message_be_transformed(msg)) {
64 * return {
65 * so_5::make_transformed<part>(
66 * dest_mbox, // Destination for the transformed message.
67 * msg.m_first // Initializer for the new `part` instance.
68 * ) };
69 * }
70 * else
71 * return std::nullopt; // No transformation.
72 * });
73 * \endcode
74 *
75 * \note
76 * Because the type of the source message is deduced from \a transformer
77 * argument this helper can't be used for transforming mutable messages
78 * and signals.
79 *
80 * \attention
81 * The \a transformer can't have an argument in the form of `const auto &`:
82 * \code
83 * // Compilation error is expected here because the type of
84 * // the transformer argument can't be deduced.
85 * so_5::bind_transformer(binding, src, [](const auto & msg) {...});
86 * \endcode
87 *
88 * \tparam Binding type of binding object. It's expected to be
89 * so_5::single_sink_binding_t, so_5::multi_sink_binding_t or a similar
90 * type with the same interface.
91 *
92 * \tparam Transformer type of transformer functor (a lambda or free function).
93 *
94 * \since v.5.8.1
95 */
96template< typename Binding, typename Transformer >
97void
99 //! Binding object to be used.
100 Binding & binding,
101 //! Source mbox. It must not be nullptr.
102 const so_5::mbox_t & src_mbox,
103 //! Transformer that produced so_5::transformed_message_t instance or
104 //! std::optional<so_5::transformed_message_t> instance.
105 Transformer && transformer )
106 {
108 using lambda_traits_t =
110 using transformer_arg_t =
112
113 binding.template bind< transformer_arg_t >(
114 src_mbox,
118 }
119
120/*!
121 * \brief Helper function to add transform_then_redirect msink to a binding
122 * object (with a delivery filter).
123 *
124 * Type of source message is automatically deduced from the type of
125 * \a transformer argument.
126 *
127 * The \a filter is called first and only if it return `true` the
128 * \a transformed is called for message transformation.
129 *
130 * Usage example:
131 * \code
132 * struct part { ... };
133 * struct compound {
134 * part m_first;
135 * part m_second;
136 * };
137 *
138 * ...
139 * so_5::mbox_t src_mbox = ...;
140 * so_5::mbox_t dest_mbox = ...;
141 *
142 * so_5::single_sink_binding_t binding;
143 * so_5::bind_transformer(binding, src_mbox,
144 * [dest_mbox](const compound & msg) {
145 * return so_5::make_transformed<part>(
146 * dest_mbox, // Destination for the transformed message.
147 * msg.m_first // Initializer for the new `part` instance.
148 * );
149 * },
150 * [](const compound & msg) { // or [](const auto & msg) {...}
151 * return ...; // Some predicate.
152 * });
153 * \endcode
154 *
155 * The \a transformer is expected to return a so_5::transformed_message_t
156 * or std::optional<so_5::transformed_message_t>.
157 *
158 * \note
159 * Because the type of the source message is deduced from \a transformer
160 * argument this helper can't be used for transforming mutable messages
161 * and signals.
162 *
163 * \attention
164 * The \a transformer can't have an argument in the form of `const auto &`:
165 * \code
166 * // Compilation error is expected here because the type of
167 * // the transformer argument can't be deduced.
168 * so_5::bind_transformer(binding, src,
169 * // This would lead to compilation error.
170 * [](const auto & msg) {...},
171 * // `const auto &` can be used for a delivery filter.
172 * [](const auto & msg) {...});
173 * \endcode
174 *
175 * \tparam Binding type of binding object. It's expected to be
176 * so_5::single_sink_binding_t, so_5::multi_sink_binding_t or a similar
177 * type with the same interface.
178 *
179 * \tparam Transformer type of transformer functor (a lambda or free function).
180 *
181 * \tparam Delivery_Filter type of delivery filter functor (a lambda or free
182 * function).
183 *
184 * \since v.5.8.1
185 */
186template< typename Binding, typename Transformer, typename Delivery_Filter >
187void
189 //! Binding object to be used.
190 Binding & binding,
191 //! Source mbox. It must not be nullptr.
192 const so_5::mbox_t & src_mbox,
193 //! Transformer that produced so_5::transformed_message_t instance or
194 //! std::optional<so_5::transformed_message_t> instance.
195 Transformer && transformer,
196 //! Delivery filter for the source message.
197 Delivery_Filter && filter )
198 {
200 using lambda_traits_t =
202 using transformer_arg_t =
204
205 binding.template bind< transformer_arg_t >(
206 src_mbox,
211 }
212
213/*!
214 * \brief Helper function to add transform_then_redirect msink to a binding
215 * object.
216 *
217 * The type of the source message is specified explicitly.
218 *
219 * \attention
220 * Because the source message is specified explicitly, this helper
221 * can be used for immutable, mutable messages, and signals.
222 *
223 * Usage example:
224 * \code
225 * struct part { ... };
226 * struct compound {
227 * part m_first;
228 * part m_second;
229 * };
230 *
231 * ...
232 * so_5::mbox_t src_mbox = ...;
233 * so_5::mbox_t dest_mbox = ...;
234 *
235 * so_5::single_sink_binding_t binding;
236 * so_5::bind_transformer< so_5::mutable_msg<compound> >(binding, src_mbox,
237 * [dest_mbox](compound & msg) { // or [dest_mbox](auto & msg)
238 * return so_5::make_transformed<part>(
239 * dest_mbox, // Destination for the transformed message.
240 * std::move(msg.m_first) // Initializer for the new `part` instance.
241 * );
242 * });
243 * \endcode
244 *
245 * If this helper is used for signals then \a transformer should be a
246 * function without arguments:
247 * \code
248 * struct first_signal final : public so_5::signal_t {};
249 * struct second_signal final : public so_5::signal_t {};
250 *
251 * ...
252 * so_5::mbox_t src_mbox = ...;
253 * so_5::mbox_t dest_mbox = ...;
254 *
255 * so_5::single_sink_binding_t binding;
256 * so_5::bind_transformer< first_signal >(binding, src_mbox,
257 * [dest_mbox]() {
258 * return so_5::make_transformed<second_signal>(
259 * dest_mbox // Destination for the transformed message.
260 * );
261 * });
262 * \endcode
263 *
264 * The \a transformer is expected to return a so_5::transformed_message_t
265 * or std::optional<so_5::transformed_message_t>:
266 * \code
267 * // so_5::immutable_msg is supported as well as so_5::mutable_msg.
268 * so_5::bind_transformer< so_5::immutable_msg<compound> >(binding, src_mbox,
269 * [dest_mbox](const auto & msg)
270 * -> std::optional<so_5::transformed_message_t<part>>
271 * {
272 * if(should_message_be_transformed(msg)) {
273 * return {
274 * so_5::make_transformed<part>(
275 * dest_mbox, // Destination for the transformed message.
276 * msg.m_first // Initializer for the new `part` instance.
277 * ) };
278 * }
279 * else
280 * return std::nullopt; // No transformation.
281 * });
282 * \endcode
283 *
284 * \note
285 * The \a transformer can have an argument in the form of `const auto &`:
286 * \code
287 * so_5::bind_transformer< compound >(binding, src, [](const auto & msg) {...});
288 * \endcode
289 *
290 * \tparam Expected_Msg type of the source message or signal. If `Msg` is the
291 * message type, then `Msg`, `so_5::immutable_msg<Msg>` or
292 * `so_5::mutable_msg<Msg>` can be used. If `Msg` is the signal type then
293 * `Msg` or `so_5::immutable_msg<Msg>` is allowed.
294 *
295 * \tparam Binding type of binding object. It's expected to be
296 * so_5::single_sink_binding_t, so_5::multi_sink_binding_t or a similar
297 * type with the same interface.
298 *
299 * \tparam Transformer type of transformer functor (a lambda or free function).
300 *
301 * \since v.5.8.1
302 */
303template< typename Expected_Msg, typename Binding, typename Transformer >
304void
306 //! Binding object to be used.
307 Binding & binding,
308 //! Source mbox. It must not be nullptr.
309 const so_5::mbox_t & src_mbox,
310 //! Transformer that produced so_5::transformed_message_t instance or
311 //! std::optional<so_5::transformed_message_t> instance.
312 Transformer && transformer )
313 {
314 binding.template bind< Expected_Msg >(
315 src_mbox,
319 }
320
321/*!
322 * \brief Helper function to add transform_then_redirect msink to a binding
323 * object (with a delivery filter).
324 *
325 * The type of the source message is specified explicitly.
326 *
327 * \attention
328 * Because the source message is specified explicitly, this helper
329 * can be used for immutable and mutable messages.
330 *
331 * \attention
332 * This helper can't be used for signals because delivery filters are
333 * not applicable to signals.
334 *
335 * Usage example:
336 * \code
337 * struct part { ... };
338 * struct compound {
339 * part m_first;
340 * part m_second;
341 * };
342 *
343 * ...
344 * so_5::mbox_t src_mbox = ...;
345 * so_5::mbox_t dest_mbox = ...;
346 *
347 * so_5::single_sink_binding_t binding;
348 * so_5::bind_transformer< so_5::mutable_msg<compound> >(binding, src_mbox,
349 * [dest_mbox](compound & msg) { // or [dest_mbox](auto & msg)
350 * return so_5::make_transformed<part>(
351 * dest_mbox, // Destination for the transformed message.
352 * std::move(msg.m_first) // Initializer for the new `part` instance.
353 * );
354 * },
355 * // Note the use of const, delivery filter always receives a const
356 * // reference for a message to be filtered.
357 * [](const compound & msg) { // or [](const auto & msg)
358 * return ...; // Some predicate.
359 * });
360 * \endcode
361 *
362 * The \a transformer is expected to return a so_5::transformed_message_t
363 * or std::optional<so_5::transformed_message_t>:
364 * \code
365 * so_5::bind_transformer< so_5::mutable_msg<compound> >(binding, src_mbox,
366 * [dest_mbox](auto & msg)
367 * -> std::optional<so_5::transformed_message_t<part>>
368 * {
369 * if(should_message_be_transformed(msg)) {
370 * return {
371 * so_5::make_transformed<part>(
372 * dest_mbox, // Destination for the transformed message.
373 * std::move(msg.m_first) // Initializer for the new `part` instance.
374 * ) };
375 * }
376 * else
377 * return std::nullopt; // No transformation.
378 * },
379 * // Note the use of const, delivery filter always receives a const
380 * // reference for a message to be filtered.
381 * [](const compound & msg) { // or [](const auto & msg)
382 * return ...; // Some predicate.
383 * });
384 * \endcode
385 *
386 * \note
387 * The \a transformer can have an argument in the form of `const auto &`:
388 * \code
389 * so_5::bind_transformer< compound >(binding, src,
390 * // Transformer.
391 * [](const auto & msg) {...},
392 * // Delivery filter
393 * [](const auto & msg) {...});
394 * \endcode
395 *
396 * \tparam Expected_Msg type of the source message or signal. When `Msg` is the
397 * expected message type, then `Msg`, `so_5::immutable_msg<Msg>` or
398 * `so_5::mutable_msg<Msg>` can be used.
399 *
400 * \tparam Binding type of binding object. It's expected to be
401 * so_5::single_sink_binding_t, so_5::multi_sink_binding_t or a similar
402 * type with the same interface.
403 *
404 * \tparam Transformer type of transformer functor (a lambda or free function).
405 *
406 * \since v.5.8.1
407 */
408template<
409 typename Expected_Msg,
410 typename Binding,
411 typename Transformer,
412 typename Delivery_Filter >
413void
415 //! Binding object to be used.
416 Binding & binding,
417 //! Source mbox. It must not be nullptr.
418 const so_5::mbox_t & src_mbox,
419 //! Transformer that produced so_5::transformed_message_t instance or
420 //! std::optional<so_5::transformed_message_t> instance.
421 Transformer && transformer,
422 //! Delivery filter for the source message.
423 Delivery_Filter && delivery_filter )
424 {
425 binding.template bind< Expected_Msg >(
426 src_mbox,
431 }
432
433} /* namespace so_5 */
Interface for message sink.
A base class for agents.
Definition agent.hpp:673
static demand_handler_pfn_t get_demand_handler_on_message_ptr() noexcept
Definition agent.cpp:1526
static demand_handler_pfn_t get_demand_handler_on_enveloped_msg_ptr() noexcept
Definition agent.cpp:1544
It's a kind of strong typedef for coop's deregistration reason.
Definition coop.hpp:80
Type of smart handle for a cooperation.
An interface of delivery filter object.
Definition mbox.hpp:62
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.
An information about payload inside envelope.
message_ref_t & message() const noexcept
Parameters for the SObjectizer Environment initialization.
environment_params_t()
Constructor.
SObjectizer Environment.
Interface of event_queue_hook object.
An interface of event queue for agent.
trigger_t & trigger() const noexcept
Get a reference to activated trigger.
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 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.
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.
token_t(abstract_scenario_step_t *activated_step, abstract_scenario_step_t::token_t step_token)
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.
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
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.
Definition all.cpp:449
agent_unfreezer_t & operator=(const agent_unfreezer_t &)=delete
virtual void unfreeze() noexcept=0
Issue a command to unfreeze all frozen agents.
agent_unfreezer_t & operator=(agent_unfreezer_t &&)=delete
constraint_t & operator=(constraint_t &&)=delete
virtual void start() noexcept=0
Hook for step preactivation.
constraint_t & operator=(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 agent_t * register_new_catcher(const so_5::mbox_t &from) const
Helper for registration of a new agent.
const std::chrono::steady_clock::duration m_pause
Value to be used.
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.
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.
bool check(const incident_status_t, const incident_info_t &) const noexcept override
Check for fulfillment of constraint.
preactivate_actions_container_t m_preactivate_actions
All preactivation actions.
Definition all.cpp:143
std::size_t m_triggers_activated
Count of triggers those are activated.
Definition all.cpp:175
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
Definition all.cpp:256
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.
Definition all.cpp:210
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.
Definition all.cpp:353
void setup_constraints(constraint_container_t constraints) noexcept override
Setup constraints for the step.
Definition all.cpp:301
void preactivate() noexcept override
Perform preactivation of the step.
Definition all.cpp:203
std::size_t m_last_non_activated_trigger
Index of last trigger in the first part of trigger's container.
Definition all.cpp:166
status_t status() const noexcept override
Get the current status of the step.
Definition all.cpp:273
std::size_t m_triggers_to_completion
Count of activated triggers those are not completed yet.
Definition all.cpp:184
status_t m_status
The current state of the step.
Definition all.cpp:187
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.
Definition all.cpp:230
const std::string & name() const noexcept override
Get the name of the step.
Definition all.cpp:197
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.
Definition all.cpp:367
constraint_container_t m_constraints
All constraints.
Definition all.cpp:146
void add_preactivate_action(preactivate_action_t action) override
Add another preactivation action.
Definition all.cpp:279
void setup_triggers(trigger_container_t triggers, std::size_t triggers_to_activate) noexcept override
Setup triggers for the step.
Definition all.cpp:286
void no_handler_hook(const incident_info_t &info, const message_ref_t &incoming_msg) noexcept override
Definition all.cpp:656
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.
Definition all.cpp:737
bool has_stored_state_name(const std::string &step_name, const std::string &tag) const override
Check presence of the stored state name.
Definition all.cpp:719
std::size_t m_waiting_step_index
Index of the current preactivated step.
Definition all.cpp:499
std::set< abstract_scenario_step_t * > m_active_steps
Set of active step those are not completed yet.
Definition all.cpp:496
scenario_result_t result() const noexcept override
Get the result of scenario execution.
Definition all.cpp:566
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.
Definition all.cpp:682
bool has_stored_msg_inspection_result(const std::string &step_name, const std::string &tag) const override
Is there the inspection result?
Definition all.cpp:762
std::string stored_state_name(const std::string &step_name, const std::string &tag) const override
Get the stored state name.
Definition all.cpp:694
token_t react_on_pre_handler_hook(const incident_info_t &info, const message_ref_t &incoming_msg) noexcept
Definition all.cpp:789
std::condition_variable m_completion_cv
Condition variable for waiting completion of the scenario.
Definition all.cpp:480
void react_on_no_handler_hook(const incident_info_t &info, const message_ref_t &incoming_msg) noexcept
Definition all.cpp:833
void post_handler_hook(token_t token) noexcept override
Hook that should be called just after completion of event-handler.
Definition all.cpp:627
void run_for(std::chrono::steady_clock::duration run_time) override
Run the scenario until completion or for specific amount of time.
Definition all.cpp:577
agent_unfreezer_t * m_unfreezer
Unfreezer for registered agents.
Definition all.cpp:530
void setup_unfreezer(agent_unfreezer_t &unfreezer) noexcept
Set the unfreezer for registered agents.
Definition all.cpp:541
inspection_result_map_t m_stored_inspection_results
Container for holding stored inspection results for messages.
Definition all.cpp:524
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.
Definition all.cpp:672
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.
Definition all.cpp:607
step_definition_proxy_t define_step(nonempty_name_t step_name) override
Create a new step and return proxy for it.
Definition all.cpp:548
state_name_map_t m_stored_states
Container for holding stored state names.
Definition all.cpp:518
scenario_status_t m_status
The current state of the scenario.
Definition all.cpp:483
std::vector< step_unique_ptr_t > m_steps
Scenario's steps.
Definition all.cpp:489
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
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
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_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.
void set_completion(completion_function_t fn)
Setter for completion function.
Definition all.cpp:51
void set_activation(activation_function_t fn)
Setter for activation function.
Definition all.cpp:73
void activate(const trigger_activation_context_t &context) noexcept
Do activation of the trigger.
Definition all.cpp:114
bool check(const incident_status_t incident_status, const incident_info_t &info) const noexcept
Check for activation of the trigger.
Definition all.cpp:96
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.
Definition all.cpp:28
const agent_t & target_agent() const noexcept
Get the reference of the target agent.
Definition all.cpp:45
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?
Definition all.cpp:108
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.
Definition all.cpp:122
const agent_t & m_target_agent
A reference to the target agent.
outliving_reference_t< so_5::enveloped_msg::handler_invoker_t > m_invoker
Handler invoker that has to be used for extracted message.
Definition all.cpp:1079
invoker_for_message_extraction_t(outliving_reference_t< so_5::enveloped_msg::handler_invoker_t > invoker, so_5::enveloped_msg::access_context_t access_context)
Initializing constructor.
Definition all.cpp:1089
const so_5::enveloped_msg::access_context_t m_access_context
Context for accessing enveloped message.
Definition all.cpp:1082
bool handled() const noexcept
Has the message actually been handled?
Definition all.cpp:1128
void invoke(const so_5::enveloped_msg::payload_info_t &payload) noexcept override
Call an actual handler for the enveloped message/signal.
Definition all.cpp:1099
void invoke(const payload_info_t &payload) noexcept override
Call an actual handler for the enveloped message/signal.
Definition all.cpp:1061
no_handler_invoker_t(outliving_reference_t< special_envelope_t > owner)
Initializing constructor.
Definition all.cpp:1055
outliving_reference_t< special_envelope_t > m_owner
Owner of this invoker.
Definition all.cpp:1051
outliving_reference_t< handler_invoker_t > m_actual_invoker
Invoker to be used to call the actual event handler.
Definition all.cpp:1016
void invoke(const payload_info_t &payload) noexcept override
Call an actual handler for the enveloped message/signal.
Definition all.cpp:1030
pre_handler_hook_invoker_t(outliving_reference_t< special_envelope_t > owner, outliving_reference_t< handler_invoker_t > actual_invoker)
Intializing constructor.
Definition all.cpp:1020
outliving_reference_t< special_envelope_t > m_owner
Owner of this invoker.
Definition all.cpp:1013
outliving_reference_t< details::abstract_scenario_t > m_scenario
A testing scenario for that envelope.
Definition all.cpp:1000
special_envelope_t(outliving_reference_t< details::abstract_scenario_t > scenario, const execution_demand_t &demand)
Initializing constructor.
Definition all.cpp:1136
details::incident_info_t m_demand_info
Information about enveloped message.
Definition all.cpp:1002
void access_hook(access_context_t context, handler_invoker_t &invoker) noexcept override
Definition all.cpp:1165
delivery_result_t m_delivery_result
Was this message handled by a receiver?
Definition all.cpp:1007
void unfreeze() noexcept override
Issue a command to unfreeze all frozen agents.
Definition all.cpp:1490
outliving_reference_t< details::abstract_scenario_t > m_scenario
Testing scenario for that this object is created.
Definition all.cpp:1440
void on_unbind(agent_t *, event_queue_t *queue) noexcept override
A reaction to unbinding of an agent from some event_queue.
Definition all.cpp:1480
queue_mode_t m_mode
Mode of operation for new queues.
Definition all.cpp:1437
std::vector< special_event_queue_t * > m_created_queues
List of all queues created before unfreeze was called.
Definition all.cpp:1452
special_event_queue_hook_t(outliving_reference_t< details::abstract_scenario_t > scenario)
Definition all.cpp:1455
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.
Definition all.cpp:1462
std::vector< execution_demand_t > m_buffer
Local storage for demands to be used in buffered mode.
Definition all.cpp:1280
static bool is_ordinary_demand(const execution_demand_t &demand) noexcept
Definition all.cpp:1283
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)
Definition all.cpp:1303
void push_evt_finish(execution_demand_t demand) noexcept override
Enqueue a demand for evt_finish event.
Definition all.cpp:1344
queue_mode_t m_mode
The current mode of operation.
Definition all.cpp:1278
void push_evt_start(execution_demand_t demand) override
Enqueue a demand for evt_start event.
Definition all.cpp:1337
outliving_reference_t< event_queue_t > m_original_queue
Original event_queue.
Definition all.cpp:1275
void push(execution_demand_t demand) override
Enqueue new event to the queue.
Definition all.cpp:1313
outliving_reference_t< details::abstract_scenario_t > m_scenario
Testing scenario for that this queue was created.
Definition all.cpp:1273
stop_guard_for_unfreezer_t(outliving_reference_t< details::agent_unfreezer_t > unfreezer, outliving_reference_t< environment_t > env)
Definition all.cpp:1396
outliving_reference_t< details::agent_unfreezer_t > m_unfreezer
Definition all.cpp:1392
void stop() noexcept override
Perform stop-related actions.
Definition all.cpp:1404
step_definition_proxy_t define_step(nonempty_name_t step_name)
Start definition of a new scenario's step.
Definition all.cpp:1608
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.
Definition all.cpp:1628
std::string stored_msg_inspection_result(const std::string &step_name, const std::string &tag) const
Try to get stored msg inspection result.
Definition all.cpp:1644
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?
Definition all.cpp:1636
bool has_stored_msg_inspection_result(const std::string &step_name, const std::string &tag) const
Is there the inspection result?
Definition all.cpp:1652
void run_for(std::chrono::steady_clock::duration run_time)
Runs the scenario for specified amount of time.
Definition all.cpp:1621
scenario_proxy_t(outliving_reference_t< details::abstract_scenario_t > scenario)
Definition all.cpp:1602
scenario_result_t result() const
Get the result of scenario execution.
Definition all.cpp:1615
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)
friend std::ostream & operator<<(std::ostream &to, const scenario_result_t &v)
Dump of object's content to ostream.
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.
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_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.
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.
Definition all.cpp:1694
environment_t & environment() const
Access to wrapped environment.
Definition all.cpp:1688
testing_env_t(environment_params_t &&env_params)
Definition all.cpp:1671
scenario_proxy_t scenario() noexcept
Access to the associated scenario.
Definition all.cpp:1713
void join()
Wait for complete finish of environment's work.
Definition all.cpp:1700
void tune_environment_on_start(environment_t &env)
Definition all.cpp:1719
void stop_then_join()
Send stop signal and wait for complete finish of environment's work.
Definition all.cpp:1706
testing_env_t(so_5::generic_simple_so_env_params_tuner_t env_params_tuner)
A constructor that allows to tune environment's parameters.
Definition all.cpp:1666
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.
An information block about one subscription to one message type with presence of message_sink.
void set_filter(const delivery_filter_t &filter)
Set the delivery filter for the subscriber.
abstract_message_sink_t & sink_reference() const noexcept
Get a reference to the subscribed sink.
abstract_message_sink_t * sink_pointer() const noexcept
Get a pointer to the subscribed sink.
const delivery_filter_t * m_filter
Delivery filter for that message for that subscription.
subscription_info_with_sink_t(abstract_message_sink_t &sink, const delivery_filter_t &filter)
delivery_possibility_t must_be_delivered(const message_ref_t &msg, Msg_Ref_Extractor msg_extractor) const
Must a message be delivered to the subscriber?
void set_sink(abstract_message_sink_t &sink)
Inform about addition of a subscription.
An information block about one subscription to one message type.
delivery_possibility_t must_be_delivered(abstract_message_sink_t &subscriber, const message_ref_t &msg, Msg_Ref_Extractor msg_extractor) const
Must a message be delivered to the subscriber?
void set_filter(const delivery_filter_t &filter)
Set the delivery filter for the subscriber.
const delivery_filter_t * m_filter
Delivery filter for that message for that subscription.
Auxiliary class for the SObjectizer launching.
Definition api.hpp:31
Init m_init
Initialization routine.
Definition api.hpp:53
void init() override
Initialization hook.
Definition api.hpp:46
so_quick_environment_t(Init init, so_5::environment_params_t &&env_params)
Definition api.hpp:35
An interface of the additional SObjectizer Environment layer.
Definition so_layer.hpp:31
auto_closer_t & operator=(const auto_closer_t &)=delete
auto_closer_t(so_5::mchain_props::close_mode_t close_mode)
auto_closer_t(const auto_closer_t &)=delete
auto_closer_t & operator=(auto_closer_t &&o) noexcept
friend void swap(auto_closer_t &a, auto_closer_t &b) noexcept
Basic parameters for advanced receive from mchain and for multi chain select.
Definition mchain.hpp:1270
Helper class for automatic close of a mchain at the destruction of master handle instance.
const mchain_t & get() const noexcept
Get the mchain.
mchain_master_handle_t(mchain_master_handle_t &&handle) noexcept
Move constructor.
mchain_master_handle_t(mchain_t chain, mchain_props::close_mode_t close_mode) noexcept
Initializing constructor.
const mchain_t & operator*() const noexcept
Get the mchain.
static mchain_master_handle_t make(mchain_t chain, mchain_props::close_mode_t close_mode) noexcept
static mchain_master_handle_t with_retain_content(mchain_t chain) noexcept
mchain_master_handle_t & operator=(const mchain_master_handle_t &)=delete
friend void swap(mchain_master_handle_t &a, mchain_master_handle_t &b) noexcept
Swap operation.
~mchain_master_handle_t()
Destructor closes the chain.
mchain_props::close_mode_t m_close_mode
Close mode for mchain.
mchain_master_handle_t(const mchain_master_handle_t &)=delete
static mchain_master_handle_t with_drop_content(mchain_t chain) noexcept
mchain_master_handle_t & operator=(mchain_master_handle_t &&handle) noexcept
Move operator.
Actual implementation of one multi chain select case.
actual_receive_select_case_t(mchain_t chain, Handlers &&... handlers)
Initializing constructor.
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.
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.
A holder for serie of select_cases for the case of extensible select.
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.
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.
Special class for locking extensible-select instance for modification.
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 > &&params, extensible_select_cases_holder_t &&cases) noexcept
Initializing constructor.
Special class for locking prepared-select instance for activation inside select() call.
prepared_select_data_t(mchain_select_params_t< msg_count_status_t::defined > &&params, 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.
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 &notificator) override
An attempt to handle this case.
Helper class for performing select-specific operations.
const mchain_select_params_t< msg_count_status_t::defined > & m_params
void on_send_result(select_case_t *current, const mchain_send_result_t &result)
extraction_status_t last_extraction_status() const noexcept
std::size_t m_completed_send_cases
The counter of completed send_cases.
void on_receive_result(select_case_t *current, const mchain_receive_result_t &result)
mchain_select_result_t make_result() const noexcept
select_actions_performer_t(const mchain_select_params_t< msg_count_status_t::defined > &params, const Holder &select_cases)
bool operator!=(const const_iterator &o) const noexcept
bool operator==(const const_iterator &o) const noexcept
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
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 &notificator) 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.
select_case_t * query_next() const noexcept
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(const select_case_t &)=delete
select_case_t(mchain_t chain)
Initialized constructor.
select_case_t * giveout_next() noexcept
virtual handling_result_t try_handle(select_notificator_t &notificator)=0
An attempt to handle this case.
select_notificator_t * m_notificator
Notificator to be used for notify sleeping thread.
void notify() noexcept
Notification for all waiting select_cases.
select_case_t * m_next
Next select_case in queue.
mchain_t m_chain
Message chain to receive message from.
void on_select_finish() noexcept
Reaction to the end of select work.
select_case_t(select_case_t &&)=delete
An interface of select_case notificator.
virtual void notify(select_case_t &what) noexcept=0
A result of receive from mchain.
Definition mchain.hpp:962
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.
Definition mchain.hpp:1034
A base class for agent messages.
Definition message.hpp:47
friend message_kind_t message_kind(const so_5::intrusive_ptr_t< message_t > &what)
Helper method for quering kind of the message.
Definition message.hpp:154
Class that actually holds multiple sinks bindings.
void do_actual_bind(const std::type_index &msg_type, const mbox_t &from, const msink_t &dest, Single_Sink_Modificator &&single_sink_modificator)
Implementation of bind procedure.
void do_bind(const mbox_t &from, const msink_t &dest)
void do_unbind(const mbox_t &from, const msink_t &dest) noexcept
void do_bind(const mbox_t &from, const msink_t &dest, delivery_filter_unique_ptr_t delivery_filter)
void do_unbind_all_for(const mbox_t &from, const msink_t &dest) noexcept
insertion_it_with_auto_erase_if_not_committed_t(const insertion_it_with_auto_erase_if_not_committed_t &)=delete
insertion_it_with_auto_erase_if_not_committed_t(insertion_it_with_auto_erase_if_not_committed_t &&)=delete
insertion_it_with_auto_erase_if_not_committed_t(Container &container, typename Container::key_type const &k)
Initializing constructor.
Helper class for managing multiple sink bindings.
multi_sink_binding_t & operator=(multi_sink_binding_t &&)=delete
void bind(const mbox_t &from, const msink_t &dest)
void bind(const mbox_t &from, const msink_t &dest, delivery_filter_unique_ptr_t delivery_filter)
void unbind(const mbox_t &from, const msink_t &dest) noexcept
void bind(const mbox_t &from, const msink_t &dest, Lambda &&filter)
multi_sink_binding_t & operator=(const multi_sink_binding_t &)=delete
multi_sink_binding_t(multi_sink_binding_t &&)=delete
void unbind_all_for(const mbox_t &from, const msink_t &dest) noexcept
multi_sink_binding_t(const multi_sink_binding_t &)=delete
A class for the name which cannot be empty.
Helper class for indication of long-lived reference via its type.
Definition outliving.hpp:98
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.
Helper class for managing single sink bindings.
void bind(const mbox_t &source, const msink_t &sink_owner)
single_sink_binding_t(single_sink_binding_t &&other) noexcept
single_sink_binding_t(const single_sink_binding_t &)=delete
single_sink_binding_t & operator=(single_sink_binding_t &&other) noexcept
std::optional< binding_info_t > m_info
void bind(const mbox_t &source, const msink_t &sink_owner, delivery_filter_unique_ptr_t delivery_filter)
single_sink_binding_t & operator=(const single_sink_binding_t &)=delete
void bind(const mbox_t &source, const msink_t &sink_owner, Lambda &&filter)
void bind_for_msg_type(const std::type_index &msg_type, const mbox_t &source, const msink_t &sink_owner)
friend void swap(single_sink_binding_t &a, single_sink_binding_t &b) noexcept
single_sink_binding_t() noexcept=default
void bind_for_msg_type(const std::type_index &msg_type, const mbox_t &source, const msink_t &sink_owner, delivery_filter_unique_ptr_t delivery_filter)
An interface of stop_guard entity.
friend void swap(auto_joiner_t &a, auto_joiner_t &b) noexcept
auto_joiner_t & operator=(const auto_joiner_t &)=delete
auto_joiner_t(const auto_joiner_t &)=delete
void set_thread(std::size_t index, std::thread &t)
auto_joiner_t & operator=(auto_joiner_t &&o) noexcept
std::string query_name() const override
Get the mbox name.
void modify_and_remove_subscriber_if_needed(const std::type_index &msg_type, abstract_message_sink_t &subscriber, Info_Changer changer)
void do_deliver_message_impl(typename Tracing_Base::deliver_op_tracer const &tracer, message_delivery_mode_t delivery_mode, const std::type_index &msg_type, const message_ref_t &message, unsigned int redirection_deep)
environment_t & environment() const noexcept override
SObjectizer Environment for which the mbox is created.
void do_deliver_message(message_delivery_mode_t delivery_mode, const std::type_index &msg_type, const message_ref_t &message, unsigned int redirection_deep) override
Deliver message for all subscribers with respect to message limits.
void insert_or_modify_subscriber(const std::type_index &msg_type, abstract_message_sink_t &subscriber, Info_Maker maker, Info_Changer changer)
void subscribe_event_handler(const std::type_index &msg_type, abstract_message_sink_t &subscriber) override
Add the message handler.
actual_mbox_t(mbox_id_t id, outliving_reference_t< environment_t > env, Tracing_Args &&... args)
void drop_delivery_filter(const std::type_index &msg_type, abstract_message_sink_t &subscriber) noexcept override
Removes delivery filter for message type and subscriber.
mbox_type_t type() const override
Get the type of message box.
void set_delivery_filter(const std::type_index &msg_type, const delivery_filter_t &filter, abstract_message_sink_t &subscriber) override
Set a delivery filter for message type and subscriber.
void do_deliver_message_to_subscriber(const subscriber_info_t &subscriber_info, typename Tracing_Base::deliver_op_tracer const &tracer, message_delivery_mode_t delivery_mode, const std::type_index &msg_type, const message_ref_t &message, unsigned int redirection_deep) const
void unsubscribe_event_handler(const std::type_index &msg_type, abstract_message_sink_t &subscriber) noexcept override
Remove all message handlers.
mbox_id_t id() const override
Unique ID of this mbox.
A wrapped environment.
void stop()
Send stop signal to environment.
wrapped_env_t(wait_init_completion_t wait_init_completion_indicator, so_5::generic_simple_init_t init_func, environment_params_t &&params)
A constructor for synchronous mode which receives initialization function and already prepared enviro...
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 &&params)
wrapped_env_t(const wrapped_env_t &)=delete
std::unique_ptr< details_t > m_impl
Implementation details.
wrapped_env_t(environment_params_t &&params)
A constructor which receives already prepared environment's params.
wrapped_env_t(so_5::generic_simple_init_t init_func)
A constructor which receives only initialization function.
wrapped_env_t(wrapped_env_t &&)=delete
wrapped_env_t()
Default constructor.
static constexpr wait_init_completion_t wait_init_completion
Special indicator that tells that synchronous mode has to be used for calling init-function.
~wrapped_env_t()
Destructor.
wrapped_env_t(wait_init_completion_t wait_init_completion_indicator, so_5::generic_simple_init_t init_func, so_5::generic_simple_so_env_params_tuner_t params_tuner)
A constructor for synchronous mode which receives initialization function and a function for environm...
wrapped_env_t(wait_init_completion_t wait_init_completion_indicator, so_5::generic_simple_init_t init_func)
A constructor for synchronous mode which receives only initialization function.
wrapped_env_t(so_5::generic_simple_init_t init_func, so_5::generic_simple_so_env_params_tuner_t params_tuner)
A constructor which receives initialization function and a function for environment's params tuning.
void join()
Wait for complete finish of environment's work.
environment_t & environment() const
Access to wrapped environment.
wrapped_env_t(so_5::generic_simple_init_t init_func, environment_params_t &&params, wrapped_env_details::init_style_t init_style)
The main initializing constructor.
wait_init_completion_t
Helper type to be used as indicator of synchronous mode.
#define SO_5_TYPE
Definition declspec.hpp:46
#define SO_5_THROW_EXCEPTION(error_code, desc)
Definition exception.hpp:74
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.
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.
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 &&params)
Definition all.cpp:1582
void setup_special_queue_hook(outliving_reference_t< testing_env_t::internals_t > internals, environment_params_t &to)
Definition all.cpp:1558
environment_params_t make_tuned_params(so_5::generic_simple_so_env_params_tuner_t env_params_tuner)
Definition all.cpp:1571
queue_mode_t
A mode of work for special_event_queue.
Definition all.cpp:1224
@ 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.
@ 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.
Implementation details for MPMC mboxes.
Details of SObjectizer run-time implementations.
Definition agent.cpp:905
void add_to_closer(Closer &to, std::size_t index, mchain_t ch, Tail &&... tail)
Helper for filling auto_closer object.
void add_to_closer(Closer &to, std::size_t index, mchain_t ch)
Helper for filling auto_closer object.
Implementation details.
Definition mchain.hpp:37
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 > &params, 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 > &params, 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 > &params, const Holder &select_cases)
void fill_select_cases_holder(extensible_select_cases_holder_t &)
Various properties and parameters of message chains.
Definition mchain.hpp:28
close_mode_t
What to do with chain's content at close.
Definition mchain.hpp:410
overflow_reaction_t
What reaction must be performed on attempt to push new message to the full message chain.
Definition mchain.hpp:199
msg_count_status_t
Status of limit for messages to be extracted/handled during a bulk operation on a mchain.
Definition mchain.hpp:1082
@ 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.
Definition mchain.hpp:371
@ no_messages
No available messages in the chain.
memory_usage_t
Memory allocation for storage for size-limited chains.
Definition mchain.hpp:182
insertion_it_with_auto_erase_if_not_committed_t(C &, const K &) -> insertion_it_with_auto_erase_if_not_committed_t< C >
void ensure_valid_argument_for_delivery_filter()
Helper to have more information in compiler output if static_assert fails.
void add_to_joiner(Joiner &to, std::size_t index, std::thread &t)
Helper for filling auto_joiner object.
void add_to_joiner(Joiner &to, std::size_t index, std::thread &t, Tail &&... tail)
Helper for filling auto_joiner object.
init_style_t
Style of handling init-functor in the constructor of wrapped_env.
Private part of message limit implementation.
Definition agent.cpp:33
mchain_t create_mchain(environment_t &env, std::size_t max_size, mchain_props::memory_usage_t memory_usage, mchain_props::overflow_reaction_t overflow_reaction)
Create size-limited chain without waiting on overflow.
message_delivery_mode_t
Possible modes of message/signal delivery.
Definition types.hpp:172
void launch(Init_Routine &&init_routine)
Launch a SObjectizer Environment with default parameters.
Definition api.hpp:142
mchain_t create_mchain(wrapped_env_t &sobj)
Create size-unlimited chain.
thread_auto_join_details::auto_joiner_t< 1+sizeof...(Tail) > auto_join(std::thread &first_thread, Tail &&... tail)
Helper function for creation of automatic joiner of std::threads.
mbox_type_t
Type of the message box.
Definition mbox.hpp:163
mbox_t make_unique_subscribers_mbox(so_5::environment_t &env)
Factory function for creation of a new instance of unique_subscribers mbox.
auto make_coop_reg_notificator(mbox_t target) noexcept
Create notificator about cooperation registration completion.
void bind_transformer(Binding &binding, const so_5::mbox_t &src_mbox, Transformer &&transformer)
Helper function to add transform_then_redirect msink to a binding object.
void bind_transformer(Binding &binding, const so_5::mbox_t &src_mbox, Transformer &&transformer, Delivery_Filter &&delivery_filter)
Helper function to add transform_then_redirect msink to a binding object (with a delivery filter).
mchain_auto_close_details::auto_closer_t< sizeof...(Tail) > auto_close_drop_content(Tail &&... tail)
Helper function for automatic closing of mchains with dropping their content.
mchain_t create_mchain(environment_t &env)
Create size-unlimited chain.
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_t create_mchain(environment_t &env, mchain_props::duration_t waiting_time, std::size_t max_size, mchain_props::memory_usage_t memory_usage, mchain_props::overflow_reaction_t overflow_reaction)
Create size-limited chain with waiting on overflow.
mchain_select_result_t select(const mchain_select_params_t< Msg_Count_Status > &params, Cases &&... cases)
An advanced form of multi chain select.
@ user_type_message
Message is an user type message.
@ enveloped_msg
Message is an envelope with some other message inside.
mchain_auto_close_details::auto_closer_t< sizeof...(Tail) > auto_close_retain_content(Tail &&... tail)
Helper function for automatic closing of mchains with retaining their content.
mchain_select_result_t select(const extensible_select_t &extensible_select)
A select operation to be done on previously prepared extensible-select object.
mchain_auto_close_details::auto_closer_t< sizeof...(Tail) > auto_close_mchains(mchain_props::close_mode_t close_mode, Tail &&... tail)
Helper function for creation of automatic closer of mchains.
message_ownership_t
Type of ownership of a message instance inside message_holder.
delivery_possibility_t
Result of checking delivery posibility.
Definition mbox.hpp:39
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_t create_mchain(wrapped_env_t &sobj, mchain_props::duration_t waiting_time, std::size_t max_size, mchain_props::memory_usage_t memory_usage, mchain_props::overflow_reaction_t overflow_reaction)
Create size-limited chain without waiting on overflow.
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.
mchain_t create_mchain(wrapped_env_t &sobj, std::size_t max_size, mchain_props::memory_usage_t memory_usage, mchain_props::overflow_reaction_t overflow_reaction)
Create size-limited chain without waiting on overflow.
void bind_transformer(Binding &binding, const so_5::mbox_t &src_mbox, Transformer &&transformer)
Helper function to add transform_then_redirect msink to a binding object.
void bind_transformer(Binding &binding, const so_5::mbox_t &src_mbox, Transformer &&transformer, Delivery_Filter &&filter)
Helper function to add transform_then_redirect msink to a binding object (with a delivery filter).
void launch(Init_Routine &&init_routine, Params_Tuner &&params_tuner)
Launch a SObjectizer Environment with explicitely specified parameters.
Definition api.hpp:212
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 selector of actual lock_holder type in dependency of lock type.
A description of event execution demand.
demand_handler_pfn_t m_demand_handler
Demand handler.
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.
Special indicator to be used in implementation of receives trigger.
A special data object for case of store-state-name completion 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.
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.
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...
Definition all.cpp:1525
Internal data for testing environment.
Definition all.cpp:1538
impl::special_event_queue_hook_t m_special_hook
Definition all.cpp:1540
static std::unique_ptr< internals_t > make()
Definition all.cpp:1552
Description of one demand in message chain.
Definition mchain.hpp:144
A helper class for detection of payload type of message.
Definition message.hpp:783
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
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
msg_coop_registered & operator=(const msg_coop_registered &)=delete
msg_coop_registered(msg_coop_registered &&)=delete
binding_info_t(const mbox_t &source, const std::type_index &msg_type, const msink_t &sink_owner, delivery_filter_unique_ptr_t delivery_filter) noexcept
std::type_index m_msg_type
Type of message/signal.
msink_t m_sink_owner
The destination for messages/signals.
delivery_filter_unique_ptr_t m_delivery_filter
Optional delivery filter.
Helper metafunction to check delivery filter lambda.
A coolection of data required for local mbox implementation.
environment_t & m_env
Environment for which the mbox is created.
messages_table_t m_subscribers
Map of subscribers to messages.
Implementation details for wrapped_env.