ADTF  3.18.2
class_info_detail.h
Go to the documentation of this file.
1 
7 #ifndef _ADTF_UCOM_ANT_CLASS_INFO_DETAIL_INCLUDES_HEADER_
8 #define _ADTF_UCOM_ANT_CLASS_INFO_DETAIL_INCLUDES_HEADER_
9 
10 #ifdef GetClassInfo
11 #undef GetClassInfo
12 #endif
13 
14 namespace adtf
15 {
16 namespace ucom
17 {
18 namespace ant
19 {
20 namespace detail
21 {
22 
28 template<typename T>
30 {
32  struct yes { char x[1]; };
34  struct no { char x[2]; };
35 
41  template<typename C>
42  static yes exists(typename C::template class_dependencies<static_cast<C*>(nullptr)>* = nullptr);
48  template<typename C> static no exists(...);
49 
50 public:
52  static const bool value = sizeof(exists<T>(nullptr)) == sizeof(yes);
53 };//template<typename T> class has_class_dependencies_type
54 
60 template<typename T>
62 {
64  struct yes { char x[1]; };
66  struct no { char x[2]; };
67 
73  template<typename C>
74  static yes exists(typename C::template class_versions<static_cast<C*>(nullptr)>* = nullptr);
80  template<typename C> static no exists(...);
81 
82 public:
84  static const bool value = sizeof(exists<T>(nullptr)) == sizeof(yes);
85 };//template<typename T> class has_class_versions_type
86 
87 
88 template<typename EnclosingType>
90 {
91 private:
92  template<typename U, bool = has_class_dependencies_type<U>::value>
93  struct class_dependency_traits //false
94  {
95  static const tDependencyDescription* dependency_data() { return nullptr; }
96  static std::size_t dependency_size() { return 0; }
97  };
98 
99  template<typename U>
100  struct class_dependency_traits <U, true>
101  {
102  static const tDependencyDescription* dependency_data()
103  {
104  return U::template class_dependencies<(U*)nullptr>::get_dependencies().data();
105  }
106 
107  static std::size_t dependency_size()
108  {
109  return U::template class_dependencies<(U*)nullptr>::get_dependencies().size();
110  }
111  };
112 
113  template<typename U, bool = has_class_versions_type<U>::value>
114  struct class_versions_traits //false
115  { //at least the default version set with ADTF_CLASS_ID() must be considered
116  static const tNamedVersion* version_data() { return &DefaultCVersion(); }
117  static const std::size_t version_size() { return 1; }
118  };
119 
120  template<typename U>
121  struct class_versions_traits <U, true>
122  {
123  static const tNamedVersion* version_data()
124  {
125  return U::template class_versions<(U*)nullptr>::get_versions().data();
126  }
127 
128  static const std::size_t version_size()
129  {
130  return U::template class_versions<(U*)nullptr>::get_versions().size();
131  }
132  };
133 
134 public:
135  static const adtf::ucom::ant::tNamedVersion& DefaultCVersion()
136  {
138  static const tNamedVersion oVersion{ UCOM_VERSION_ID, adtf::ucom::get_ucom_version_information() };
139  return oVersion;
140  }
141 
144  CVersions()
145  {
146  return GetClass_Info().GetCVersions();
147  }
148 
151  CDependencies()
152  {
153  return GetClass_Info().GetCDependencies();
154  }
155 
156  static const adtf::ucom::cClassInfo& GetClass_Info()
157  { //To prevent information being added twice to the static object, everything
158  //has to be passed via initialization
159  static const adtf::ucom::cClassInfo s_oClassInfo(
160  adtf::ucom::get_class_id<EnclosingType>(),
161  adtf::ucom::get_class_label<EnclosingType>(),
162  class_dependency_traits<EnclosingType>::dependency_data(),
163  class_dependency_traits<EnclosingType>::dependency_size(),
164  class_versions_traits<EnclosingType>::version_data(),
165  class_versions_traits<EnclosingType>::version_size());
166  return s_oClassInfo;
167  }
168 };//struct class_info_detail
169 
170 }//ns detail
171 }//ns ant
172 
173 namespace detail
174 {
176 using ant::detail::class_info_detail;
177 }//ns detail
178 
179 }//ns ucom
180 }//ns adtf
181 
182 #endif // _ADTF_UCOM_ANT_CLASS_INFO_DETAIL_INCLUDES_HEADER_
The Helper Storage Class for a IClassInfo.
Definition: class_info.h:27
Usable for enable_if<>: Compile time check whether a struct class_dependencies<> is available.
static const bool value
Evaluates to either size of yes or no, depending on existence of class_dependencies<>
static yes exists(typename C::template class_dependencies< static_cast< C * >(nullptr)> *=nullptr)
Overload taken if the class_dependencies<> exists.
static no exists(...)
Overload taken if the class_dependencies<> does not exist.
Usable for enable_if<>: Compile time check whether a struct class_versions<> is available.
static const bool value
Evaluates to either size of yes or no, depending on existence of class_versions<>
static no exists(...)
Overload taken if the class_versions<> does not exist.
static yes exists(typename C::template class_versions< static_cast< C * >(nullptr)> *=nullptr)
Overload taken if the class_versions<> exists.
ant::tDependencyDescription tDependencyDescription
Alias alwas bringing the latest version of ant::tDependencyDescription into scope.
ant::tNamedVersion tNamedVersion
Alias alwas bringing the latest version of ant::tNamedVersion into scope.
Namespace for entire ADTF SDK.
Return value if interface_info<> does not exist.
Return value if interface_info<> does not exist.
Return value if interface_info<> exists.
Adapter for begin and end iterators - usable as return and parameter value in interfaces.
Empty struct template to specialize implementations of iterator interfaces.
Definition: iterator_intf.h:28
Dependency description usable for ADTF_CLASS_DEPENDENCIES()
Named version information consisting of the modules name and its adtf_util::tVersion.