stlab.adobe.com Adobe Systems Incorporated

placeable_concept.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2006-2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 
00007 /*************************************************************************************************/
00008 #ifndef ADOBE_PLACEABLE_HPP
00009 #define ADOBE_PLACEABLE_HPP
00010 
00011 /************************************************************************************************/
00012 
00013 #include <boost/concept_check.hpp>
00014 
00015 #include <adobe/extents.hpp>
00016 #include <adobe/layout_attributes.hpp>
00017 
00018 /************************************************************************************************/
00019 
00020 namespace adobe {
00027 /************************************************************************************************/
00028 
00029 #ifdef ADOBE_HAS_CPLUS0X_CONCEPTS
00030 
00031 /*************************************************************************************************/
00032 
00033 
00037 auto concept PlaceableConcept <typename T> 
00038 // not yet : RegularConcept<T> 
00039 : std::CopyConstructible<T>
00040 {
00041     void measure(T& t, extents_t& result);
00042     void place(T& t, const place_data_t& place_data);
00043 };
00044 
00045 /*************************************************************************************************/
00046 
00050 auto concept PlaceableMFConcept <typename Placeable> 
00051 // not yet : RegularConcept<Placeable>
00052 : std::CopyConstructible<Placeable>
00053 {
00054     void Placeable::measure(extents_t& result); 
00055     void Placeable::place(const place_data_t& place_data);
00056 };
00057 
00058 /*************************************************************************************************/
00059 
00063 template <PlaceableMFConcept T>
00064 concept_map PlaceableConcept<T> {
00065     void measure(T& t, extents_t& result)
00066         { t.measure(result); }
00067     void place(T& t, const place_data_t& place_data)
00068         { t.place(place_data); }
00069 };
00070 
00071 /*************************************************************************************************/
00072 
00076 template <PlaceableConcept T>
00077 concept_map PlaceableConcept<boost::reference_wrapper<T> > {
00078     void measure(boost::reference_wrapper<T>& r, extents_t& result)
00079         { PlaceableConcept<T>::measure(static_cast<T&>(r), result); }
00080 };
00081 
00082 /*************************************************************************************************/
00083 
00087 auto concept PlaceableTwoPassConcept<typename Placeable> : PlaceableConcept<Placeable> 
00088 {
00089     void measure_vertical(Placeable& p, extents_t& calculated_horizontal,
00090                                  const place_data_t& placed_horizontal);
00091 };
00092 
00093 /*************************************************************************************************/
00094 
00098 auto concept PlaceableTwoPassMFConcept<typename Placeable> : PlaceableMFConcept<Placeable>
00099 {
00100     void Placeable::measure_vertical(extents_t& calculated_horizontal,
00101                                  const place_data_t& placed_horizontal); 
00102 };
00103 
00104 /*************************************************************************************************/
00105 
00109 template <typename T>
00110 concept_map PlaceableTwoPassConcept<PlaceableTwoPassMFConcept<T> > {
00111     
00112     void measure(PlaceableTwoPassMFConcept<T>& t, extents_t& result)
00113     { t.measure(result); }
00114 
00115     void place(PlaceableTwoPassMFConcept<T>& t, const place_data_t& place_data)
00116     { t.place(place_data); }
00117 
00118     void measure_vertical(PlaceableTwoPassMFConcept<T>& t, extents_t& calculated_horizontal,
00119                                  const place_data_t& placed_horizontal)
00120     { t.measure_vertical(calculated_horizontal, placed_horizontal); }
00121 };
00122 
00123 /*************************************************************************************************/
00124 
00128 template <typename T>
00129 concept_map PlaceableTwoPassConcept<boost::reference_wrapper<PlaceableTwoPassConcept<T> > > {
00130     void measure(boost::reference_wrapper<PlaceableTwoPassConcept<T> >& r, 
00131                           extents_t& extents)
00132     { 
00133         PlaceableTwoPassConcept<PlaceableTwoPassConcept<T> >::measure(
00134             *r.get_pointer(), extents); 
00135     }
00136     void place(boost::reference_wrapper<PlaceableTwoPassConcept<T> >& r, 
00137                const place_data_t& place_data)
00138     { 
00139         PlaceableTwoPassConcept<PlaceableTwoPassConcept<T> >::place(
00140             *r.get_pointer(), place_data); 
00141     }
00142     void measure_vertical(boost::reference_wrapper<PlaceableTwoPassConcept<T> >& r, 
00143                           extents_t& calculated_horizontal,
00144                           const place_data_t& placed_horizontal)
00145     { 
00146         PlaceableTwoPassConcept<PlaceableTwoPassConcept<T> >::measure_vertical(
00147             *r.get_pointer(), calculated_horizontal, placed_horizontal); 
00148     }
00149 };
00150 
00151 /*************************************************************************************************/
00152 
00153 #else
00154 
00155 /*************************************************************************************************/
00156 
00157 
00174 template <class T>
00175 inline void measure(T& t, extents_t& result)
00176 { t.measure(result); }
00177 
00178 /*************************************************************************************************/
00179 
00180 
00205 template <class T>
00206 inline void place(T& t, const place_data_t& place_data)
00207 { t.place(place_data); }
00208 
00209 /*************************************************************************************************/
00210 
00219 template <class T>
00220 struct PlaceableConcept
00221 {
00222 #if !defined(ADOBE_NO_DOCUMENTATION)
00223 
00224     static void measure(T& t, extents_t& result)
00225     {   
00226         using adobe::measure; // pick up default version which looks for member functions
00227         measure(t, result); // unqualified to allow user versions
00228     }
00229 
00230     static void place(T& t, const place_data_t& place_data)
00231     { 
00232         using adobe::place; // pick up default version which looks for member functions
00233         place(t, place_data); // unqualified to allow user versions
00234     }
00235 
00236 // Concept checking:
00237     
00238     void constraints() {
00239         // not yet: boost::function_requires<RegularConcept<Placeable> >();
00240         // boost::function_requires<boost::CopyConstructibleConcept<Placeable> >();
00241 
00242         using adobe::measure; 
00243         measure(*placeable, extents);
00244 
00245         using adobe::place;
00246         place(*placeable, place_data);
00247     }
00248 
00249 //use pointers since not required to be default constructible
00250     T*                  placeable;
00251     const place_data_t  place_data;
00252     extents_t           extents;    
00253 #endif
00254 };
00255 
00264 template <class T>
00265 struct PlaceableConcept<T*> : public PlaceableConcept<T>
00266 {
00267     static void measure(T* r, extents_t& result) 
00268     { PlaceableConcept<T>::measure(*r, result); }
00269 
00270     static void place(T* r, const place_data_t& place_data) 
00271     { PlaceableConcept<T>::place(*r, place_data); }
00272 
00273 #if !defined(ADOBE_NO_DOCUMENTATION)
00274     void constraints() {
00275         //boost concept check lib gets confused on VC8 without this
00276         PlaceableConcept<T>::constraints();
00277     }
00278 #endif
00279 };
00280 
00281 /*************************************************************************************************/
00282 
00283 
00303 template <class T>
00304 inline void measure_vertical(T& t,
00305                              extents_t& calculated_horizontal,
00306                              const place_data_t& placed_horizontal)
00307 { t.measure_vertical(calculated_horizontal, placed_horizontal); }
00308 
00309 /*************************************************************************************************/
00310 
00319 template <class T>
00320 struct PlaceableTwoPassConcept : PlaceableConcept<T>
00321 {
00322 #if ! defined(ADOBE_NO_DOCUMENTATION)    
00323 
00324     static void measure_vertical(T& t,
00325                                  extents_t& calculated_horizontal,
00326                                  const place_data_t& placed_horizontal)
00327     {
00328         using adobe::measure_vertical;
00329         measure_vertical(t, calculated_horizontal, placed_horizontal);
00330     }
00331 
00332     void constraints() {
00333         // not yet: boost::function_requires<RegularConcept<T> >();
00334         //boost::function_requires<boost::CopyConstructibleConcept<T> >();  
00335 
00336         using adobe::place;
00337         place(*t2, this->place_data); 
00338         
00339         using adobe::measure;
00340         measure(*t2, this->extents);
00341 
00342         using adobe::measure_vertical;
00343         measure_vertical(*t2, this->extents, this->place_data);
00344     }
00345 
00346      // Concept checking:
00347     //use pointers since not required to be default constructible
00348     T *t2;
00349 #endif
00350 
00351 };
00352 
00361 template <class T>
00362 struct PlaceableTwoPassConcept<T*> : 
00363     PlaceableTwoPassConcept<T> 
00364 {
00365     static void measure(T* r, extents_t& extents)
00366     { 
00367         PlaceableTwoPassConcept<T>::measure(
00368             *r, extents); 
00369     }
00370     static void place(T* r, const place_data_t& place_data)
00371     { 
00372         PlaceableTwoPassConcept<T>::place(
00373             *r, place_data); 
00374     }
00375     static void measure_vertical(T* r, extents_t& calculated_horizontal,
00376                           const place_data_t& placed_horizontal)
00377     { 
00378         PlaceableTwoPassConcept<T>::measure_vertical(
00379             *r, calculated_horizontal, placed_horizontal); 
00380     }
00381 
00382 #if !defined(ADOBE_NO_DOCUMENTATION)
00383     void constraints() {
00384         //boost concept check lib gets confused on VC8 without this
00385         PlaceableTwoPassConcept<T>::constraints();
00386     }
00387 #endif
00388 };
00389 
00390 
00391 /*************************************************************************************************/
00392 
00393 #endif
00394 
00395 /*************************************************************************************************/
00396 
00397 } // namespace adobe
00398 
00399 /*************************************************************************************************/
00400 
00401 #endif

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google