widget_proxies.hppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ADOBE_WIDGET_PROXIES_HPP
00010 #define ADOBE_WIDGET_PROXIES_HPP
00011
00012
00013
00014 #include <adobe/config.hpp>
00015
00016 #include <adobe/future/assemblage.hpp>
00017 #include <adobe/poly_controller.hpp>
00018 #include <adobe/poly_view.hpp>
00019
00020
00021
00022 namespace adobe {
00023
00024
00025
00026 namespace implementation {
00027
00028
00031 template <typename T,
00032 typename MonitorFunction,
00033 typename EnableFunction>
00034 struct functions_as_controller
00035 {
00036 typedef T model_type;
00037 typedef boost::function<void (const model_type&)> setter_type;
00038
00039 functions_as_controller(const MonitorFunction& monitor_function,
00040 const EnableFunction& enable_function) :
00041 monitor_function_m(monitor_function),
00042 enable_function_m(enable_function)
00043 { }
00044
00045 void monitor(const setter_type& proc)
00046 {
00047 monitor_function_m(proc);
00048 }
00049
00050 void enable(bool enable)
00051 {
00052 enable_function_m(enable);
00053 }
00054
00055 friend inline bool operator==(const functions_as_controller&, const functions_as_controller&)
00056 { return true; }
00057
00058 private:
00059 MonitorFunction monitor_function_m;
00060 EnableFunction enable_function_m;
00061 };
00062
00063
00064
00065 template <typename T, typename MF, typename EF>
00066 inline functions_as_controller<T, MF, EF> make_functions_as_controller(const MF& mf,
00067 const EF& ef)
00068 {
00069 return functions_as_controller<T, MF, EF>(mf, ef);
00070 }
00071
00072
00073
00074 }
00075
00076
00077
00082 template <typename T,
00083 typename MonitorFunction,
00084 typename EnableFunction>
00085 inline poly<controller> make_functions_as_poly_controller(const MonitorFunction& monitor_function,
00086 const EnableFunction& enable_function)
00087 {
00088 return poly<controller>(implementation::functions_as_controller<T,
00089 MonitorFunction,
00090 EnableFunction>(monitor_function,
00091 enable_function));
00092 }
00093
00094
00095
00096 }
00097
00098
00099
00100 #endif
00101
00102
|