5 #include <cgv/type/cond/is_base_of.h>
12 class CGV_API traverse_policy;
19 bool default_result_begin;
20 bool default_result_end;
23 action(
bool _default_result_begin,
bool _default_result_end);
25 void set_default_results(
bool _default_result);
27 void set_default_result_begin(
bool _default_result_begin);
29 void set_default_result_end(
bool _default_result_end);
33 virtual bool implements_action()
const;
41 virtual bool has_begin_only()
const;
44 template <
bool is_derived,
class X>
45 struct extract_policy_struct
51 struct extract_policy_struct<true,X>
53 static void extract_policy(X* x, traverse_policy* &tp) { tp =
static_cast<traverse_policy*
>(x); }
66 :
action(_default_result_begin, _default_result_end), tp(0), x(0) {}
70 x = p->get_interface<X>();
71 extract_policy_struct<type::cond::is_base_of<traverse_policy, X>::value,X>::extract_policy(x, tp);
85 template <
class X,
typename T1>
92 method_action(T1 _v1,
bool _default_result_begin,
bool _default_result_end)
100 return default_result;
105 return (this->x->*mp)(v1);
106 return default_result;
111 template <
class X,
typename R,
typename T1>
115 R (X::*on_begin)(T1);
119 bool _default_result_begin =
false,
bool _default_result_end =
false)
120 :
method_action<X,T1>(_v1, _default_result_begin, _default_result_end), on_begin(_on_begin) {}
128 template <
class X,
typename R1,
typename R2,
typename T1>
132 R1 (X::*on_begin)(T1);
136 matched_method_action(T1 _v1, R1 (X::*_on_begin)(T1), R2 (X::*_on_end)(T1),
bool _default_result_begin,
bool _default_result_end)
137 :
method_action<X,T1>(_v1, _default_result_begin, _default_result_end), on_begin(_on_begin), on_end(_on_end) {}
145 template <
typename T1,
class X,
typename R>
151 template <
typename T1,
class X,
typename R1,
typename R2>
158 template <
class X,
typename T1,
typename T2>
167 :
base_method_action<X>(_default_result_begin, _default_result_end), v1(_v1), v2(_v2) {}
173 (this->x->*mp)(v1,v2);
174 return default_result;
179 return (this->x->*mp)(v1, v2);
180 return default_result;
185 template <
class X,
typename R,
typename T1,
typename T2>
189 R (X::*on_begin)(T1,T2);
193 bool _default_result_begin =
false,
bool _default_result_end =
false)
194 :
method_action_2<X,T1,T2>(_v1, _v2, _default_result_begin, _default_result_end), on_begin(_on_begin) {}
202 template <
typename T1,
typename T2,
class X,
typename R>
210 #include <cgv/config/lib_end.h>
bool implements_action() const
simply return whether the stored pointer of type X* is not 0
Definition: action.h:74
bool begin()
uses call_method of base class method_action to call the method refered to by the stored method point...
Definition: action.h:122
bool begin()
uses call_method of base class method_action to call the method refered to by the stored method point...
Definition: action.h:139
void set_signature(T1 _v1, T2 _v2)
set a new signature with which the methods of the traversed nodes are called
Definition: action.h:169
single_method_action_2< X, R, T1, T2 > make_action_2(T1 _v1, T2 _v2, R(X::*_on_begin)(T1, T2), bool _default_result_begin=false, bool _default_result_end=false)
helper function to construct an action from a signature and one method that is called when a node is ...
Definition: action.h:203
bool call_method(void(X::*mp)(T1), bool default_result)
call a void method given a default return value
Definition: action.h:97
bool end()
uses call_method of base class method_action to call the method refered to by the stored method point...
Definition: action.h:141
void select(base_ptr p)
implement the select method and store pointers of type X* and traverse_policy*
Definition: action.h:69
nodes should inherit from this policy class to allow selective tree traversals
Definition: traverser.h:24
method_action_2(T1 _v1, T2 _v2, bool _default_result_begin, bool _default_result_end)
construct action from signature and default return values
Definition: action.h:166
base_method_action(bool _default_result_begin, bool _default_result_end)
construct from default return values that are passed on to the base class
Definition: action.h:65
bool call_method(bool(X::*mp)(T1), bool default_result)
call a bool method given a default return value
Definition: action.h:103
traverse_policy * get_policy() const
simply return the stored pointer of type traverse_policy*
Definition: action.h:78
bool call_method(void(X::*mp)(T1, T2), bool default_result)
call a void method given a default return value
Definition: action.h:171
void set_signature(T1 _v1)
set a new signature with which the methods of the traversed nodes are called
Definition: action.h:95
single_method_action< X, R, T1 > make_action(T1 _v1, R(X::*_on_begin)(T1), bool _default_result_begin=false, bool _default_result_end=false)
helper function to construct an action from a signature and one method that is called when a node is ...
Definition: action.h:146
single_method_action(T1 _v1, R(X::*_on_begin)(T1), bool _default_result_begin=false, bool _default_result_end=false)
construct from signature, method pointer and default result values
Definition: action.h:118
bool call_method(bool(X::*mp)(T1, T2), bool default_result)
call a bool method given a default return value
Definition: action.h:177
single_method_action_2(T1 _v1, T2 _v2, R(X::*_on_begin)(T1, T2), bool _default_result_begin=false, bool _default_result_end=false)
construct from signature, method pointer and default result values
Definition: action.h:192
method_action(T1 _v1, bool _default_result_begin, bool _default_result_end)
construct action from signature and default return values
Definition: action.h:92
bool begin()
uses call_method of base class method_action to call the method refered to by the stored method point...
Definition: action.h:196
bool has_begin_only() const
check whether the action has registered a single begin method or both begin and end methods
Definition: action.h:124
bool has_begin_only() const
check whether the action has registered a single begin method or both begin and end methods
Definition: action.h:198
the cgv namespace
Definition: vr_calib.cxx:9
matched_method_action(T1 _v1, R1(X::*_on_begin)(T1), R2(X::*_on_end)(T1), bool _default_result_begin, bool _default_result_end)
construct from signature, method pointers and default result values
Definition: action.h:136