Qualia  0.2
BoolCondition.h
Go to the documentation of this file.
1 #include "Common.h"
2 
3 #ifndef BOOL_CONDITION_H
4 #define BOOL_CONDITION_H
5 
6 namespace BehaviorTree
7 {
8  template <class T = NoClass>
10 
22  {
23  public:
24  BEHAVIOR_STATUS execute(void* agent)
25  {
26  T* obj = (T*) agent;
27  if ((obj->*func)() == check)
28  return BT_SUCCESS;
29  else
30  return BT_FAILURE;
31  };
32 
33  void init(void* agent)
34  {
35  };
36 
40  BoolCondition(bool(T::*_func)(), bool _check) : func(_func), func2(NULL)
41  {
42  check = _check;
43  }
47  BoolCondition(bool(*_func)(), bool _check) : func2(_func), func(NULL)
48  {
49  check = _check;
50  }
54  BoolCondition(bool(T::* const _func)() const,bool _check) : func(reinterpret_cast<bool(T::* const)()>(_func)), func2(NULL)
55  {
56  check = _check;
57  }
58 
59  private:
60  bool (T::* const func)();
61  bool (* const func2)();
62  bool check;
63  };
64 }
65 
66 #endif