SObjectizer  5.8
Loading...
Searching...
No Matches
handler_makers.cpp
Go to the documentation of this file.
1/*
2 * SObjectizer-5
3 */
4
5/*!
6 * \file
7 * \brief Implementation of some parts of handler makers which can't be inline.
8 *
9 * \since
10 * v.5.5.23
11 */
12
13#include <so_5/handler_makers.hpp>
14
15#include <so_5/impl/enveloped_msg_details.hpp>
16
17namespace so_5 {
18
19namespace details {
20
21namespace {
22
23bool
25 const msg_type_and_handler_pair_t & handler,
26 message_ref_t & message )
27 {
28 using namespace so_5::enveloped_msg::impl;
29
30 bool result = false;
31
32 // We don't expect exceptions here and can't restore after them.
33 so_5::details::invoke_noexcept_code( [&] {
34 auto & envelope = message_to_envelope( message );
35
36 mchain_demand_handler_invoker_t invoker{ handler };
37 envelope.access_hook(
39 invoker );
40
41 result = invoker.was_handled();
42 } );
43
44 return result;
45 }
46
47} /* namespace anonymous */
48
50bool
54 const std::type_index & msg_type,
56 {
57 bool ret_value = false;
58
60 auto it = std::lower_bound( left, right, key );
61 if( it != right && it->m_msg_type == key.m_msg_type )
62 {
63 // Handler is found and must be called.
64 switch( message_kind( message ) )
65 {
69 // This is an async message.
70 // Simple call is enough.
71 ret_value = true;
73 break;
74
76 // Invocation must be done a special way.
78 break;
79 }
80 }
81
82 return ret_value;
83 }
84
85} /* namespace details */
86
87} /* namespace so_5 */
virtual void access_hook(access_context_t context, handler_invoker_t &invoker) noexcept=0
An implementation of handler_invoker interface for the case when a mesage was sent to mchain.
mchain_demand_handler_invoker_t(const ::so_5::details::msg_type_and_handler_pair_t &handler)
Initializing constructor.
#define SO_5_FUNC
Definition declspec.hpp:48
bool process_envelope_when_handler_found(const msg_type_and_handler_pair_t &handler, message_ref_t &message)
Some reusable and low-level classes/functions which can be used in public header files.
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.
Private part of message limit implementation.
Definition agent.cpp:33