IQRF Gateway Daemon
IMessaging.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016-2017 MICRORISC s.r.o.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "JsonUtils.h"
20 #include <string>
21 #include <functional>
22 
23 class IDaemon;
24 
30 {
31 public:
35  virtual void start() = 0;
36 
40  virtual void stop() = 0;
41 
46  virtual void update(const rapidjson::Value& cfg) = 0;
47 
52  virtual const std::string& getName() const = 0;
53 
54  typedef std::basic_string<unsigned char> ustring;
56  typedef std::function<void(const ustring&)> MessageHandlerFunc;
57 
63  virtual void registerMessageHandler(MessageHandlerFunc hndl) = 0;
64 
68  virtual void unregisterMessageHandler() = 0;
69 
74  virtual void sendMessage(const ustring& msg) = 0;
75 
76  inline virtual ~IMessaging() {};
77 };
virtual ~IMessaging()
Definition: IMessaging.h:76
virtual const std::string & getName() const =0
Get name of the instance.
virtual void sendMessage(const ustring &msg)=0
send message
std::function< void(const ustring &)> MessageHandlerFunc
Incoming message handler functional type.
Definition: IMessaging.h:56
virtual void stop()=0
Stop Messaging instance.
virtual void start()=0
Start Messaging instance.
IDaemon interface.
Definition: IDaemon.h:31
virtual void unregisterMessageHandler()=0
Unregister message handler.
IMessaging interface.
Definition: IMessaging.h:29
virtual void registerMessageHandler(MessageHandlerFunc hndl)=0
Register message handler.
virtual void update(const rapidjson::Value &cfg)=0
Update configuration.
std::basic_string< unsigned char > ustring
Definition: IMessaging.h:54