AbstractMsgQueue.h

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #ifndef ABSTRACT_MSG_QUEUE_H_
00004 #define ABSTRACT_MSG_QUEUE_H_
00005 
00006 #include <fesa-core/Core/AbstractEquipment.h>
00007 #include <fesa-core/Utilities/ProcessConfiguration.h>
00008 
00009 namespace fesa
00010 {
00011 
00012 class AbstractMessage;
00013 
00018 typedef enum
00019 {
00020     LOCAL_MSG_QUEUE, IPC_MSG_QUEUE
00021 } MQ_TYPE;
00022 
00027 const uint32_t HIGH_MQ_PRIO = 10;
00028 const uint32_t DEFAULT_MQ_PRIO = 9;
00029 const uint32_t LOW_MQ_PRIO = 8;
00030 
00037 class AbstractMsgQueue
00038 {
00039 
00040   public:
00041 
00046     class Constants
00047     {
00048       public:
00049 
00053         uint32_t msg_size_max_;
00054 
00058         uint32_t msg_num_max_;
00059 
00063         uint32_t queue_diag_slots;
00064 
00068         Constants()
00069         {
00070             const ProcessConfiguration* configuration = AbstractEquipment::getInstance()->getProcessConfiguration();
00071             msg_size_max_ = configuration->getIntValue(PropertyTag::MSG_SIZE_MAX);
00072             msg_num_max_ = configuration->getIntValue(PropertyTag::MSG_NUM_MAX);
00073             queue_diag_slots = configuration->getIntValue(PropertyTag::MSG_DIAG_SLOTS);
00074         }
00075     };
00076 
00080     const Constants constants_;
00081 
00089     AbstractMsgQueue(const std::string& name, MQ_TYPE type, uint32_t queueLength);
00090 
00094     virtual ~AbstractMsgQueue();
00095 
00100     virtual uint32_t isFull();
00101 
00106     virtual uint32_t isAlmostFull();
00107 
00113     virtual const std::string& getQueueName();
00114 
00119     virtual uint32_t getQueueLength();
00120 
00126     virtual void postMsg(AbstractMessage* msg) = 0;
00127 
00133     virtual AbstractMessage* consumeMsg() = 0;
00134 
00138     virtual void purge() = 0;
00139 
00144     virtual uint32_t getCurrentMsgCount() = 0;
00145 
00151     virtual void checkState(uint32_t msgPrio);
00152 
00153   protected:
00154 
00158     std::string queueName_;
00159 
00163     MQ_TYPE queueType_;
00164 
00168     const uint32_t queueLength_;
00169 
00170   private:
00171 
00175     AbstractMsgQueue(const AbstractMsgQueue&);
00176 
00180     AbstractMsgQueue& operator=(const AbstractMsgQueue&);
00181 };
00182 
00183 inline const std::string& AbstractMsgQueue::getQueueName()
00184 {
00185     return queueName_;
00186 }
00187 
00188 inline uint32_t AbstractMsgQueue::getQueueLength()
00189 {
00190     return queueLength_;
00191 }
00192 
00193 } // fesa
00194 
00195 #endif //ABSTRACT_MSG_QUEUE_H_
00196 

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1