view_concept.hppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ADOBE_VIEW_HPP
00010 #define ADOBE_VIEW_HPP
00011
00012
00013
00014 #include <boost/concept_check.hpp>
00015 #include <boost/ref.hpp>
00016
00017 #include <adobe/regular_concept.hpp>
00018
00019
00020
00021 namespace adobe {
00022
00023
00024
00025 #ifdef ADOBE_HAS_CPLUS0X_CONCEPTS
00026
00027
00028
00029 auto concept ViewConcept<typename View>
00030
00031 : std::CopyConstructible<View>
00032 {
00033 typename model_type;
00034 void display(View& v, model_type value);
00035 };
00036
00037
00038
00039 auto concept ViewMFConcept<typename View>
00040
00041 : std::CopyConstructible<View>
00042 {
00043
00044 typename model_type = View::model_type;
00045 void View::display(model_type value);
00046 };
00047
00048
00049
00050 template <ViewMFConcept T>
00051 concept_map ViewConcept<T> {
00052 typedef ViewMFConcept<T>::model_type model_type;
00053 inline void display(T& v, model_type value)
00054 { v.display(value); }
00055 };
00056
00057
00058
00059 template <ViewConcept T>
00060 concept_map ViewConcept<boost::reference_wrapper<T> > {
00061 typedef ViewConcept<T>::model_type model_type;
00062 void display(boost::reference_wrapper<T>& r, model_type value)
00063 { ViewConcept<T>::display(static_cast<T&>(r),value); }
00064 };
00065
00066
00067
00068 #else
00069
00070
00071
00072 template <class View>
00073 struct view_model_type
00074 {
00075 typedef typename boost::unwrap_reference<View>::type::model_type type;
00076 };
00077
00078
00079
00080 template <class V>
00081 inline void display(V& v, const typename view_model_type<V>::type& value)
00082 { v.display(value); }
00083
00084
00085
00086 template <class T>
00087 struct ViewConcept
00088 {
00089 typedef typename view_model_type<T>::type model_type;
00090
00091 static void display(T& view, const model_type& value)
00092 {
00093 using adobe::display;
00094 display(view, value);
00095 }
00096
00097
00098
00099 T* t;
00100 typename view_model_type<T>::type* x;
00101
00102 void constraints() {
00103
00104
00105
00106
00107
00108 typedef typename view_model_type<T>::type associated_type;
00109
00110
00111 using adobe::display;
00112 display(*t, *x);
00113 }
00114 };
00115
00116 template <class T>
00117 struct ViewConcept<boost::reference_wrapper<T> > : ViewConcept<T>
00118 {
00119 void constraints() {
00120
00121 ViewConcept<T>::constraints();
00122 }
00123 };
00124
00125 #endif
00126
00127
00128
00129
00130 }
00131
00132
00133
00134 #endif
|