5#include <cgv/type/cond/is_base_of.h>
19 bool default_result_begin;
20 bool default_result_end;
23 action(
bool _default_result_begin,
bool _default_result_end);
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)
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) {}
145template <
typename T1,
class X,
typename R>
151template <
typename T1,
class X,
typename R1,
typename R2>
158template <
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;
185template <
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) {}
202template <
typename T1,
typename T2,
class X,
typename R>
210#include <cgv/config/lib_end.h>
void set_default_result_end(bool _default_result_end)
sets the value that is returned for on_end events
void set_default_result_begin(bool _default_result_begin)
sets the value that is returned for on_begin events
virtual bool implements_action() const
check if the current object implements the interface needed for this action
virtual bool has_begin_only() const
check whether the action has registered a single begin method or both begin and end methods
action(bool _default_result_begin, bool _default_result_end)
construct with default return values for the begin and end method
virtual bool end()
perform the leave part of the action on the current object
virtual bool begin()
perform the enter part of the action on the current object
void set_default_results(bool _default_result)
sets the value that is returned, whenever no result is obtained from the traversed methods
virtual traverse_policy * get_policy() const
return the traverse_policy of the current object if available or 0 otherwise
virtual void select(base_ptr p)
make the passed object current
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
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
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
the base namespace holds the base hierarchy, support for plugin registration and signals
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 ...
data::ref_ptr< base, true > base_ptr
ref counted pointer to base
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 ...
this header is dependency free