m2etis  0.4
PubSubWrapper.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_SIM_PUBSUBWRAPPER_H__
23 #define __M2ETIS_SIM_PUBSUBWRAPPER_H__
24 
25 #include <string>
26 
32 
34 
35 namespace m2etis {
36 namespace pubsub {
37  class PubSubSystem;
38  class PubSubSystemEnvironment;
39 } /* namespace pubsub */
40 namespace sim {
41 
42  class OmNetCallbackInterface;
43 
44  class PubSubWrapper {
45  public:
55  PubSubWrapper(OmNetCallbackInterface * o, const std::string & ip, const int port, const std::string & known_hostname, const int known_hostport, const std::vector<std::string> & rootList);
56 
63  void subscribe(const pubsub::ChannelName channel, pubsub::BasicDeliverCallbackInterface<SimulationEventType> & callback);
64 
71  void publish(const pubsub::ChannelName channel, const message::M2Message<SimulationEventType>::Ptr msg) const;
72 
78  void unsubscribe(const pubsub::ChannelName channel) const;
79 
86  message::M2Message<SimulationEventType>::Ptr createMessage(const pubsub::ChannelName channel, const SimulationEventType & v);
87 
95 
103 
108 
112  void Update();
113 
118  };
119 
120 } /* namespace sim */
121 } /* namespace m2etis */
122 
123 #endif /* __M2ETIS_SIM_PUBSUBWRAPPER_H__ */
124 
boost::shared_ptr< M2Message< EventType > > Ptr
Definition: M2Message.h:42
void Update()
method updating Scheduler for simulator
pubsub::PubSubSystemEnvironment * pssi()
getter for PubSubSystemEnvironment
PubSubWrapper(OmNetCallbackInterface *o, const std::string &ip, const int port, const std::string &known_hostname, const int known_hostport, const std::vector< std::string > &rootList)
constructor creating wrapper out of simulator
void subscribe(const pubsub::ChannelName channel, pubsub::BasicDeliverCallbackInterface< SimulationEventType > &callback)
wrapper for subscribe method of PubSubSystem
pubsub::PubSubSystem * _pubsub
PubSubSystem being wrapped by this class.
void publish(const pubsub::ChannelName channel, const message::M2Message< SimulationEventType >::Ptr msg) const
wrapper for publish method of PubSubSystem
message::M2Message< SimulationEventType >::Ptr transformToM2etisMessage(message::NetworkMessage< net::NetworkType< net::OMNET >>::Ptr msg, const pubsub::ChannelName chan)
method to create M2Message out of a NetworkMessage
void unsubscribe(const pubsub::ChannelName channel) const
wrapper for unsubscribe method of PubSubSystem
message::M2Message< SimulationEventType >::Ptr createMessage(const pubsub::ChannelName channel, const SimulationEventType &v)
method to create a message for the specified channel with the given payload
class for accessing the m2etis pub/sub system. It is the main entry point for the usage of the m2etis...
Definition: PubSubSystem.h:60
message::NetworkMessage< net::NetworkType< net::OMNET > >::Ptr transformToNetworkMessage(message::M2Message< SimulationEventType >::Ptr msg, const pubsub::ChannelName chan)
method to create NetworkMessage out of a M2Message