Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Menge::BFSM::GoalSelector Class Referenceabstract

The base, abstract class for selecting per-agent goals. More...

#include <GoalSelector.h>

Inheritance diagram for Menge::BFSM::GoalSelector:
Menge::Element Menge::BFSM::ExplicitGoalSelector Menge::BFSM::IdentityGoalSelector Menge::BFSM::MirrorGoalSelector Menge::BFSM::OffsetGoalSelector Menge::BFSM::SetGoalSelector Menge::BFSM::SharedGoalSelector Menge::BFSM::FarthestGoalSelector Menge::BFSM::FarthestNMGoalSelector Menge::BFSM::NearestGoalSelector Menge::BFSM::NearestNMGoalSelector Menge::BFSM::RandomGoalSelector Menge::BFSM::WeightedGoalSelector

Public Member Functions

 GoalSelector ()
 Default constructor.
 
GoalassignGoal (const Agents::BaseAgent *agent)
 Uses the goal selector to assign a goal to the given agent. More...
 
void freeGoal (const Agents::BaseAgent *agent, Goal *goal)
 Informs the goal selector that the agent is done with the goal. More...
 
virtual GoalgetGoal (const Agents::BaseAgent *agent) const =0
 Interface function for acquiring per-agent goals. More...
 
virtual void setGoalSet (std::map< size_t, GoalSet * > &goalSets)
 Gives the instance the opportunity to set the goal set. More...
 
void setPersistence (bool state)
 Sets the persistence of the goal. More...
 
bool getPersistence () const
 Reports the persistence of the goal. More...
 
- Public Member Functions inherited from Menge::Element
void destroy ()
 This supplants the destructor. More...
 
virtual BFSM::TaskgetTask ()
 Return an optional task associated with this element. More...
 
virtual SceneGraph::GLNodegetSGNode ()
 Returns an optional visualization element associated with the element. More...
 

Protected Member Functions

virtual ~GoalSelector ()
 Default virtual destructor.
 
virtual void lockResources ()
 Allows the goal selector to lock any resources it requires. More...
 
virtual void releaseResources ()
 Allows the goal selector to release previously locked resources. More...
 

Protected Attributes

bool _persistent
 Determines if the GoalSelector maintains persistent goals. More...
 
HASH_MAP< size_t, Goal * > _assignedGoals
 A mapping from agent id to assigned goals. This will only contain meaningful values in one of two cases: More...
 
ReadersWriterLock _lock
 The lock to maintain readers-writer access to the _assignedGoals.
 

Detailed Description

The base, abstract class for selecting per-agent goals.

Member Function Documentation

Goal * Menge::BFSM::GoalSelector::assignGoal ( const Agents::BaseAgent agent)

Uses the goal selector to assign a goal to the given agent.

This is the main interface for assiging goals to agents (while maintaing bookkeping for capacity and persistence.) It calls the GoalSelector::getGoal method to actually determine which goal is to be assigned.

Parameters
agentThe agent for whom a goal is assigned.
Returns
A pointer to the assigned goal.
void Menge::BFSM::GoalSelector::freeGoal ( const Agents::BaseAgent agent,
Goal goal 
)

Informs the goal selector that the agent is done with the goal.

The behavior of this function depends on the persistence of the goal selector. If the goal selector is persistent, the goal will not actually be freed and capacity will remain as indicated. If it is not persistent, the goal's capacity will be freed up.

Parameters
agentThe agent who is finished using the goal.
goalThe goal the agent was previously assigned.
virtual Goal* Menge::BFSM::GoalSelector::getGoal ( const Agents::BaseAgent agent) const
pure virtual
bool Menge::BFSM::GoalSelector::getPersistence ( ) const
inline

Reports the persistence of the goal.

Returns
True if the goal selector is persistent, false otherwise.
virtual void Menge::BFSM::GoalSelector::lockResources ( )
inlineprotectedvirtual

Allows the goal selector to lock any resources it requires.

This is primarily here so that GoalSelectors which use shared resources have a chance to lock them (see SetGoalSelector). A call to lockResources should always be followed by a call to releeaseResources.

Reimplemented in Menge::BFSM::SetGoalSelector.

virtual void Menge::BFSM::GoalSelector::releaseResources ( )
inlineprotectedvirtual

Allows the goal selector to release previously locked resources.

Should be used in conjunction with lockResources.

Reimplemented in Menge::BFSM::SetGoalSelector.

virtual void Menge::BFSM::GoalSelector::setGoalSet ( std::map< size_t, GoalSet * > &  goalSets)
inlinevirtual

Gives the instance the opportunity to set the goal set.

This does nothing for instances which don't require a goal set. Otherwise, it extracts its required goal set.

Parameters
goalSetsA mapping from goal set identifier to goal set pointers.

Reimplemented in Menge::BFSM::ExplicitGoalSelector, and Menge::BFSM::SetGoalSelector.

void Menge::BFSM::GoalSelector::setPersistence ( bool  state)
inline

Sets the persistence of the goal.

Parameters
stateThe new persistence state.

Member Data Documentation

HASH_MAP< size_t, Goal * > Menge::BFSM::GoalSelector::_assignedGoals
protected

A mapping from agent id to assigned goals. This will only contain meaningful values in one of two cases:

  • If the selector is persistent.
  • If compiled in debug mode (and then node freeing will be tested against this map).
bool Menge::BFSM::GoalSelector::_persistent
protected

Determines if the GoalSelector maintains persistent goals.

If the goal selector is persistent, it means that when an agent leaves the state with the corresponding goal selector, the goal is not released and if the agent returns to the state, it receives its previous goal.


The documentation for this class was generated from the following files: