Menge
Modular Pedestrian Simulation Framework for Research and Development
|
The base, abstract class for selecting per-agent goals. More...
#include <GoalSelector.h>
Public Member Functions | |
GoalSelector () | |
Default constructor. | |
Goal * | assignGoal (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 Goal * | getGoal (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::Task * | getTask () |
Return an optional task associated with this element. More... | |
virtual SceneGraph::GLNode * | getSGNode () |
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. | |
The base, abstract class for selecting per-agent goals.
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.
agent | The agent for whom a goal is assigned. |
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.
agent | The agent who is finished using the goal. |
goal | The goal the agent was previously assigned. |
|
pure virtual |
Interface function for acquiring per-agent goals.
agent | The agent for whom a goal is extracted. |
Implemented in Menge::BFSM::SharedGoalSelector, Menge::BFSM::OffsetGoalSelector, Menge::BFSM::ExplicitGoalSelector, Menge::BFSM::MirrorGoalSelector, Menge::BFSM::FarthestNMGoalSelector, Menge::BFSM::NearestNMGoalSelector, Menge::BFSM::IdentityGoalSelector, Menge::BFSM::FarthestGoalSelector, Menge::BFSM::NearestGoalSelector, Menge::BFSM::RandomGoalSelector, and Menge::BFSM::WeightedGoalSelector.
|
inline |
Reports the persistence of the goal.
|
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.
|
inlineprotectedvirtual |
Allows the goal selector to release previously locked resources.
Should be used in conjunction with lockResources.
Reimplemented in Menge::BFSM::SetGoalSelector.
|
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.
goalSets | A mapping from goal set identifier to goal set pointers. |
Reimplemented in Menge::BFSM::ExplicitGoalSelector, and Menge::BFSM::SetGoalSelector.
|
inline |
Sets the persistence of the goal.
state | The new persistence state. |
|
protected |
A mapping from agent id to assigned goals. This will only contain meaningful values in one of two cases:
|
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.