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