Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CondBoolean.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 __COND_BOOLEAN_H__
45 #define __COND_BOOLEAN_H__
46 
47 #include "CoreConfig.h"
48 #include "Condition.h"
49 #include "ConditionFactory.h"
50 
51 namespace Menge {
52 
53  namespace BFSM {
54 
55  // forward declarations
56  class Bool2CondFactory;
57 
59 
63  class MENGE_API Bool2Condition : public Condition {
64  public:
69 
75  Bool2Condition( const Bool2Condition & cond );
76 
77  protected:
81  virtual ~Bool2Condition();
82 
83  public:
93  virtual void onEnter( Agents::BaseAgent * agent );
94 
100  virtual void onLeave( Agents::BaseAgent * agent );
101 
102  friend class Bool2CondFactory;
103 
104  protected:
109 
114  };
115 
117 
121  class MENGE_API Bool2CondFactory : public ConditionFactory {
122  protected:
141  virtual bool setFromXML( Condition * condition, TiXmlElement * node, const std::string & behaveFldr ) const;
142  };
143 
145 
149  class MENGE_API AndCondition : public Bool2Condition {
150  public:
154  AndCondition();
155 
161  AndCondition( const AndCondition & cond );
162 
171  virtual bool conditionMet( Agents::BaseAgent * agent, const Goal * goal );
172 
181  virtual Condition * copy();
182  };
183 
185 
189  class MENGE_API AndCondFactory : public Bool2CondFactory {
190  public:
199  virtual const char * name() const { return "and"; }
200 
208  virtual const char * description() const {
209  return "The and condition. This condition depends on the evaluation of "\
210  "two child conditions. If both are met, this condition is met.";
211  }
212  protected:
223  virtual Condition * instance() const { return new AndCondition(); }
224  };
225 
227 
231  class MENGE_API OrCondition : public Bool2Condition {
232  public:
236  OrCondition();
237 
243  OrCondition( const OrCondition & cond );
244 
253  virtual bool conditionMet( Agents::BaseAgent * agent, const Goal * goal );
254 
263  virtual Condition * copy();
264  };
265 
267 
271  class MENGE_API OrCondFactory : public Bool2CondFactory {
272  public:
281  virtual const char * name() const { return "or"; }
282 
290  virtual const char * description() const {
291  return "The or condition. This condition depends on the evaluation of "\
292  "two child conditions. If either are met, this condition is met.";
293  }
294  protected:
305  virtual Condition * instance() const { return new OrCondition(); }
306  };
307 
309 
310  // forward declaration
311  class NotCondFactory;
312 
316  class MENGE_API NotCondition : public Condition {
317  public:
321  NotCondition();
322 
328  NotCondition( const NotCondition & cond );
329 
330  protected:
334  virtual ~NotCondition();
335 
336  public:
346  virtual void onEnter( Agents::BaseAgent * agent );
347 
353  virtual void onLeave( Agents::BaseAgent * agent );
354 
363  virtual bool conditionMet( Agents::BaseAgent * agent, const Goal * goal );
364 
373  virtual Condition * copy();
374 
375  friend class NotCondFactory;
376 
377  protected:
382 
383  };
384 
386 
390  class MENGE_API NotCondFactory : public ConditionFactory {
391  public:
400  virtual const char * name() const { return "not"; }
401 
409  virtual const char * description() const {
410  return "The not condition. This condition depends on the evaluation of "\
411  "a single child condition. This condition is met when the child is not "\
412  " and vice versa.";
413  }
414  protected:
425  virtual Condition * instance() const { return new NotCondition(); }
426 
427 
446  virtual bool setFromXML( Condition * condition, TiXmlElement * node, const std::string & behaveFldr ) const;
447  };
448 
449  } // namespace BFSM
450 } // namespace Menge
451 #endif // __COND_BOOLEAN_H__
Condition * _op
The boolean operand to negate.
Definition: CondBoolean.h:381
virtual const char * name() const
The name of the condition.
Definition: CondBoolean.h:400
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
The class for parsing the xml description of a Condition and instantiating particular instances...
Definition: ConditionFactory.h:61
virtual const char * description() const
A description of the condition.
Definition: CondBoolean.h:208
Sets up the proper compiler directives for platform and dll export/import.
The factory for parsing xml data for transition conditions and instantiating the appropriate class...
A condition based on the boolean negation of a single condition.
Definition: CondBoolean.h:316
The base, abstract class defining goals.
Definition: Goal.h:110
A condition based on the boolean and of two conditions.
Definition: CondBoolean.h:149
virtual Condition * instance() const
Create an instance of this class's condition.
Definition: CondBoolean.h:425
virtual const char * name() const
The name of the condition.
Definition: CondBoolean.h:281
The factory for creating the AndCondition.
Definition: CondBoolean.h:189
virtual const char * description() const
A description of the condition.
Definition: CondBoolean.h:290
The factory for creating the NotCondition.
Definition: CondBoolean.h:390
virtual Condition * instance() const
Create an instance of this class's condition.
Definition: CondBoolean.h:305
The base class for binary boolean operand as a transition condition.
Definition: CondBoolean.h:63
virtual const char * description() const
A description of the condition.
Definition: CondBoolean.h:409
The namespace contains the Behavior Finite State Machine (BFSM) definition.
A condition based on the boolean OR of two conditions.
Definition: CondBoolean.h:231
Condition * _op2
The second boolean operand.
Definition: CondBoolean.h:113
The factory for creating the OrCondition.
Definition: CondBoolean.h:271
The base class for transition conditions.
Definition: Condition.h:68
Defines the basic agent properties and functionality that all simulation agents share.
Definition: BaseAgent.h:123
virtual Condition * instance() const
Create an instance of this class's condition.
Definition: CondBoolean.h:223
The factory for creating the Bool2Condition.
Definition: CondBoolean.h:121
virtual const char * name() const
The name of the condition.
Definition: CondBoolean.h:199
Condition * _op1
The first boolean operand.
Definition: CondBoolean.h:108
The basis for determining the conditions under which transitions become "active" (and are taken)...