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::AgentPropertyManipulator Class Referenceabstract

Base class for manipulating agent properties in an undoable manner. The undo is limited, it only maintains knowledge of one manipulation. If multiple manipulations are applied, only the last can be undone. More...

#include <AgentPropertyManipulator.h>

Inheritance diagram for Menge::AgentPropertyManipulator:
Menge::Element Menge::OffsetPropertyManipulator Menge::ScalePropertyManipulator Menge::SetPropertyManipulator

Public Member Functions

 AgentPropertyManipulator ()
 Constructor.
 
void manipulate (Agents::BaseAgent *agent)
 Applies the manipulation to the given agent, storing the previous state for restoration. More...
 
void restore (Agents::BaseAgent *agent)
 Restores the agent's previous value. More...
 
void setGenerator (FloatGenerator *gen)
 Sets the generator for the manipulator. More...
 
void setProperty (BFSM::PropertyOperand prop)
 Sets the property operand. 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 ~AgentPropertyManipulator ()
 Virtual destructor.
 
virtual float newValue (float value, size_t agentID)=0
 Computes the new property value given the original property value. More...
 

Protected Attributes

FloatGenerator_operandGen
 The generator for determining the operand value.
 
BFSM::PropertyOperand _property
 The property to operate on.
 
std::map< size_t, float > _originalMap
 A mapping from agent id to the agent's property value before the action was applied.
 
SimpleLock _lock
 Lock for guaranteeing thread-safety.
 

Detailed Description

Base class for manipulating agent properties in an undoable manner. The undo is limited, it only maintains knowledge of one manipulation. If multiple manipulations are applied, only the last can be undone.

Member Function Documentation

void Menge::AgentPropertyManipulator::manipulate ( Agents::BaseAgent agent)

Applies the manipulation to the given agent, storing the previous state for restoration.

Parameters
agentThe agent to manipulate.
virtual float Menge::AgentPropertyManipulator::newValue ( float  value,
size_t  agentID 
)
protectedpure virtual

Computes the new property value given the original property value.

Parameters
valueThe original value of the property.
agentIDThe identifier for the agent.
Returns
The new value.

Implemented in Menge::ScalePropertyManipulator, Menge::OffsetPropertyManipulator, and Menge::SetPropertyManipulator.

void Menge::AgentPropertyManipulator::restore ( Agents::BaseAgent agent)

Restores the agent's previous value.

If there is no previous value for the provided agent, nothing happens.

Parameters
agentThe agent whose property value should be restored.
void Menge::AgentPropertyManipulator::setGenerator ( FloatGenerator gen)

Sets the generator for the manipulator.

Parameters
genThe generator to assign to this manipulator. Any previous generator will be destroyed and it is assumed that the generator is not shared with any other entity.
void Menge::AgentPropertyManipulator::setProperty ( BFSM::PropertyOperand  prop)
inline

Sets the property operand.

Parameters
propThe property to operate on.

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