14 #ifndef _OCRABASE_OBSERVER_SUBJECT_H_ 15 #define _OCRABASE_OBSERVER_SUBJECT_H_ 20 #include <boost/static_assert.hpp> 21 #include <boost/type_traits/is_base_of.hpp> 22 #include <boost/type_traits/is_convertible.hpp> 23 #include <boost/type_traits/is_class.hpp> 36 template<
int EVT,
class Derived,
class Base>
37 void connect(Derived&
object,
void (Base::*newCallback)(
int))
const 39 typedef boost::is_class<Derived> you_must_pass_the_first_arg_by_reference;
40 typedef boost::is_base_of<Base, Derived> callback_must_be_a_method_of_observer_or_must_be_inherited;
41 typedef boost::is_convertible<Derived*, Base*> if_inherited_callback_then_public_inheritance_needed;
43 BOOST_STATIC_ASSERT(you_must_pass_the_first_arg_by_reference ::value);
44 BOOST_STATIC_ASSERT(callback_must_be_a_method_of_observer_or_must_be_inherited ::value);
45 BOOST_STATIC_ASSERT(if_inherited_callback_then_public_inheritance_needed ::value);
47 Base& objectBase = object;
53 void connect(
void (*newCallback)(
int))
const 59 template<
int EVT,
class Derived,
class Base>
60 void disconnect(Derived&
object,
void (Base::*callbackToErase)(
int))
const 62 typedef boost::is_class<Derived> you_must_pass_the_first_arg_by_reference;
63 typedef boost::is_base_of<Base, Derived> callback_must_be_a_method_of_observer_or_must_be_inherited;
64 typedef boost::is_convertible<Derived*, Base*> if_inherited_callback_then_public_inheritance_needed;
66 BOOST_STATIC_ASSERT(you_must_pass_the_first_arg_by_reference ::value);
67 BOOST_STATIC_ASSERT(callback_must_be_a_method_of_observer_or_must_be_inherited ::value);
68 BOOST_STATIC_ASSERT(if_inherited_callback_then_public_inheritance_needed ::value);
70 Base& objectBase = object;
125 bind<EVT_RESIZE>(*this);
126 bind<EVT_CHANGE_DEPENDENCIES>(*this);
127 bind<EVT_CHANGE_VALUE>(*this);
134 #endif//_OCRABASE_OBSERVER_SUBJECT_H_ void propagate(int timestamp) const
void disconnect(void(*callbackToErase)(int)) const
Disconnect free function.
void connect(T &object, typename SubjectBaseTraits< EVT, T >::callback_type newCallback) const
Call this method to register a non-static method as a callback.
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
void disconnect(T &object, typename SubjectBaseTraits< EVT, T >::callback_type callback) const
Disconnect non-static method.
Declaration file of the Observer and Subject base classes.
void connect(void(*newCallback)(int)) const
Call this method to register a free function as a callback.
void bind(SubjectBase< EVT > &subject)
Call this method to automatically propagate observed events to observers connected to the subject giv...
Base class for Observers with propagation system.
void bind(subject_type &subject)
Call this method to automatically propagate observed events to observers connected to the subject giv...
void disconnect(Derived &object, void(Base::*callbackToErase)(int)) const
Disconnect non-static method.
void connect(Derived &object, void(Base::*newCallback)(int)) const
Call this method to register a non-static method as a callback.
virtual ~ObserverSubject()
void stopPropagation()
Call this method from your callbacks to avoid propagation to the bound subject (if any)...