sigx++  2.0.1
signal_traits.h
Go to the documentation of this file.
1 #ifndef _SIGX_SIGNAL_TYPE_TRAIT_HPP_
2 #define _SIGX_SIGNAL_TYPE_TRAIT_HPP_
3 
4 /*
5  * Copyright 2005 Klaus Triendl
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the Free
19  * Software Foundation, 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #include <sigc++/signal_base.h>
24 #include <glibmm/signalproxy.h>
25 
26 
27 namespace sigx
28 {
29 
30  namespace internal
31  {
32 
34 {
35  typedef char sm;
36  struct middle {
37  char memory[32];
38  };
39  struct big {
40  char memory[64];
41  };
42 
43  enum Type
44  {
45  NOBASE = sizeof(sm),
46  BASE1 = sizeof(middle),
47  BASE2 = sizeof(big)
48  };
49 };
50 
59 template<typename T_derived, typename T_base1, typename T_base2>
61 {
62 private:
63 #ifndef SIGC_SELF_REFERENCE_IN_MEMBER_INITIALIZATION
64 
65  //Certain compilers, notably GCC 3.2, require these functions to be inside an inner class.
66  struct internal_class
67  {
68  static derivation_helper::sm is_base_class_(...);
69  static derivation_helper::middle is_base_class_(typename sigc::type_trait<T_base1>::pointer);
70  static derivation_helper::big is_base_class_(typename sigc::type_trait<T_base2>::pointer);
71  };
72 
73 public:
74  static const int value =
75  sizeof(internal_class::is_base_class_(reinterpret_cast<typename sigc::type_trait<T_derived>::pointer>(0)));
76 
77 #else //SIGC_SELF_REFERENCE_IN_MEMBER_INITIALIZATION
78 
79  //The AIX xlC compiler does not like these 2 functions being in the inner class.
80  //It says "The incomplete type "test" must not be used as a qualifier.
81  //It does not seem necessary anyway. murrayc.
82  static derivation_helper::sm is_base_class_(...);
83  static derivation_helper::middle is_base_class_(typename sigc::type_trait<T_base1>::pointer);
84  static derivation_helper::big is_base_class_(typename sigc::type_trait<T_base2>::pointer);
85 
86 public:
87  static const int value =
88  sizeof(is_base_class_(reinterpret_cast<typename sigc::type_trait<T_derived>::pointer>(0)));
89 
90 #endif //SIGC_SELF_REFERENCE_IN_MEMBER_INITIALIZATION
91 
92  void avoid_gcc3_warning_(); //Not implemented. g++ 3.3.5 (but not 3.3.4, and not 3.4) warn that there are no public methods, even though there is a public variable.
93 };
94 
95 
97 {
101 };
102 
103 
109 template<typename T_signal, int I_oneof = is_derived_from<T_signal, sigc::signal_base, Glib::SignalProxyNormal>::value>
111 {
112  static const signal_group type = SIGGROUP_IRRELEVANT;
113 };
114 
117 template<typename T_signal>
119 {
120  static const signal_group type = SIGGROUP_SIGC;
121 };
122 
125 template<typename T_signal>
127 {
128  static const signal_group type = SIGGROUP_GLIB_PROXY;
129 };
130 
131 
132  } // namespace internal
133 
134 } // namespace sigx
135 
136 
137 #endif // end file guard