1 // -*- c++ -*-
2 /* Do not edit! -- generated file */
3 
4 
5 #ifndef _SIGC_MACROS_LIMIT_REFERENCEHM4_
6 #define _SIGC_MACROS_LIMIT_REFERENCEHM4_
7 
8 
9 #include <sigc++/type_traits.h>
10 #include <sigc++/trackable.h>
11 
12 
13 namespace sigc {
14 
15 
16 /** A limit_reference<Foo> object stores a reference (Foo&), but make sure that,
17  * if Foo inherits from sigc::trackable, then visit_each<>() will "limit" itself to the
18  * sigc::trackable reference instead of the derived reference. This avoids use of
19  * a reference to the derived type when the derived destructor has run. That can be
20  * a problem when using virtual inheritance.
21  *
22  * If Foo inherits from trackable then both the derived reference and the
23  * sigc::trackable reference are stored, so we can later retrieve the sigc::trackable
24  * reference without doing an implicit conversion. To retrieve the derived reference
25  * (so that you invoke methods or members of it), use invoke(). To retrieve the trackable
26  * reference (so that you can call visit_each() on it), you use visit().
27  *
28  * If Foo does not inherit from sigc::trackable then invoke() and visit() just return the
29  * derived reference.
30  *
31  * This is used for bound (sigc::bind) slot parameters (via bound_argument), bound return values,
32  * and, with mem_fun(), the reference to the handling object.
33  *
34  * - @e T_type The type of the reference.
35  */
36 template <class T_type,
37           bool I_derives_trackable =
38             is_base_and_derived<trackable, T_type>::value>
39 class limit_reference
40 {
41 public:
42   /** Constructor.
43    * @param _A_target The reference to limit.
44    */
limit_reference(T_type & _A_target)45   limit_reference(T_type& _A_target)
46     : visited(_A_target)
47     {}
48 
49   /** Retrieve the entity to visit for visit_each().
50    * Depending on the template specialization, this is either a derived reference, or sigc::trackable& if T_type derives from sigc::trackable.
51    * @return The reference.
52    */
visit()53   inline const T_type& visit() const
54     { return visited; }
55 
56   /** Retrieve the reference.
57    * This is always a reference to the derived instance.
58    * @return The reference.
59    */
invoke()60   inline T_type& invoke() const
61     { return visited; }
62 
63 private:
64   /** The reference.
65    */
66   T_type& visited;
67 };
68 
69 /** limit_reference object for a class that derives from trackable.
70  * - @e T_type The type of the reference.
71  */
72 template <class T_type>
73 class limit_reference<T_type, true>
74 {
75 public:
76   /** Constructor.
77    * @param _A_target The reference to limit.
78    */
limit_reference(T_type & _A_target)79   limit_reference(T_type& _A_target)
80     : visited(_A_target),
81       invoked(_A_target)
82     {}
83 
84   /** Retrieve the entity to visit for visit_each().
85    * Depending on the template specialization, this is either a derived reference, or sigc::trackable& if T_type derives from sigc::trackable.
86    * @return The reference.
87    */
visit()88   inline const trackable& visit() const
89     { return visited; }
90 
91   /** Retrieve the reference.
92    * This is always a reference to the derived instance.
93    * @return The reference.
94    */
invoke()95   inline T_type& invoke() const
96     { return invoked; }
97 
98 private:
99   /** The trackable reference.
100    */
101   trackable& visited;
102 
103   /** The reference.
104    */
105   T_type& invoked;
106 };
107 
108 /** Implementation of visit_each() specialized for the limit_reference
109  * class, to call visit_each() on the entity returned by the limit_reference's
110  * visit() method.
111  * - @e T_action The type of functor to invoke.
112  * - @e T_type The type of the reference.
113  * @param _A_action The functor to invoke.
114  * @param _A_argument The visited instance.
115  */
116 template <class T_action, class T_type, bool I_derives_trackable>
117 void
visit_each(const T_action & _A_action,const limit_reference<T_type,I_derives_trackable> & _A_target)118 visit_each(const T_action& _A_action,
119            const limit_reference<T_type, I_derives_trackable>& _A_target)
120 {
121   visit_each(_A_action, _A_target.visit());
122 }
123 
124 
125 /** A const_limit_reference<Foo> object stores a reference (Foo&), but make sure that,
126  * if Foo inherits from sigc::trackable, then visit_each<>() will "limit" itself to the
127  * sigc::trackable reference instead of the derived reference. This avoids use of
128  * a reference to the derived type when the derived destructor has run. That can be
129  * a problem when using virtual inheritance.
130  *
131  * If Foo inherits from trackable then both the derived reference and the
132  * sigc::trackable reference are stored, so we can later retrieve the sigc::trackable
133  * reference without doing an implicit conversion. To retrieve the derived reference
134  * (so that you invoke methods or members of it), use invoke(). To retrieve the trackable
135  * reference (so that you can call visit_each() on it), you use visit().
136  *
137  * If Foo does not inherit from sigc::trackable then invoke() and visit() just return the
138  * derived reference.
139  *
140  * This is used for bound (sigc::bind) slot parameters (via bound_argument), bound return values,
141  * and, with mem_fun(), the reference to the handling object.
142  *
143  * - @e T_type The type of the reference.
144  */
145 template <class T_type,
146           bool I_derives_trackable =
147             is_base_and_derived<trackable, T_type>::value>
148 class const_limit_reference
149 {
150 public:
151   /** Constructor.
152    * @param _A_target The reference to limit.
153    */
const_limit_reference(const T_type & _A_target)154   const_limit_reference(const T_type& _A_target)
155     : visited(_A_target)
156     {}
157 
158   /** Retrieve the entity to visit for visit_each().
159    * Depending on the template specialization, this is either a derived reference, or sigc::trackable& if T_type derives from sigc::trackable.
160    * @return The reference.
161    */
visit()162   inline const T_type& visit() const
163     { return visited; }
164 
165   /** Retrieve the reference.
166    * This is always a reference to the derived instance.
167    * @return The reference.
168    */
invoke()169   inline const T_type& invoke() const
170     { return visited; }
171 
172 private:
173   /** The reference.
174    */
175   const T_type& visited;
176 };
177 
178 /** const_limit_reference object for a class that derives from trackable.
179  * - @e T_type The type of the reference.
180  */
181 template <class T_type>
182 class const_limit_reference<T_type, true>
183 {
184 public:
185   /** Constructor.
186    * @param _A_target The reference to limit.
187    */
const_limit_reference(const T_type & _A_target)188   const_limit_reference(const T_type& _A_target)
189     : visited(_A_target),
190       invoked(_A_target)
191     {}
192 
193   /** Retrieve the entity to visit for visit_each().
194    * Depending on the template specialization, this is either a derived reference, or sigc::trackable& if T_type derives from sigc::trackable.
195    * @return The reference.
196    */
visit()197   inline const trackable& visit() const
198     { return visited; }
199 
200   /** Retrieve the reference.
201    * This is always a reference to the derived instance.
202    * @return The reference.
203    */
invoke()204   inline const T_type& invoke() const
205     { return invoked; }
206 
207 private:
208   /** The trackable reference.
209    */
210   const trackable& visited;
211 
212   /** The reference.
213    */
214   const T_type& invoked;
215 };
216 
217 /** Implementation of visit_each() specialized for the const_limit_reference
218  * class, to call visit_each() on the entity returned by the const_limit_reference's
219  * visit() method.
220  * - @e T_action The type of functor to invoke.
221  * - @e T_type The type of the reference.
222  * @param _A_action The functor to invoke.
223  * @param _A_argument The visited instance.
224  */
225 template <class T_action, class T_type, bool I_derives_trackable>
226 void
visit_each(const T_action & _A_action,const const_limit_reference<T_type,I_derives_trackable> & _A_target)227 visit_each(const T_action& _A_action,
228            const const_limit_reference<T_type, I_derives_trackable>& _A_target)
229 {
230   visit_each(_A_action, _A_target.visit());
231 }
232 
233 
234 /** A volatile_limit_reference<Foo> object stores a reference (Foo&), but make sure that,
235  * if Foo inherits from sigc::trackable, then visit_each<>() will "limit" itself to the
236  * sigc::trackable reference instead of the derived reference. This avoids use of
237  * a reference to the derived type when the derived destructor has run. That can be
238  * a problem when using virtual inheritance.
239  *
240  * If Foo inherits from trackable then both the derived reference and the
241  * sigc::trackable reference are stored, so we can later retrieve the sigc::trackable
242  * reference without doing an implicit conversion. To retrieve the derived reference
243  * (so that you invoke methods or members of it), use invoke(). To retrieve the trackable
244  * reference (so that you can call visit_each() on it), you use visit().
245  *
246  * If Foo does not inherit from sigc::trackable then invoke() and visit() just return the
247  * derived reference.
248  *
249  * This is used for bound (sigc::bind) slot parameters (via bound_argument), bound return values,
250  * and, with mem_fun(), the reference to the handling object.
251  *
252  * - @e T_type The type of the reference.
253  */
254 template <class T_type,
255           bool I_derives_trackable =
256             is_base_and_derived<trackable, T_type>::value>
257 class volatile_limit_reference
258 {
259 public:
260   /** Constructor.
261    * @param _A_target The reference to limit.
262    */
volatile_limit_reference(T_type & _A_target)263   volatile_limit_reference(T_type& _A_target)
264     : visited(_A_target)
265     {}
266 
267   /** Retrieve the entity to visit for visit_each().
268    * Depending on the template specialization, this is either a derived reference, or sigc::trackable& if T_type derives from sigc::trackable.
269    * @return The reference.
270    */
visit()271   inline const T_type& visit() const
272     { return visited; }
273 
274   /** Retrieve the reference.
275    * This is always a reference to the derived instance.
276    * @return The reference.
277    */
invoke()278   inline volatile T_type& invoke() const
279     { return visited; }
280 
281 private:
282   /** The reference.
283    */
284   T_type& visited;
285 };
286 
287 /** volatile_limit_reference object for a class that derives from trackable.
288  * - @e T_type The type of the reference.
289  */
290 template <class T_type>
291 class volatile_limit_reference<T_type, true>
292 {
293 public:
294   /** Constructor.
295    * @param _A_target The reference to limit.
296    */
volatile_limit_reference(T_type & _A_target)297   volatile_limit_reference(T_type& _A_target)
298     : visited(_A_target),
299       invoked(_A_target)
300     {}
301 
302   /** Retrieve the entity to visit for visit_each().
303    * Depending on the template specialization, this is either a derived reference, or sigc::trackable& if T_type derives from sigc::trackable.
304    * @return The reference.
305    */
visit()306   inline const trackable& visit() const
307     { return visited; }
308 
309   /** Retrieve the reference.
310    * This is always a reference to the derived instance.
311    * @return The reference.
312    */
invoke()313   inline volatile T_type& invoke() const
314     { return invoked; }
315 
316 private:
317   /** The trackable reference.
318    */
319   trackable& visited;
320 
321   /** The reference.
322    */
323   T_type& invoked;
324 };
325 
326 /** Implementation of visit_each() specialized for the volatile_limit_reference
327  * class, to call visit_each() on the entity returned by the volatile_limit_reference's
328  * visit() method.
329  * - @e T_action The type of functor to invoke.
330  * - @e T_type The type of the reference.
331  * @param _A_action The functor to invoke.
332  * @param _A_argument The visited instance.
333  */
334 template <class T_action, class T_type, bool I_derives_trackable>
335 void
visit_each(const T_action & _A_action,const volatile_limit_reference<T_type,I_derives_trackable> & _A_target)336 visit_each(const T_action& _A_action,
337            const volatile_limit_reference<T_type, I_derives_trackable>& _A_target)
338 {
339   visit_each(_A_action, _A_target.visit());
340 }
341 
342 
343 /** A const_volatile_limit_reference<Foo> object stores a reference (Foo&), but make sure that,
344  * if Foo inherits from sigc::trackable, then visit_each<>() will "limit" itself to the
345  * sigc::trackable reference instead of the derived reference. This avoids use of
346  * a reference to the derived type when the derived destructor has run. That can be
347  * a problem when using virtual inheritance.
348  *
349  * If Foo inherits from trackable then both the derived reference and the
350  * sigc::trackable reference are stored, so we can later retrieve the sigc::trackable
351  * reference without doing an implicit conversion. To retrieve the derived reference
352  * (so that you invoke methods or members of it), use invoke(). To retrieve the trackable
353  * reference (so that you can call visit_each() on it), you use visit().
354  *
355  * If Foo does not inherit from sigc::trackable then invoke() and visit() just return the
356  * derived reference.
357  *
358  * This is used for bound (sigc::bind) slot parameters (via bound_argument), bound return values,
359  * and, with mem_fun(), the reference to the handling object.
360  *
361  * - @e T_type The type of the reference.
362  */
363 template <class T_type,
364           bool I_derives_trackable =
365             is_base_and_derived<trackable, T_type>::value>
366 class const_volatile_limit_reference
367 {
368 public:
369   /** Constructor.
370    * @param _A_target The reference to limit.
371    */
const_volatile_limit_reference(const T_type & _A_target)372   const_volatile_limit_reference(const T_type& _A_target)
373     : visited(_A_target)
374     {}
375 
376   /** Retrieve the entity to visit for visit_each().
377    * Depending on the template specialization, this is either a derived reference, or sigc::trackable& if T_type derives from sigc::trackable.
378    * @return The reference.
379    */
visit()380   inline const T_type& visit() const
381     { return visited; }
382 
383   /** Retrieve the reference.
384    * This is always a reference to the derived instance.
385    * @return The reference.
386    */
invoke()387   inline const volatile T_type& invoke() const
388     { return visited; }
389 
390 private:
391   /** The reference.
392    */
393   const T_type& visited;
394 };
395 
396 /** const_volatile_limit_reference object for a class that derives from trackable.
397  * - @e T_type The type of the reference.
398  */
399 template <class T_type>
400 class const_volatile_limit_reference<T_type, true>
401 {
402 public:
403   /** Constructor.
404    * @param _A_target The reference to limit.
405    */
const_volatile_limit_reference(const T_type & _A_target)406   const_volatile_limit_reference(const T_type& _A_target)
407     : visited(_A_target),
408       invoked(_A_target)
409     {}
410 
411   /** Retrieve the entity to visit for visit_each().
412    * Depending on the template specialization, this is either a derived reference, or sigc::trackable& if T_type derives from sigc::trackable.
413    * @return The reference.
414    */
visit()415   inline const trackable& visit() const
416     { return visited; }
417 
418   /** Retrieve the reference.
419    * This is always a reference to the derived instance.
420    * @return The reference.
421    */
invoke()422   inline const volatile T_type& invoke() const
423     { return invoked; }
424 
425 private:
426   /** The trackable reference.
427    */
428   const trackable& visited;
429 
430   /** The reference.
431    */
432   const T_type& invoked;
433 };
434 
435 /** Implementation of visit_each() specialized for the const_volatile_limit_reference
436  * class, to call visit_each() on the entity returned by the const_volatile_limit_reference's
437  * visit() method.
438  * - @e T_action The type of functor to invoke.
439  * - @e T_type The type of the reference.
440  * @param _A_action The functor to invoke.
441  * @param _A_argument The visited instance.
442  */
443 template <class T_action, class T_type, bool I_derives_trackable>
444 void
visit_each(const T_action & _A_action,const const_volatile_limit_reference<T_type,I_derives_trackable> & _A_target)445 visit_each(const T_action& _A_action,
446            const const_volatile_limit_reference<T_type, I_derives_trackable>& _A_target)
447 {
448   visit_each(_A_action, _A_target.visit());
449 }
450 
451 
452 } /* namespace sigc */
453 
454 
455 #endif /* _SIGC_MACROS_LIMIT_REFERENCEHM4_ */
456