m2etis  0.4
BaseDeliver.h
Go to the documentation of this file.
1 /*
2  Copyright (2016) Michael Baer, Daniel Bonrath, All rights reserved.
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 
22 #ifndef __M2ETIS_PUBSUB_DELIVER_BASEDELIVER_H__
23 #define __M2ETIS_PUBSUB_DELIVER_BASEDELIVER_H__
24 
25 #include <string>
26 
29 
30 namespace m2etis {
31 namespace pubsub {
32 namespace deliver {
33 
34  enum class Amount {
38  };
39 
40  template<class NetworkType>
41  class BaseDeliver {
42  public:
44 
45  virtual ~BaseDeliver() {}
46 
51  void configureCallback(const boost::function<void(uint64_t, msgProcess)> & func) {
52  process_ = func;
53  }
54 
58  void configureSendCallback(const boost::function<void(message::DeliverInfo::Ptr, const typename NetworkType::Key &, ControlTarget)> & func) {
59  sendCtrlMsg_ = func;
60  }
61 
65  virtual void configureDeliverInfo(uint64_t id, const message::ActionType mtype, typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key & receiver, message::ControlType ct) = 0;
66 
70  virtual bool processPublishPayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key & sender) = 0;
71 
75  virtual bool processOtherControlPayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key & sender) = 0;
76 
80  virtual bool processControlPayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key & sender) = 0;
81 
85  virtual bool processNotifyPayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key & sender) = 0;
86 
90  virtual bool processSubscribePayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key & sender) = 0;
91 
95  virtual bool processUnsubscribePayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key & sender) = 0;
96 
97  protected:
102 
107  boost::function<void(uint64_t, msgProcess)> process_;
108 
117  boost::function<void(message::DeliverInfo::Ptr, typename NetworkType::Key, ControlTarget)> sendCtrlMsg_;
118  };
119 
120 } /* namespace deliver */
121 } /* namespace pubsub */
122 } /* namespace m2etis */
123 
124 #endif /* __M2ETIS_PUBSUB_DELIVER_BASEDELIVER_H__ */
125 
void configureCallback(const boost::function< void(uint64_t, msgProcess)> &func)
used to set the function to be called when a message should be send to the next processing stage call...
Definition: BaseDeliver.h:51
virtual bool processOtherControlPayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key &sender)=0
creates the DeliverInfo
boost::shared_ptr< DeliverInfo > Ptr
virtual void configureDeliverInfo(uint64_t id, const message::ActionType mtype, typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key &receiver, message::ControlType ct)=0
creates the DeliverInfo
virtual bool processControlPayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key &sender)=0
creates the DeliverInfo
BaseDeliver(PubSubSystemEnvironment *pssi)
Definition: BaseDeliver.h:43
void configureSendCallback(const boost::function< void(message::DeliverInfo::Ptr, const typename NetworkType::Key &, ControlTarget)> &func)
with this function, new messages can be sent directly to nodes
Definition: BaseDeliver.h:58
virtual bool processPublishPayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key &sender)=0
creates the DeliverInfo
virtual bool processSubscribePayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key &sender)=0
creates the DeliverInfo
PubSubSystemEnvironment * pssi_
PubSubSystemEnvironment.
Definition: BaseDeliver.h:101
boost::function< void(message::DeliverInfo::Ptr, typename NetworkType::Key, ControlTarget)> sendCtrlMsg_
stores the function to send new messages This function will send a newly created control message cont...
Definition: BaseDeliver.h:117
virtual bool processUnsubscribePayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key &sender)=0
processes Control Messages (id got acked)
boost::function< void(uint64_t, msgProcess)> process_
stores the function to be called for delivering
Definition: BaseDeliver.h:107
virtual bool processNotifyPayload(typename message::DeliverInfo::Ptr ptr, const typename NetworkType::Key &sender)=0
creates the DeliverInfo