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

IDEA::SimulatorResponseScheduler Class Reference
[Simulator]

This class will handle the incomming messages from differentd agent and schedule responses. More...

#include <SimMsgRcvObs.hh>

Inheritance diagram for IDEA::SimulatorResponseScheduler:

IDEA::Reactor IDEA::MessageObserver List of all members.

Public Methods

 SimulatorResponseScheduler (Simulator *simulator, const std::string &name)
 Constructor.

 ~SimulatorResponseScheduler ()
 Destructor.

StatusType startReacting (const Time &time)
const std::string & getName () const
 Returns the name of the invoking observer.

bool hasPendingMessages ()
 Returns true if the invoking observer has pending messages in the queue.

int getNrOfPendingMessages ()
 Returns the number of pending messages in the queue.

UpdatePolicysetUpdatePolicy (UpdatePolicy *policy, bool deleteInst=false)
 Sets the update-policy to policy and will delete the old one if it was constructed by the constructor of the invoking observer or if it was set with deleteInst true.

UpdatePolicygetUpdatePolicy () const
 Returns the current UpdatePolicy of the invoking observer.

AcceptorPolicysetAcceptorPolicy (AcceptorPolicy *policy, bool deleteInst=false)
 Sets the acceptor-policy to policy and will delete the old one if it was constructed by the constructor of the invoking observer or if it was set with deleteInst true.

AcceptorPolicygetAcceptorPolicy () const
 Returns the current AcceptorPolicy of the invoking observer.

virtual void startUpdating ()
 Forces the invoking observer to start updating any of the messages in the queue using the UpdatePolicy of the invoking observer.

bool isUpdating () const
 Returns true if the invoking observer is in the process of updating messages in the queue, otherwise returns false.

bool isActive () const
 Returns true if the invoking observer is active otherwise false.

bool updatesInSeperateThread () const
 Returns true if the invoking observer will update messages in a seperate thread. Otherwise returns false.


Protected Types

typedef ACE_Thread_Condition<
ThreadMutex
ConditionVariable

Protected Methods

void updateStartMessage (const Time &time, const StartMessageData *data)
 Invoked when a start-message is being updated.

void updateUserDefinedMessage (const Time &time, const MessageData *data)
 Invoked when a user-defined-message is being updated.

void updateObjectMessage (const Time &time, const ObjectMessageData *data)
 Invoked when a object-message is being updated.

void updateStopMessage (const Time &time, const StopMessageData *data)
 Invoked when a stop-message is being updated.

void updateStatusMessage (const Time &time, const StatusMessageData *data)
 Invoked when a status-message is being updated.

void updateValueMessage (const Time &time, const ValueMessageData *data)
 Invoked when a value-message is being updated.

int notify (MessageHandle message)
 Notifies the invoking observer that a message has been observed.

virtual int activate ()
 Activates the invoking message-observer.

virtual void deActivate ()
 De-activates the invoking message-observer.

virtual int initialize ()
 Hook for additional setup, should return -1 in case of failed initialization.

void updateInternal (const MessageHandle &message)
 Updates the message by checking type and extracting data and invoking the correct update method depending on the type.

virtual void updateTelemetryMessage (const Time &time, const TelemetryMessageData *data)
virtual void onQueueEmpty ()
 This method is invoked when the queue becomes empty. No signal is signalled at initialization (empty).

virtual void onQueueNonEmpty ()
 This method is invoked when the queue becomes non-empty.

int update ()
 Pops MessageHandle instance from the top of the queue and asks the UpdatePolicy if the message should be updated and if so will update based upon type of the message and release the handle when done.

int svc (void)
 Main thred function used when invoking class has been constructed with threaded option true.


Protected Attributes

MessageHandleQueue m_ObservedMessages
 A queue containing MessageHandle instance to be updated. The queue sorts the message conform the binary function latestTime (that is the top of the queue is the MessageHandle whose getTime is latest).

std::string m_Name
 Name of the invoking observer.

UpdatePolicym_UpdatePolicy
 Policy used for when to start updating and till what message in the queue.

bool m_DeleteUpdatePolicy
 Indicating if the destructor of the invoking observer should delete the update-policy.

bool m_Updating
 Indiates if the observer is updating messages.

bool m_Active
 Indicates if the invoking observer is active.

bool m_Threaded
 Boolean indicating if the messages will be udpated in a seperate thread.

ThreadMutex m_Mutex
ConditionVariablem_StartCondition
 If the invoking class runs it's own thread to update the messages this variable is used to notify the thread to start updating.

