Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

/home/pauldt/projects/IDEA/IDEA-ALL/IDEA-DEV/Core/Agent/Includes/MessageObserver.hh

Go to the documentation of this file.
00001 // -*- Mode: c++ -*-
00002 //      CVS: $Id: MessageObserver.hh,v 1.4 2005/12/30 22:05:33 rijsman Exp $
00003 //      Tag: $name$
00004 //     Info: $CVSROOT/IDEA-DEV/COPYRIGHT
00005 
00006 #ifndef HEADER_MESSAGE_OBSERVER_BASE_HEADER__
00007 #define HEADER_MESSAGE_OBSERVER_BASE_HEADER__
00008 
00010 #include "Queue.hh"
00011 #include "MessageHandle.hh"
00012 
00013 namespace IDEA
00014 {
00015   class AcceptorPolicy;
00016   class StartMessageData;
00017   class StopMessageData;
00018   class ObjectMessageData;
00019   class StatusMessageData;
00020   class TelemetryMessageData;
00021   class UserdefinedMessage;
00022   class UpdatePolicy;
00023   class ValueMessageData;
00024 
00029   typedef ThreadSafeQueue<MessageHandle, std::vector< MessageHandle >, laterTime > MessageHandleQueue;
00030 
00063   class MessageObserver:
00064     public ACE_Task_Base
00065   {
00066     friend class AgentRelay;
00067     friend class ReactivePlanner;
00068   public:
00072     virtual ~MessageObserver();
00076     const std::string& getName() const { return m_Name; }
00084     bool hasPendingMessages();
00088     int getNrOfPendingMessages() { return m_ObservedMessages.size(); }
00098     UpdatePolicy* setUpdatePolicy( UpdatePolicy* policy, bool deleteInst = false );
00102     UpdatePolicy* getUpdatePolicy() const { return m_UpdatePolicy; }
00113     AcceptorPolicy* setAcceptorPolicy( AcceptorPolicy* policy, bool deleteInst = false );
00117     AcceptorPolicy* getAcceptorPolicy() const { return m_AcceptorPolicy; }
00121     virtual void startUpdating();
00125     bool isUpdating() const;
00129     bool isActive() const { return m_Active; }
00133     bool updatesInSeperateThread() const { return m_Threaded; }
00134   protected:
00150     MessageObserver( const std::string& name = "MessageObserver", 
00151                          bool threaded = false,
00152                          long subscribeToMessages = Message::START | Message::STOP | Message::VALUE | Message::STATUS | Message::TELEMETRY | Message::OBJECT | Message::USERDEFINED );
00156     int notify( MessageHandle message );
00160     virtual int activate();
00164     virtual void deActivate();
00168     virtual int initialize() { return 0; }
00173     void updateInternal( const MessageHandle& message );
00179     virtual void updateStartMessage( const Time& time, const StartMessageData* data  );
00185     virtual void updateStopMessage( const Time& time, const StopMessageData* data  );
00191     virtual void updateValueMessage( const Time& time, const ValueMessageData* data  );
00197     virtual void updateStatusMessage( const Time& time, const StatusMessageData* data  );
00203     virtual void updateObjectMessage( const Time& time, const ObjectMessageData* data  );
00209     virtual void updateTelemetryMessage( const Time& time, const TelemetryMessageData* data  );
00215     virtual void updateUserDefinedMessage( const Time& time, const MessageData* data  );
00219     virtual void onQueueEmpty() {}
00223     virtual void onQueueNonEmpty() {}
00230     int update();
00234     int svc(void);
00239     MessageHandleQueue m_ObservedMessages;  
00243     std::string m_Name;
00247     UpdatePolicy* m_UpdatePolicy;
00251     bool m_DeleteUpdatePolicy;
00255     bool m_Updating;
00259     bool m_Active;
00263     bool m_Threaded;
00264 
00265     ThreadMutex m_Mutex;
00266 
00267     typedef ACE_Thread_Condition< ThreadMutex > ConditionVariable;
00272     ConditionVariable* m_StartCondition;
00276     AcceptorPolicy* m_AcceptorPolicy;
00280     bool m_DeleteAcceptorPolicy;
00281   };
00282 
00283 } //namespace IDEA
00284 
00285 #endif //HEADER_MESSAGE_OBSERVER_BASE_HEADER__

Contact information
© IDEA
Generated on Fri Feb 3 17:09:40 2006 for IDEA.