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

IDEA::ReactivePlannerImpl Class Reference

#include <ReactivePlannerImpl.hh>

Inheritance diagram for IDEA::ReactivePlannerImpl:

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

Public Methods

 ReactivePlannerImpl (const std::string &name, const PslDatabase *database, const AgentTimingService *ats, const std::string &heuristicFile, bool readHeuristicsFile, const std::string &noBranchFile, bool readNoBranchFile)
 Constructor.

virtual ~ReactivePlannerImpl ()
 Destructor.

const FreeStrategygetFreeStrategy () const
 Returns the strategy to use when we free a token.

void addRevocableAuthority (int authority)
 Adds authority to the set of authorities of constraints which the invoking planner can revoke.

bool isRevocable (int authority) const
 Returns true if the invoking planner can revoke constraints with authority authority.

int getAuthority ()
 Returns the authority of the planner of the invoking reactive planner.

void setFreeGoalTokens ()
 Invoking this method will enable the freeing of goal-tokens in case of a recovery.

void stopReacting ()
 Stops the reactive planner as soon as possible if it is reacting.

virtual StatusType startReacting (const Time &time)
 Starts a reactive planner cycle for tick time.

void setForgettingThePast (bool value)
const PslDatabasegetDatabase () const
const AgentTimingServicegetAgentTimingService () const
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

const IntSetgetRevocableAuthorities () const
const PlannergetPlanner () const
bool freeGoalTokens () const
 Returns true if the invoking reactive planner should free goal tokens in case of an attempt recovery. Otherwise returns false.

void finalizeTokens ()
void scheduleForFinalization (const PslToken *token)
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.

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 updateUserDefinedMessage (const Time &time, const MessageData *data)
 Invoked when a user-defined-message is being updated.

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 determineDisablement (const PslToken *token, const PslTokenList &tokens)
StatusType attemptRecovery (const Time &time)
 Attempt to recover from a violated convention or inconsistent database.

int initialize ()
 Invoked by activate and creates the planner.

virtual void getFutureTokens (const PslTimeline *timeline, PslTokenList &tokensExecuting, PslTokenList &tokensInTheFuture) const
 Queries the tokens on timeline timeline and will store tokens which are scheduled completely in the futur in tokensInTheFuture and the tokens which is currently executing in tokensExecuting.

virtual StatusType free (const PslToken *pslTok)
 Frees token pslTok.

virtual StatusType relax (const PslToken *pslTok)
 Relaxes token pslTok.

StatusType preProcessPlanning ()
StatusType postProcessPlanning ()
StatusType preProcessExecutingTokens (PslTokenList &tokens)
 Iterates over all tokens in tokens and invokes updateControllableToken on the token if it is controllable and invokes updateUncontrollableToken if the token is uncontrollable.

StatusType postProcessExecutingTokens (PslTokenList &tokens)
StatusType preProcessControllableToken (const PslToken *token)
StatusType preProcessUncontrollableToken (const PslToken *token, const PslTokenList &controllableTokens)

Private Attributes

IntSet m_RevocableAuthorities
Plannerm_Planner
FreeStrategy m_FreeStrategy
bool m_FreeGoalTokens
PslTokenList m_ExecutingTokens
bool m_StopPlanner
std::string m_HeuristicFile
bool m_ReadHeuristicsFile
std::string m_NoBranchFile
bool m_ReadNoBranchFile

Friends

class ReactivePlanner

Detailed Description

class ReactivePlannerImpl


Member Typedef Documentation

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


Constructor & Destructor Documentation

IDEA::ReactivePlannerImpl::ReactivePlannerImpl const std::string &    name,
const PslDatabase   database,
const AgentTimingService   ats,
const std::string &    heuristicFile,
bool    readHeuristicsFile,
const std::string &    noBranchFile,
bool    readNoBranchFile
 

Constructor.

IDEA::ReactivePlannerImpl::~ReactivePlannerImpl   [virtual]
 

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::ReactivePlannerImpl::addRevocableAuthority int    authority
 

Adds authority to the set of authorities of constraints which the invoking planner can revoke.

StatusType IDEA::ReactivePlannerImpl::attemptRecovery const Time   time [private]
 

Attempt to recover from a violated convention or inconsistent database.

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

De-activates the invoking message-observer.

void IDEA::ReactivePlannerImpl::determineDisablement const PslToken   token,
const PslTokenList   tokens
[private]
 

void IDEA::DefaultReactor::finalizeTokens   [protected, inherited]
 

StatusType IDEA::ReactivePlannerImpl::free const PslToken   pslTok [private, virtual]
 

Frees token pslTok.

Reimplemented in IDEA::PlasmaReactivePlannerImpl.

