m2etis  0.4
NetworkMessage.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_MESSAGE_NETWORKMESSAGE_H__
23 #define __M2ETIS_MESSAGE_NETWORKMESSAGE_H__
24 
25 #include "m2etis/config/GeneratedEventTypes.h"
26 
28 
29 #include "m2etis/net/NetworkType.h"
30 
31 #include "boost/serialization/export.hpp"
32 #include "boost/serialization/list.hpp"
33 #include "boost/serialization/map.hpp"
34 #include "boost/serialization/shared_ptr.hpp"
35 #include "boost/serialization/variant.hpp"
36 #include "boost/serialization/vector.hpp"
37 
38 namespace m2etis {
39 namespace message {
40 
41  template<class NetworkType>
43  public:
44  // Message Ptr
45  typedef boost::shared_ptr<NetworkMessage> Ptr;
46 
50  typename NetworkType::Key sender;
51 
55  typename NetworkType::Key receiver;
56 
58 
59  NetworkMessage() : sender(), receiver(), typePtr() {
60  }
61 
62  explicit NetworkMessage(MessageType * mt) : sender(), receiver(), typePtr(mt) {
63  }
64 
65  NetworkMessage(const NetworkMessage & msg, MessageType * mt) : sender(msg.sender), receiver(msg.receiver), typePtr(mt) {
66  }
67 
68  virtual ~NetworkMessage() {}
69 
70 #ifdef WITH_SIM
71  SimulationEventType pl;
72 #endif /* WITH_SIM */
73 
74  private:
75  friend class boost::serialization::access;
76 
77  template<typename Archive>
78  void serialize(Archive & ar, const unsigned int /*version*/) {
79  ar & sender;
80  }
81  };
82 
83 } /* namespace message */
84 } /* namespace m2etis */
85 
86 #endif /* __M2ETIS_MESSAGE_NETWORKMESSAGE_H__ */
87 
NetworkType::Key sender
sender of the message
NetworkType::Key receiver
receiver of the message
NetworkMessage(const NetworkMessage &msg, MessageType *mt)
boost::shared_ptr< NetworkMessage > Ptr
uint32_t MessageType
Definition: MessageType.h:35