Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TargetReturn.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 
45 #ifndef __TARGET_RETURN_H__
46 #define __TARGET_RETURN_H__
47 
48 #include "CoreConfig.h"
49 #include "Target.h"
50 #include "TargetFactory.h"
51 #include "fsmCommon.h"
52 #include "ReadersWriterLock.h"
53 #include <list>
54 
55 namespace Menge {
56 
57  namespace BFSM {
58 
59  // forward declarations
60  class State;
61  class ReturnTargetFactory;
62 
64 
75  class MENGE_API ReturnTarget : public TransitionTarget {
76  public:
80  ReturnTarget();
81 
87  ReturnTarget( const ReturnTarget & tgt);
88 
98  virtual void onEnter( Agents::BaseAgent * agent );
99 
105  virtual void onLeave( Agents::BaseAgent * agent );
106 
118  virtual State * nextState( Agents::BaseAgent * agent );
119 
129  virtual bool connectStates( std::map< std::string, State * > & stateMap );
130 
139  virtual TransitionTarget * copy();
140 
141  friend class ReturnTargetFactory;
142  protected:
146  std::map< size_t, State * > _targets;
147 
152 
153  };
154 
156 
160  class MENGE_API ReturnTargetFactory : public TargetFactory {
161  public:
170  virtual const char * name() const { return "return"; }
171 
179  virtual const char * description() const {
180  return "Defines the transition target as the state the agent was in when "\
181  "it advanced to this state.";
182  }
183 
184  protected:
195  virtual TransitionTarget * instance() const { return new ReturnTarget(); }
196  };
197 
198  } // namespace BFSM
199 } // namespace Menge
200 #endif // __TARGET_RETURN_H__
The base class for transition targets.
Definition: Target.h:77
The basic state of the behavior finite state machine.
Definition: State.h:123
std::map< size_t, State * > _targets
A mapping between an agent id and its return state.
Definition: TargetReturn.h:146
virtual const char * name() const
The name of the action.
Definition: TargetReturn.h:170
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
Sets up the proper compiler directives for platform and dll export/import.
The definition of a readers-writer lock.
Definition: ReadersWriterLock.h:62
ReadersWriterLock _lock
Lock to protect _targets;.
Definition: TargetReturn.h:151
The basis for determing what an active transition leads to.
The factory for creating the ReturnTarget.
Definition: TargetReturn.h:160
The definition of the return target.
Definition: TargetReturn.h:75
virtual const char * description() const
A description of the action.
Definition: TargetReturn.h:179
The definition of a readers-writer lock.
The namespace contains the Behavior Finite State Machine (BFSM) definition.
A class for parsing the xml description of a TransitionTarget and instantiating particular instances...
Definition: TargetFactory.h:61
Collection of convenient pre-compiler information for fsm definitions.
Defines the basic agent properties and functionality that all simulation agents share.
Definition: BaseAgent.h:123
virtual TransitionTarget * instance() const
Create an instance of this class's condition.
Definition: TargetReturn.h:195
The factory for parsing xml data for TransitionTarget and instantiating the appropriate class...