m2etis  0.4
NetworkCallbackInterface.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_NET_NETWORKCALLBACKINTERFACE_H__
23 #define __M2ETIS_NET_NETWORKCALLBACKINTERFACE_H__
24 
25 #include <stdexcept>
26 
28 #include "m2etis/net/NodeHandle.h"
29 
30 namespace m2etis {
31 namespace net {
32 
42  template<class NetworkType>
44  public:
47 
59  virtual bool forward(typename message::NetworkMessage<NetworkType>::Ptr message, const typename NodeHandle<NetworkType>::Ptr hint) = 0;
60 
66  virtual void deliver(typename message::NetworkMessage<NetworkType>::Ptr message) = 0;
67 
75  virtual void update(const typename NetworkType::Key & key, const typename NodeHandle<NetworkType>::Ptr_const handle, bool joined) = 0;
76  };
77 
78 } /* namespace net */
79 } /* namespace m2etis */
80 
81 #endif /* __M2ETIS_NET_NETWORKCALLBACKINTERFACE_H__ */
82 
virtual bool forward(typename message::NetworkMessage< NetworkType >::Ptr message, const typename NodeHandle< NetworkType >::Ptr hint)=0
called if a message is forwarded by your node
Generic interface for the callback-class used for the network.
virtual void deliver(typename message::NetworkMessage< NetworkType >::Ptr message)=0
called if a message is delivered to your node.
boost::shared_ptr< const NodeHandle< NetworkType > > Ptr_const
Definition: NodeHandle.h:61
boost::shared_ptr< NetworkMessage > Ptr
boost::shared_ptr< NodeHandle< NetworkType > > Ptr
Definition: NodeHandle.h:62
virtual void update(const typename NetworkType::Key &key, const typename NodeHandle< NetworkType >::Ptr_const handle, bool joined)=0
called on node joins or leaves