AcceptorPolicym_AcceptorPolicy
 Policy used for what message to accept to push in the queue.

bool m_DeleteAcceptorPolicy
 Indicating if the destructor of the invoking observer should delete the acceptor-policy.


Private Methods

void createAndScheduleResponses (const std::string &identifier, const Time &received, const MessageData *data, const Message::Type &type)

Private Attributes

Simulatorm_Simulator

Detailed Description

This class will handle the incomming messages from differentd agent and schedule responses.

class SimulatorResponseScheduler


Member Typedef Documentation

typedef ACE_Thread_Condition< ThreadMutex > IDEA::MessageObserver::ConditionVariable [protected, inherited]
 


Constructor & Destructor Documentation

IDEA::SimulatorResponseScheduler::SimulatorResponseScheduler Simulator   simulator,
const std::string &    name
 

Constructor.

IDEA::SimulatorResponseScheduler::~SimulatorResponseScheduler  
 

Destructor.


Member Function Documentation

int IDEA::MessageObserver::activate   [protected, virtual, inherited]
 

Activates the invoking message-observer.

release all the messages we did not update

void IDEA::SimulatorResponseScheduler::createAndScheduleResponses const std::string &    identifier,
const Time   received,
const MessageData   data,
const Message::Type   type
[private]
 

void IDEA::MessageObserver::deActivate   [protected, virtual, inherited]
 

De-activates the invoking message-observer.

AcceptorPolicy* IDEA::MessageObserver::getAcceptorPolicy   const [inline, inherited]
 

Returns the current AcceptorPolicy of the invoking observer.

const std::string& IDEA::MessageObserver::getName   const [inline, inherited]
 

Returns the name of the invoking observer.

int IDEA::MessageObserver::getNrOfPendingMessages   [inline, inherited]
 

Returns the number of pending messages in the queue.

UpdatePolicy* IDEA::MessageObserver::getUpdatePolicy   const [inline, inherited]
 

Returns the current UpdatePolicy of the invoking observer.

bool IDEA::MessageObserver::hasPendingMessages   [inherited]
 

Returns true if the invoking observer has pending messages in the queue.

Will take into account the logic of the UpdatePolicy, that is it will take the message at the top of the queue and check with the updatePolicy ( updateNextMessage( msg ) ) if it would be updated if we would invoke update. So there can be messages in the queue ( getNrOfPendingMessages() != 0 ) and this method returns false.

virtual int IDEA::MessageObserver::initialize   [inline, protected, virtual, inherited]
 

Hook for additional setup, should return -1 in case of failed initialization.

Reimplemented in IDEA::ReactivePlannerImpl, and IDEA::IPCRelay.

bool IDEA::MessageObserver::isActive   const [inline, inherited]
 

Returns true if the invoking observer is active otherwise false.

bool IDEA::MessageObserver::isUpdating   [inherited]
 

Returns true if the invoking observer is in the process of updating messages in the queue, otherwise returns false.

int IDEA::MessageObserver::notify MessageHandle    message [protected, inherited]
 

Notifies the invoking observer that a message has been observed.

virtual void IDEA::MessageObserver::onQueueEmpty   [inline, protected, virtual, inherited]
 

This method is invoked when the queue becomes empty. No signal is signalled at initialization (empty).

virtual void IDEA::MessageObserver::onQueueNonEmpty   [inline, protected, virtual, inherited]
 

This method is invoked when the queue becomes non-empty.

AcceptorPolicy * IDEA::MessageObserver::setAcceptorPolicy AcceptorPolicy   policy,
bool    deleteInst = false
[inherited]
 

Sets the acceptor-policy to policy and will delete the old one if it was constructed by the constructor of the invoking observer or if it was set with deleteInst true.

Returns the old acceptor-policy if it was not deleted otherwise 0.

The acceptor-policy is used to decide to accept messages when the invoking class is notified. Be aware the new policy will override the message-types to accept passed in the constructor of the invoking class.

UpdatePolicy * IDEA::MessageObserver::setUpdatePolicy UpdatePolicy   policy,
bool    deleteInst = false
[inherited]
 

Sets the update-policy to policy and will delete the old one if it was constructed by the constructor of the invoking observer or if it was set with deleteInst true.

Returns the old update-policy if it was not deleted otherwise 0.

The update-policy is used to trigger the updating of the messages.

StatusType IDEA::SimulatorResponseScheduler::startReacting const Time   time [inline]
 

void IDEA::MessageObserver::startUpdating   [virtual, inherited]
 

