stlab.adobe.com Adobe Systems Incorporated
placeable_concept.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2007 Adobe Systems Incorporated
3  Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
4  or a copy at http://stlab.adobe.com/licenses.html)
5 */
6 
7 /*************************************************************************************************/
8 #ifndef ADOBE_PLACEABLE_HPP
9 #define ADOBE_PLACEABLE_HPP
10 
11 /************************************************************************************************/
12 
13 #include <boost/concept_check.hpp>
14 
15 #include <adobe/extents.hpp>
17 
18 /************************************************************************************************/
19 
20 namespace adobe {
27 /************************************************************************************************/
28 
29 #ifdef ADOBE_HAS_CPLUS0X_CONCEPTS
30 
31 /*************************************************************************************************/
32 
33 
37 auto concept PlaceableConcept <typename T>
38 // not yet : RegularConcept<T>
39 : std::CopyConstructible<T>
40 {
41  void measure(T& t, extents_t& result);
42  void place(T& t, const place_data_t& place_data);
43 };
44 
45 /*************************************************************************************************/
46 
50 auto concept PlaceableMFConcept <typename Placeable>
51 // not yet : RegularConcept<Placeable>
52 : std::CopyConstructible<Placeable>
53 {
54  void Placeable::measure(extents_t& result);
55  void Placeable::place(const place_data_t& place_data);
56 };
57 
58 /*************************************************************************************************/
59 
63 template <PlaceableMFConcept T>
64 concept_map PlaceableConcept<T> {
65  void measure(T& t, extents_t& result)
66  { t.measure(result); }
67  void place(T& t, const place_data_t& place_data)
68  { t.place(place_data); }
69 };
70 
71 /*************************************************************************************************/
72 
76 template <PlaceableConcept T>
77 concept_map PlaceableConcept<boost::reference_wrapper<T> > {
78  void measure(boost::reference_wrapper<T>& r, extents_t& result)
79  { PlaceableConcept<T>::measure(static_cast<T&>(r), result); }
80 };
81 
82 /*************************************************************************************************/
83 
87 auto concept PlaceableTwoPassConcept<typename Placeable> : PlaceableConcept<Placeable>
88 {
89  void measure_vertical(Placeable& p, extents_t& calculated_horizontal,
90  const place_data_t& placed_horizontal);
91 };
92 
93 /*************************************************************************************************/
94 
98 auto concept PlaceableTwoPassMFConcept<typename Placeable> : PlaceableMFConcept<Placeable>
99 {
100  void Placeable::measure_vertical(extents_t& calculated_horizontal,
101  const place_data_t& placed_horizontal);
102 };
103 
104 /*************************************************************************************************/
105 
109 template <typename T>
110 concept_map PlaceableTwoPassConcept<PlaceableTwoPassMFConcept<T> > {
111 
112  void measure(PlaceableTwoPassMFConcept<T>& t, extents_t& result)
113  { t.measure(result); }
114 
115  void place(PlaceableTwoPassMFConcept<T>& t, const place_data_t& place_data)
116  { t.place(place_data); }
117 
118  void measure_vertical(PlaceableTwoPassMFConcept<T>& t, extents_t& calculated_horizontal,
119  const place_data_t& placed_horizontal)
120  { t.measure_vertical(calculated_horizontal, placed_horizontal); }
121 };
122 
123 /*************************************************************************************************/
124 
128 template <typename T>
129 concept_map PlaceableTwoPassConcept<boost::reference_wrapper<PlaceableTwoPassConcept<T> > > {
130  void measure(boost::reference_wrapper<PlaceableTwoPassConcept<T> >& r,
131  extents_t& extents)
132  {
133  PlaceableTwoPassConcept<PlaceableTwoPassConcept<T> >::measure(
134  *r.get_pointer(), extents);
135  }
136  void place(boost::reference_wrapper<PlaceableTwoPassConcept<T> >& r,
137  const place_data_t& place_data)
138  {
139  PlaceableTwoPassConcept<PlaceableTwoPassConcept<T> >::place(
140  *r.get_pointer(), place_data);
141  }
142  void measure_vertical(boost::reference_wrapper<PlaceableTwoPassConcept<T> >& r,
143  extents_t& calculated_horizontal,
144  const place_data_t& placed_horizontal)
145  {
146  PlaceableTwoPassConcept<PlaceableTwoPassConcept<T> >::measure_vertical(
147  *r.get_pointer(), calculated_horizontal, placed_horizontal);
148  }
149 };
150 
151 /*************************************************************************************************/
152 
153 #else
154 
155 /*************************************************************************************************/
156 
157 
174 template <class T>
175 inline void measure(T& t, extents_t& result)
176 { t.measure(result); }
177 
178 /*************************************************************************************************/
179 
180 
205 template <class T>
206 inline void place(T& t, const place_data_t& place_data)
207 { t.place(place_data); }
208 
209 /*************************************************************************************************/
210 
219 template <class T>
221 {
222 #if !defined(ADOBE_NO_DOCUMENTATION)
223 
224  static void measure(T& t, extents_t& result)
225  {
226  using adobe::measure; // pick up default version which looks for member functions
227  measure(t, result); // unqualified to allow user versions
228  }
229 
230  static void place(T& t, const place_data_t& place_data)
231  {
232  using adobe::place; // pick up default version which looks for member functions
233  place(t, place_data); // unqualified to allow user versions
234  }
235 
236 // Concept checking:
237 
238  void constraints() {
239  // not yet: boost::function_requires<RegularConcept<Placeable> >();
240  // boost::function_requires<boost::CopyConstructibleConcept<Placeable> >();
241 
242  using adobe::measure;
243  measure(*placeable, extents);
244 
245  using adobe::place;
246  place(*placeable, place_data);
247  }
248 
249 //use pointers since not required to be default constructible
250  T* placeable;
251  const place_data_t place_data;
252  extents_t extents;
253 #endif
254 };
255 
264 template <class T>
266 {
267  static void measure(T* r, extents_t& result)
268  { PlaceableConcept<T>::measure(*r, result); }
269 
270  static void place(T* r, const place_data_t& place_data)
271  { PlaceableConcept<T>::place(*r, place_data); }
272 
273 #if !defined(ADOBE_NO_DOCUMENTATION)
274  void constraints() {
275  //boost concept check lib gets confused on VC8 without this
277  }
278 #endif
279 };
280 
281 /*************************************************************************************************/
282 
283 
303 template <class T>
304 inline void measure_vertical(T& t,
305  extents_t& calculated_horizontal,
306  const place_data_t& placed_horizontal)
307 { t.measure_vertical(calculated_horizontal, placed_horizontal); }
308 
309 /*************************************************************************************************/
310 
319 template <class T>
321 {
322 #if ! defined(ADOBE_NO_DOCUMENTATION)
323 
324  static void measure_vertical(T& t,
325  extents_t& calculated_horizontal,
326  const place_data_t& placed_horizontal)
327  {
329  measure_vertical(t, calculated_horizontal, placed_horizontal);
330  }
331 
332  void constraints() {
333  // not yet: boost::function_requires<RegularConcept<T> >();
334  //boost::function_requires<boost::CopyConstructibleConcept<T> >();
335 
336  using adobe::place;
337  place(*t2, this->place_data);
338 
339  using adobe::measure;
340  measure(*t2, this->extents);
341 
343  measure_vertical(*t2, this->extents, this->place_data);
344  }
345 
346  // Concept checking:
347  //use pointers since not required to be default constructible
348  T *t2;
349 #endif
350 
351 };
352 
361 template <class T>
364 {
365  static void measure(T* r, extents_t& extents)
366  {
368  *r, extents);
369  }
370  static void place(T* r, const place_data_t& place_data)
371  {
373  *r, place_data);
374  }
375  static void measure_vertical(T* r, extents_t& calculated_horizontal,
376  const place_data_t& placed_horizontal)
377  {
379  *r, calculated_horizontal, placed_horizontal);
380  }
381 
382 #if !defined(ADOBE_NO_DOCUMENTATION)
383  void constraints() {
384  //boost concept check lib gets confused on VC8 without this
386  }
387 #endif
388 };
389 
390 
391 /*************************************************************************************************/
392 
393 #endif
394 
395 /*************************************************************************************************/
396 
397 } // namespace adobe
398 
399 /*************************************************************************************************/
400 
401 #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