Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FSMDescrip.h
Go to the documentation of this file.
1 /*
2 
3 License
4 
5 Menge
6 Copyright and trademark 2012-14 University of North Carolina at Chapel Hill.
7 All rights reserved.
8 
9 Permission to use, copy, modify, and distribute this software and its documentation
10 for educational, research, and non-profit purposes, without fee, and without a
11 written agreement is hereby granted, provided that the above copyright notice,
12 this paragraph, and the following four paragraphs appear in all copies.
13 
14 This software program and documentation are copyrighted by the University of North
15 Carolina at Chapel Hill. The software program and documentation are supplied "as is,"
16 without any accompanying services from the University of North Carolina at Chapel
17 Hill or the authors. The University of North Carolina at Chapel Hill and the
18 authors do not warrant that the operation of the program will be uninterrupted
19 or error-free. The end-user understands that the program was developed for research
20 purposes and is advised not to rely exclusively on the program for any reason.
21 
22 IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE AUTHORS
23 BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
24 DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
25 DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE
26 AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS SPECIFICALLY
29 DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY STATUTORY WARRANTY
31 OF NON-INFRINGEMENT. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
32 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS HAVE NO OBLIGATIONS
33 TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
34 
35 Any questions or comments should be sent to the authors {menge,geom}@cs.unc.edu
36 
37 */
38 
44 #ifndef __CONFIG_H__
45 #define __CONFIG_H__
46 
47 #include <string>
48 #include <map>
49 #include <list>
50 
51 #include "fsmCommon.h"
52 
53 
54 // Configuration description classes
55 #include "StateDescrip.h"
57 #include "resources/VectorField.h"
58 
59 #include "Logger.h"
60 #include "os.h"
61 #include "tinyxml.h"
62 
63 
64 namespace Menge {
65 
66  // forward declarations
67  namespace Agents {
68  class SimulatorInterface;
69  }
70 
71  namespace BFSM {
72  // Forward declaration
73  class FSM;
74  class GoalSet;
75  class Task;
76  class State;
77  class Transition;
78  class StateDescrip;
79  class VelModifier;
80 
84  class FSMDescrip {
85  public:
89  FSMDescrip();
90 
94  ~FSMDescrip();
95 
108  State * addState( StateDescrip * sData );
109 
118  bool loadFromXML( const std::string & xmlName, bool verbose );
119 
128  friend FSM * buildFSM( FSMDescrip & fsmDescrip, Agents::SimulatorInterface * sim, bool VERBOSE );
129 
137  friend Logger & operator<<( Logger & out, const FSMDescrip & fsmDescrip );
138 
139  protected:
140 
149  void addTransition( const std::string & name, Transition * trans );
150 
154  std::list< StateDescrip * > _states;
155 
159  std::map< std::string, std::list< Transition * > > _transitions;
160 
164  std::map< std::string, State * > _stateNameMap;
165 
169  std::list< Task * > _tasks;
170 
177  std::map< size_t, GoalSet * > _goalSets;
178 
182  std::vector< VelModifier * > _velModifiers;
183 
187  std::string _behaviorFldr;
188 
189  };
190  } // namespace BFSM
191 } // namespace Menge
192 
193 #endif // __CONFIG_H__
The transition between BFSM states.
Definition: Transition.h:67
The basic state of the behavior finite state machine.
Definition: State.h:123
bool loadFromXML(const std::string &xmlName, bool verbose)
Initializes the configuration from an xml file.
Definition: FSMDescrip.cpp:109
std::list< StateDescrip * > _states
List of state descriptions.
Definition: FSMDescrip.h:154
The full description of the behavioral finite state machine.
Definition: FSMDescrip.h:84
The state (and state goal) specification in the behavior configuration file.
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
The basic class for all on-disk resources.
The description of a state (see State).
Definition: StateDescrip.h:70
std::list< Task * > _tasks
A map from agent class id to a behavior description instance.
Definition: FSMDescrip.h:169
The basic simulator interface required by the fsm.
Definition: SimulatorInterface.h:66
An html logger - writes messages to a formatted html file.
Definition: Logger.h:59
FSMDescrip()
Default constructor.
Definition: FSMDescrip.cpp:64
The specificaiton of a message logger for menge, such that all messages to the system get properly re...
std::vector< VelModifier * > _velModifiers
A list of velocity modifiers to be applied to all states in the simulator.
Definition: FSMDescrip.h:182
~FSMDescrip()
Destructor.
Definition: FSMDescrip.cpp:69
Various operating-system-dependent file-system operations.
std::map< std::string, std::list< Transition * > > _transitions
List of transitions.
Definition: FSMDescrip.h:159
Templated class for the behavior finite state machine.
Definition: FSM.h:126
State * addState(StateDescrip *sData)
Instantiates a state based on the description.
Definition: FSMDescrip.cpp:96
The namespace contains the Behavior Finite State Machine (BFSM) definition.
The definition of a 2D vector field.
Collection of convenient pre-compiler information for fsm definitions.
void addTransition(const std::string &name, Transition *trans)
Adds the transition(s) associated with the given name.
Definition: FSMDescrip.cpp:212
std::map< size_t, GoalSet * > _goalSets
A mapping of goal sets to goals. The goal sets are represented by their id. The goals for each goal s...
Definition: FSMDescrip.h:177
std::string _behaviorFldr
The folder in which the behavior specification file appears.
Definition: FSMDescrip.h:187
friend FSM * buildFSM(FSMDescrip &fsmDescrip, Agents::SimulatorInterface *sim, bool VERBOSE)
Creates an FSM instance from the config file.
Definition: buildFSM.cpp:72
friend Logger & operator<<(Logger &out, const FSMDescrip &fsmDescrip)
Friend operator for printing the behavior configuration to an output stream.
Definition: FSMDescrip.cpp:227
std::map< std::string, State * > _stateNameMap
Map of state names to states.
Definition: FSMDescrip.h:164
The namespace that contains the basic simulation mechanisms.