Forces the invoking observer to start updating any of the messages in the queue using the UpdatePolicy of the invoking observer.

int IDEA::MessageObserver::svc void    [protected, inherited]
 

Main thred function used when invoking class has been constructed with threaded option true.

int IDEA::MessageObserver::update   [protected, inherited]
 

Pops MessageHandle instance from the top of the queue and asks the UpdatePolicy if the message should be updated and if so will update based upon type of the message and release the handle when done.

Returns -1 in case of an error.

void IDEA::MessageObserver::updateInternal const MessageHandle   message [protected, inherited]
 

Updates the message by checking type and extracting data and invoking the correct update method depending on the type.

void IDEA::SimulatorResponseScheduler::updateObjectMessage const Time   time,
const ObjectMessageData   data
[inline, protected, virtual]
 

Invoked when a object-message is being updated.

To be implemented in the specialization.

Reimplemented from IDEA::MessageObserver.

bool IDEA::MessageObserver::updatesInSeperateThread   const [inline, inherited]
 

Returns true if the invoking observer will update messages in a seperate thread. Otherwise returns false.

void IDEA::SimulatorResponseScheduler::updateStartMessage const Time   time,
const StartMessageData   data
[protected, virtual]
 

Invoked when a start-message is being updated.

Reimplemented from IDEA::MessageObserver.

void IDEA::SimulatorResponseScheduler::updateStatusMessage const Time   time,
const StatusMessageData   data
[inline, protected, virtual]
 

Invoked when a status-message is being updated.

To be implemented in the specialization.

Reimplemented from IDEA::MessageObserver.

void IDEA::SimulatorResponseScheduler::updateStopMessage const Time   time,
const StopMessageData   data
[inline, protected, virtual]
 

Invoked when a stop-message is being updated.

To be implemented in the specialization.

Reimplemented from IDEA::MessageObserver.

void IDEA::MessageObserver::updateTelemetryMessage const Time   time,
const TelemetryMessageData   data
[protected, virtual, inherited]
 

Invoked when a telemetry-message is being updated.

To be implemented in the specialization.

Reimplemented in IDEA::BoomerangRelay, IDEA::DefaultReactor, and IDEA::IPCRelay.

void IDEA::SimulatorResponseScheduler::updateUserDefinedMessage const Time   time,
const MessageData   data
[protected, virtual]
 

Invoked when a user-defined-message is being updated.

In this context user-defined messages are messages of base type SimulatorMessage.

Reimplemented from IDEA::MessageObserver.

void IDEA::SimulatorResponseScheduler::updateValueMessage const Time   time,
const ValueMessageData   data
[inline, protected, virtual]
 

Invoked when a value-message is being updated.

To be implemented in the specialization.

Reimplemented from IDEA::MessageObserver.


Member Data Documentation

AcceptorPolicy* IDEA::MessageObserver::m_AcceptorPolicy [protected, inherited]
 

Policy used for what message to accept to push in the queue.

bool IDEA::MessageObserver::m_Active [protected, inherited]
 

Indicates if the invoking observer is active.

bool IDEA::MessageObserver::m_DeleteAcceptorPolicy [protected, inherited]
 

Indicating if the destructor of the invoking observer should delete the acceptor-policy.

bool IDEA::MessageObserver::m_DeleteUpdatePolicy [protected, inherited]
 

Indicating if the destructor of the invoking observer should delete the update-policy.

ThreadMutex IDEA::MessageObserver::m_Mutex [protected, inherited]
 

std::string IDEA::MessageObserver::m_Name [protected, inherited]
 

Name of the invoking observer.

MessageHandleQueue IDEA::MessageObserver::m_ObservedMessages [protected, inherited]
 

A queue containing MessageHandle instance to be updated. The queue sorts the message conform the binary function latestTime (that is the top of the queue is the MessageHandle whose getTime is latest).

Simulator* IDEA::SimulatorResponseScheduler::m_Simulator [private]
 

ConditionVariable* IDEA::MessageObserver::m_StartCondition [protected, inherited]
 

If the invoking class runs it's own thread to update the messages this variable is used to notify the thread to start updating.

bool IDEA::MessageObserver::m_Threaded [protected, inherited]
 

Boolean indicating if the messages will be udpated in a seperate thread.

UpdatePolicy* IDEA::MessageObserver::m_UpdatePolicy [protected, inherited]
 

Policy used for when to start updating and till what message in the queue.

bool IDEA::MessageObserver::m_Updating [protected, inherited]
 

Indiates if the observer is updating messages.


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