Qualia
0.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
qualia
plugins
bt
IntCondition.h
Go to the documentation of this file.
1
#include "
Common.h
"
2
namespace
BehaviorTree
3
{
5
enum
INT_TEST
{
LESS_THAN
,
GREATER_THAN
,
LESS_OR_EQ
,
GREATER_OR_EQ
,
EQUAL
,
NOT_EQUAL
};
6
7
template
<
class
T = NoClass>
9
20
class
IntCondition
:
public
BehaviorTreeNode
21
{
22
public
:
24
BEHAVIOR_STATUS
execute
(
void
* agent)
25
{
26
T* obj = (T*) agent;
27
bool
status;
28
int
objVal = (obj->*
func
)();
29
switch
(
test
)
30
{
31
case
LESS_THAN
: status = (objVal <
val
);
break
;
32
case
GREATER_THAN
: status = (objVal >
val
);
break
;
33
case
LESS_OR_EQ
: status = (objVal <=
val
);
break
;
34
case
GREATER_OR_EQ
: status = (objVal >=
val
);
break
;
35
case
EQUAL
: status = (objVal ==
val
);
break
;
36
case
NOT_EQUAL
: status = (objVal !=
val
);
break
;
37
}
38
39
if
(status)
40
return
BT_SUCCESS
;
41
else
42
return
BT_FAILURE
;
43
};
44
45
void
init
(
void
* agent)
46
{
47
};
52
IntCondition
(
int
(T::*
const
_func)(),
INT_TEST
_test,
int
_val) :
func
(_func),
func2
(NULL)
53
{
54
test
= _test;
55
val
= _val;
56
}
61
IntCondition
(
int
(*
const
_func)(),
INT_TEST
_test,
int
_val) :
func2
(_func),
func
(NULL)
62
{
63
test
= _test;
64
val
= _val;
65
}
70
IntCondition
(
int
(T::*
const
_func)()
const
,
INT_TEST
_test,
int
_val) :
func
(reinterpret_cast<int(T::* const)()>(_func)),
func2
(NULL)
71
{
72
test
= _test;
73
val
= _val;
74
}
75
private
:
76
int (T::*
const
func
)() ;
//A member function pointer of the class T, being stored as const since we don't modify it
77
int (*
const
func2
)();
//A static method or function pointer, being stored as const since we don't modify it
78
INT_TEST
test
;
79
int
val
;
80
81
};
82
}
Generated on Fri Oct 11 2013 19:01:21 for Qualia by
1.8.3.1