controller_concept.hppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ADOBE_CONTROLLER_HPP
00010 #define ADOBE_CONTROLLER_HPP
00011
00012
00013
00014 #include <boost/concept_check.hpp>
00015 #include <boost/function.hpp>
00016
00017
00018
00019 namespace adobe {
00020
00021
00022
00023 template <class C>
00024 struct controller_model_type
00025 {
00026 typedef typename C::model_type type;
00027 };
00028
00029
00030
00031 template <class C, class F>
00032 inline void monitor(C& c, const F& setter)
00033 { c.monitor(setter); }
00034
00035
00036
00037 template <class C>
00038 inline void enable(C& c, bool enable_state)
00039 { c.enable(enable_state); }
00040
00041
00042
00043 template <class T>
00044 struct ControllerConcept
00045 {
00046 typedef typename controller_model_type<T>::type model_type;
00047
00048
00049 template <class F>
00050 static void monitor(T& controller, F setter)
00051 {
00052 using adobe::monitor;
00053 monitor(controller, setter);
00054 }
00055
00056 static void enable(T& controller, bool enable_state)
00057 {
00058 using adobe::enable;
00059 enable(controller, enable_state);
00060 }
00061
00062
00063
00064 T* t;
00065 bool b;
00066 boost::function<void (const typename controller_model_type<T>::type&)> f;
00067
00068 void constraints() {
00069
00070
00071
00072
00073
00074
00075 typedef typename controller_model_type<T>::type associated_type;
00076
00077
00078 using adobe::enable;
00079 enable(*t, b);
00080
00081 using adobe::monitor;
00082 monitor(*t, f);
00083 }
00084 };
00085
00086 template <class T>
00087 struct ControllerConcept<T*> : ControllerConcept<T>
00088 {
00089 static void enable(T* c, bool enable_state)
00090 { ControllerConcept<T>::enable(*c, enable_state); }
00091
00092 static void monitor(T* c, boost::function<void (const typename ControllerConcept<T>::model_type&)> setter)
00093 { ControllerConcept<T>::monitor(*c, setter); }
00094
00095 void constraints() {
00096
00097 ControllerConcept<T>::constraints();
00098 }
00099 };
00100
00101
00102
00103 }
00104
00105
00106
00107 #endif
|