m2etis  0.4
BaseOrder.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_ORDER_BASEORDER_H__
23 #define __M2ETIS_PUBSUB_ORDER_BASEORDER_H__
24 
26 
29 
30 namespace m2etis {
31 namespace pubsub {
32 namespace order {
33 
38  template<class NetworkType>
39  class BaseOrder {
40  public:
41  BaseOrder(PubSubSystemEnvironment * pssi, bool isRoot) : pssi_(pssi), isRoot_(isRoot), hn(), function_(), sendMsg_() {}
42  virtual ~BaseOrder() {}
43 
48  void configureCallback(const boost::function<void(uint64_t, msgProcess)> & func) {
49  function_ = func;
50  }
51 
55  void setHn(const typename NetworkType::Key & self) {
56  hn = self;
57  }
58 
62  void configureSendCallback(const boost::function<void(message::OrderInfo::Ptr, const typename NetworkType::Key &, ControlTarget)> & func) {
63  sendMsg_ = func;
64  }
65 
69  void setRoot(bool b) {
70  isRoot_ = b;
71  }
72 
76  virtual bool hasPending() = 0;
77 
81  virtual bool configureOrderInfo(uint64_t id, const message::ActionType mtype, typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key & rec) = 0;
82 
86  virtual bool processControlPayload(typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key & sender) = 0;
87 
91  virtual void processSubscribePayload(typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key & sender) = 0;
92 
96  virtual void processPublishPayload(typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key & sender) = 0;
97 
101  virtual void processNotifyPayload(typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key & sender) = 0;
102 
109  virtual void receive(uint64_t id, typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key & sender) = 0;
110 
114  virtual void notifyRemovedMessage(typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key & receiver) = 0;
115 
116  protected:
121 
125  bool isRoot_;
126 
130  typename NetworkType::Key hn;
131 
136  boost::function<void(uint64_t, msgProcess)> function_;
137 
146  boost::function<void(message::OrderInfo::Ptr, const typename NetworkType::Key &, ControlTarget)> sendMsg_;
147  };
148 
149 } /* namespace order */
150 } /* namespace pubsub */
151 } /* namespace m2etis */
152 
153 #endif /* __M2ETIS_PUBSUB_ORDER_BASEORDER_H__ */
154 
boost::shared_ptr< OrderInfo > Ptr
Definition: OrderInfo.h:31
virtual void processSubscribePayload(typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key &sender)=0
called for every SubscribeMsg that arrived
BaseOrder(PubSubSystemEnvironment *pssi, bool isRoot)
Definition: BaseOrder.h:41
virtual void receive(uint64_t id, typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key &sender)=0
called for every message that is ready to be delivered
bool isRoot_
true if this node is the root node
Definition: BaseOrder.h:125
PubSubSystemEnvironment * pssi_
Definition: BaseOrder.h:120
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: BaseOrder.h:48
virtual void processNotifyPayload(typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key &sender)=0
called for every NotifyMsg that arrived
virtual bool configureOrderInfo(uint64_t id, const message::ActionType mtype, typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key &rec)=0
called for every message to be sent
virtual void notifyRemovedMessage(typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key &receiver)=0
notified when message dropped by filter or validity strategy
boost::function< void(message::OrderInfo::Ptr, const typename NetworkType::Key &, ControlTarget)> sendMsg_
stores the function to send new messages This function will send a newly created control message cont...
Definition: BaseOrder.h:146
void setRoot(bool b)
sets whether this node is the root node. Several strategies need this to determind the sequencer ...
Definition: BaseOrder.h:69
This is the interface that should be used for all Order Strategies It specifies all functions that sh...
Definition: BaseOrder.h:39
void setHn(const typename NetworkType::Key &self)
sets the hostname of the current node
Definition: BaseOrder.h:55
void configureSendCallback(const boost::function< void(message::OrderInfo::Ptr, const typename NetworkType::Key &, ControlTarget)> &func)
with this function, new messages can be sent directly to nodes
Definition: BaseOrder.h:62
boost::function< void(uint64_t, msgProcess)> function_
stores the function to be called for delivering
Definition: BaseOrder.h:136
virtual bool processControlPayload(typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key &sender)=0
called for every ControlMsg that arrived
NetworkType::Key hn
hostname of the node
Definition: BaseOrder.h:130
virtual bool hasPending()=0
returns whether some messages are still waiting
virtual void processPublishPayload(typename message::OrderInfo::Ptr ptr, const typename NetworkType::Key &sender)=0
called for every PublishMsg that arrived