bool IDEA::ReactivePlannerImpl::freeGoalTokens   [protected]
 

Returns true if the invoking reactive planner should free goal tokens in case of an attempt recovery. Otherwise returns false.

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

Returns the current AcceptorPolicy of the invoking observer.

const AgentTimingService * IDEA::DefaultReactor::getAgentTimingService   [inherited]
 

int IDEA::ReactivePlannerImpl::getAuthority  
 

Returns the authority of the planner of the invoking reactive planner.

const PslDatabase * IDEA::DefaultReactor::getDatabase   [inherited]
 

const FreeStrategy & IDEA::ReactivePlannerImpl::getFreeStrategy  
 

Returns the strategy to use when we free a token.

void IDEA::ReactivePlannerImpl::getFutureTokens const PslTimeline   timeline,
PslTokenList   tokensExecuting,
PslTokenList   tokensInTheFuture
const [private, virtual]
 

Queries the tokens on timeline timeline and will store tokens which are scheduled completely in the futur in tokensInTheFuture and the tokens which is currently executing in tokensExecuting.

Reimplemented in IDEA::PlasmaReactivePlannerImpl.

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.

const Planner * IDEA::ReactivePlannerImpl::getPlanner   [protected]
 

const IntSet & IDEA::ReactivePlannerImpl::getRevocableAuthorities   [protected]
 

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.

int IDEA::ReactivePlannerImpl::initialize   [private, virtual]
 

Invoked by activate and creates the planner.

Reimplemented from IDEA::MessageObserver.

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

Returns true if the invoking observer is active otherwise false.

bool IDEA::ReactivePlannerImpl::isRevocable int    authority const
 

Returns true if the invoking planner can revoke constraints with authority authority.

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.

StatusType IDEA::ReactivePlannerImpl::postProcessExecutingTokens PslTokenList   tokens [private]
 

StatusType IDEA::ReactivePlannerImpl::postProcessPlanning   [private]
 

StatusType IDEA::ReactivePlannerImpl::preProcessControllableToken const PslToken   token [private]
 

StatusType IDEA::ReactivePlannerImpl::preProcessExecutingTokens PslTokenList   tokens [private]
 

Iterates over all tokens in tokens and invokes updateControllableToken on the token if it is controllable and invokes updateUncontrollableToken if the token is uncontrollable.

StatusType IDEA::ReactivePlannerImpl::preProcessPlanning   [private]
 

StatusType IDEA::ReactivePlannerImpl::preProcessUncontrollableToken const PslToken   token,
const PslTokenList   controllableTokens
[private]
 

StatusType IDEA::ReactivePlannerImpl::relax const PslToken   pslTok [private, virtual]
 

Relaxes token pslTok.

Reimplemented in IDEA::PlasmaReactivePlannerImpl.

void IDEA::DefaultReactor::scheduleForFinalization const PslToken   token [protected, inherited]
 

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.

void IDEA::DefaultReactor::setForgettingThePast bool    value [inherited]
 

void IDEA::ReactivePlannerImpl::setFreeGoalTokens  
 

Invoking this method will enable the freeing of goal-tokens in case of a recovery.

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::ReactivePlannerImpl::startReacting const Time   time [virtual]
 

Starts a reactive planner cycle for tick time.

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.

void IDEA::ReactivePlannerImpl::stopReacting  
 

Stops the reactive planner as soon as possible if it is reacting.

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.

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::MessageObserver::updateUserDefinedMessage const Time   time,
const MessageData   data
[protected, virtual, inherited]
 

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

To be implemented in the specialization.

Reimplemented in IDEA::BoomerangRelay, and IDEA::SimulatorResponseScheduler.


Friends And Related Function Documentation

friend class ReactivePlanner [friend]
 

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.

PslTokenList IDEA::ReactivePlannerImpl::m_ExecutingTokens [private]
 

bool IDEA::ReactivePlannerImpl::m_FreeGoalTokens [private]
 

FreeStrategy IDEA::ReactivePlannerImpl::m_FreeStrategy [private]
 

std::string IDEA::ReactivePlannerImpl::m_HeuristicFile [private]
 

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

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

Name of the invoking observer.

std::string IDEA::ReactivePlannerImpl::m_NoBranchFile [private]
 

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).

Planner* IDEA::ReactivePlannerImpl::m_Planner [private]
 

bool IDEA::ReactivePlannerImpl::m_ReadHeuristicsFile [private]
 

bool IDEA::ReactivePlannerImpl::m_ReadNoBranchFile [private]
 

IntSet IDEA::ReactivePlannerImpl::m_RevocableAuthorities [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::ReactivePlannerImpl::m_StopPlanner [private]
 

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:48 2006 for IDEA.