YAMI4 C++ Library 2.0.0
Messaging Solution for Distributed Systems
Loading...
Searching...
No Matches
incoming_message_generic_dispatcher.h
1// Copyright Maciej Sobczak 2008-2022.
2// This file is part of YAMI4.
3// See the package-level LICENSE.txt file.
4
5#ifndef YAMICPP_INCOMING_MESSAGE_GENERIC_DISPATCHER_H_INCLUDED
6#define YAMICPP_INCOMING_MESSAGE_GENERIC_DISPATCHER_H_INCLUDED
7
8#include "incoming_message_dispatcher_base.h"
9#include <yami4-core/dll.h>
10#include <string>
11
12namespace yami
13{
14
15class incoming_message;
16
17namespace details
18{
19
20template <typename functor>
23{
24public:
25 incoming_message_generic_dispatcher(functor & f) : f_(f) {}
26
27 virtual void dispatch(incoming_message & im)
28 {
29 f_(im);
30 }
31
32private:
33 functor & f_;
34};
35
38{
39public:
41 void (* callback)(incoming_message & im, void * hint), void * hint)
42 : callback_(callback),
43 hint_(hint)
44 {
45 }
46
47 virtual void dispatch(incoming_message & im)
48 {
49 callback_(im, hint_);
50 }
51
52private:
53 void (* callback_)(incoming_message & im, void * hint);
54 void * hint_;
55};
56
57} // namespace details
58
59} // namespace yami
60
61#endif // YAMICPP_INCOMING_MESSAGE_GENERIC_DISPATCHER_H_INCLUDED
Definition: incoming_message_dispatcher_base.h:20
Definition: incoming_message_generic_dispatcher.h:23
Definition: incoming_message_generic_dispatcher.h:38
Incoming message.
Definition: incoming_message.h:37
Namespace devoted to everything related to YAMI4.
Definition: agent.h:21