5#include <cgv/type/cond/is_base_of.h>
12class 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;
44template <
bool is_derived,
class X>
66 :
action(_default_result_begin, _default_result_end), tp(0), x(0) {}
70 x = p->get_interface<X>();
85template <
class X,
typename T1>
92 method_action(T1 _v1,
bool _default_result_begin,
bool _default_result_end)
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;
111template <
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) {}
128template <
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) {}
136 matched_method_action(T1 _v1, R1 (X::*_on_begin)(T1), R2 (X::*_on_end)(T1), bool _default_result_begin, bool _default_result_end) {
…}
145template <
typename T1,
class X,
typename R>
151template <
typename T1,
class X,
typename R1,
typename R2>
158template <
class X,
typename T1,
typename T2>
173 (this->x->*
mp)(v1,v2);
179 return (this->x->*
mp)(v1, v2);
185template <
class X,
typename R,
typename T1,
typename T2>
189 R (X::*on_begin)(
T1,
T2);
202template <
typename T1,
typename T2,
class X,
typename R>
210#include <cgv/config/lib_end.h>
The action class is used in tree traversals together with the traverser.
base class for all actions that use methods of class X
base_method_action(bool _default_result_begin, bool _default_result_end)
construct from default return values that are passed on to the base class
traverse_policy * get_policy() const
simply return the stored pointer of type traverse_policy*
bool implements_action() const
simply return whether the stored pointer of type X* is not 0
void select(base_ptr p)
implement the select method and store pointers of type X* and traverse_policy*
complete implementation of method actions that call a begin and end method when entering and leaving ...
bool end()
uses call_method of base class method_action to call the method refered to by the stored method point...
bool begin()
uses call_method of base class method_action to call the method refered to by the stored method point...
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
base class for all method actions that take a single argument of type T1 in their signature
bool call_method(bool(X::*mp)(T1, T2), bool default_result)
call a bool method given a default return value
method_action_2(T1 _v1, T2 _v2, bool _default_result_begin, bool _default_result_end)
construct action from signature and default return values
void set_signature(T1 _v1, T2 _v2)
set a new signature with which the methods of the traversed nodes are called
bool call_method(void(X::*mp)(T1, T2), bool default_result)
call a void method given a default return value
base class for all method actions that take a single argument of type T1 in their signature
bool call_method(bool(X::*mp)(T1), bool default_result)
call a bool method given a default return value
bool call_method(void(X::*mp)(T1), bool default_result)
call a void method given a default return value
void set_signature(T1 _v1)
set a new signature with which the methods of the traversed nodes are called
method_action(T1 _v1, bool _default_result_begin, bool _default_result_end)
construct action from signature and default return values
complete implementation of method actions that only call one method when entering a node
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
bool has_begin_only() const
check whether the action has registered a single begin method or both begin and end methods
bool begin()
uses call_method of base class method_action to call the method refered to by the stored method point...
complete implementation of method actions that only call one method when entering a node
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
bool has_begin_only() const
check whether the action has registered a single begin method or both begin and end methods
bool begin()
uses call_method of base class method_action to call the method refered to by the stored method point...
nodes should inherit from this policy class to allow selective tree traversals
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 ...
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 ...