Core Library  1.7.0.0
Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.
SimpleMulticastReceiver.h
Go to the documentation of this file.
1 // This file is part of CoreLibrary containing useful reusable utility
2 // classes.
3 //
4 // Copyright (C) 2014 to present, Duncan Crutchley
5 // Contact <dac1976github@outlook.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published
9 // by the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License and GNU Lesser General Public License
16 // for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // and GNU Lesser General Public License along with this program. If
20 // not, see <http://www.gnu.org/licenses/>.
21 
27 #ifndef SIMPLEMULTICASTRECEIVER
28 #define SIMPLEMULTICASTRECEIVER
29 
30 #include "MulticastReceiver.h"
31 #include "MessageUtils.h"
32 
34 namespace core_lib
35 {
37 namespace asio
38 {
40 namespace udp
41 {
42 
47 class CORE_LIBRARY_DLL_SHARED_API SimpleMulticastReceiver final
48 {
49 public:
51  SimpleMulticastReceiver() = delete;
75  const defs::connection_t& multicastConnection,
76  const defs::default_message_dispatcher_t& messageDispatcher,
77  const std::string& interfaceAddress = "",
78  size_t receiveBufferSize = DEFAULT_UDP_BUF_SIZE,
79  size_t memPoolMsgCount = 0);
101  SimpleMulticastReceiver(const defs::connection_t& multicastConnection,
102  const defs::default_message_dispatcher_t& messageDispatcher,
103  const std::string& interfaceAddress = "",
104  size_t receiveBufferSize = DEFAULT_UDP_BUF_SIZE,
105  size_t memPoolMsgCount = 0);
109  SimpleMulticastReceiver& operator=(SimpleMulticastReceiver&&) = delete;
113  SimpleMulticastReceiver& operator=(const SimpleMulticastReceiver&) = delete;
115  ~SimpleMulticastReceiver() = default;
120  defs::connection_t MulticastConnection() const;
125  std::string InterfaceAddress() const;
126 
127 private:
129  messages::MessageHandler m_messageHandler{};
132 };
133 
134 } // namespace udp
135 } // namespace asio
136 } // namespace core_lib
137 
138 #endif // SIMPLEMULTICASTRECEIVER
std::function< void(default_received_message_ptr_t)> default_message_dispatcher_t
Typedef to default message dispatcher function object.
Definition: AsioDefines.h:286
A simplified multicast receiver, which uses the class MessageHeader as the message header type...
Definition: SimpleMulticastReceiver.h:47
Default message handler class.
Definition: MessageUtils.h:55
MulticastReceiver m_mcastReceiver
Our actual typed multicast receiver object.
Definition: SimpleMulticastReceiver.h:131
File containing multicast receiver class declaration.
The core_lib namespace.
Definition: AsioDefines.h:59
A general purpose multicast receiver.
Definition: MulticastReceiver.h:49
std::pair< std::string, uint16_t > connection_t
Typedef describing a network connection as (address, port).
Definition: AsioDefines.h:152
boost_asio::io_context boost_iocontext_t
Boost IO context convenience typedef.
Definition: AsioDefines.h:46
File containing message utils declaration.