MessageTypes.h

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #ifndef MESSAGE_TYPES_H_
00004 #define MESSAGE_TYPES_H_
00005 
00006 #include <fesa-core/Core/FesaDefs.h>
00007 #include <fesa-core/Synchronization/MultiplexingContext.h>
00008 
00009 #include <string>
00010 #include <vector>
00011 #include <map>
00012 
00013 namespace fesa
00014 {
00018 const uint32_t MSG_DATA_SIZE_MAX = 8192;
00019 const std::string NUMBER_SEPARATOR = " ";
00020 const std::string STRING_SEPARATOR = "\n";
00021 
00025 typedef enum MessageType
00026 {
00027         AutomaticNotificationMsg, ManualNotificationMsg, CommandMsg, OnDemandMsg
00028 }MessageType;
00029 
00034 class AbstractMessage
00035 {
00036   public:
00037 
00043     bool operator<(const AbstractMessage& msg) const;
00044 
00049     virtual void serialize(std::ostream& stream);
00050 
00054     AbstractMessage(uint32_t prio, MessageType msgType);
00055 
00060     AbstractMessage(std::istream& stream, MessageType msgType);
00061 
00065     virtual ~AbstractMessage();
00066 
00070     uint32_t prio_;
00071 
00075     MessageType msgType_;
00076 };
00077 
00078 inline bool AbstractMessage::operator<(const AbstractMessage& msg) const
00079 {
00080     return prio_ < msg.prio_;
00081 }
00082 
00087 class AutomaticNotificationMessage: public AbstractMessage
00088 {
00089         public:
00090 
00094                 uint32_t notificationID_;
00095 
00099                 MultiplexingContext* muxContext_;
00100 
00106                 void serialize(std::ostream& stream);
00107 
00115                 AutomaticNotificationMessage(const uint32_t& notificationID, MultiplexingContext* muxContext,
00116                                                 uint32_t& prio);
00117 
00122                 AutomaticNotificationMessage(std::istream& stream);
00123 };
00124 
00129 class ManualNotificationMessage: public AbstractMessage
00130 {
00131         public:
00132 
00136                 std::string className_;
00137 
00142                 MultiplexingContext* muxContext_;
00143 
00148                 std::map<std::string, std::vector<std::string> > propertiesAndDevicesCol_;
00149 
00158                 void serialize(std::ostream& stream);
00159 
00164                 void addPropertyAndDevice(const std::string& property, const std::string& device);
00165 
00169                 void reset();
00170 
00175                 ManualNotificationMessage(const std::string& className);
00176 
00181                 ManualNotificationMessage(std::istream& stream);
00182 };
00183 
00188 class CommandMessage: public AbstractMessage
00189 {
00190         public:
00191 
00195                 std::string command_;
00196 
00200                 std::string parameter1_;
00201 
00205                 std::string parameter2_;
00206 
00211                 void serialize(std::ostream& stream);
00212 
00220                 CommandMessage(const std::string& command, const std::string& parameter1, const std::string& parameter2,
00221                                                 uint32_t& prio);
00222 
00227                 CommandMessage(std::istream& stream);
00228 };
00229 
00234 class OnDemandMessage: public AbstractMessage
00235 {
00236         public:
00237 
00238                 std::string cycleName_;
00239 
00240                 uint32_t payloadSize_;
00241 
00242                 char* payload_;
00243 
00248                 void serialize(std::ostream& stream);
00249 
00257                 OnDemandMessage(const std::string& cycleName, const char* payload, uint32_t payloadSize, uint32_t& prio);
00262                 OnDemandMessage(const OnDemandMessage& msg);
00263 
00268                 OnDemandMessage(std::istream& stream);
00269 
00273                 ~OnDemandMessage();
00274 };
00275 
00276 }//fesa
00277 
00278 
00279 #endif // MESSAGE_TYPES_H_

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1