ADTF
class_id.h
Go to the documentation of this file.
1 
7 #ifndef _ADTF_UCOM_ANT_CLASS_ID_INCLUDES_HEADER_
8 #define _ADTF_UCOM_ANT_CLASS_ID_INCLUDES_HEADER_
9 
10 #ifdef GetClassInfo
11 #undef GetClassInfo
12 #endif
13 
14 //#################################################################################################
15 //##################################### DEFINES ###################################################
16 //#################################################################################################
17 #ifndef ADTF_CLASS_ID_NAME
18 
33 #define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel) \
34  typedef _class class_type; \
35  template<_class*> struct class_info : \
36  public adtf::ucom::ant::detail::class_info_detail<class_type> \
37  { \
38  using adtf::ucom::ant::detail::class_info_detail<class_type>::CVersions; \
39  using adtf::ucom::ant::detail::class_info_detail<class_type>::CDependencies; \
40  static const char* CID() { return _strcid; } \
41  static const char* CLabel() { return _strclabel ? _strclabel : CID();} \
42  }
43 #endif //ADTF_CLASS_ID_NAME
44 
56 #ifndef ADTF_CLASS_INFO_IMPL
57 #define ADTF_CLASS_INFO_IMPL(_class) \
58  const char* GetCID() const override \
59  { \
60  return adtf::ucom::get_class_id<_class>(); \
61  } \
62  const char* GetCLabel() const override \
63  { \
64  return adtf::ucom::get_class_label<_class>(); \
65  } \
66  adtf::ucom::ant::iterator_adapter<const adtf::ucom::ant::tDependencyDescription, \
67  adtf::ucom::ant::pointer_iterator> \
68  GetCDependencies() const override \
69  { \
70  return adtf::ucom::get_class_dependencies<_class>(); \
71  } \
72  adtf::ucom::ant::iterator_adapter<const adtf::ucom::ant::tNamedVersion, \
73  adtf::ucom::ant::pointer_iterator> \
74  GetCVersions() const override \
75  { \
76  return adtf::ucom::get_class_versions<_class>(); \
77  }
78 #endif
79 
80 #ifndef ADTF_CLASS_ID
91 #define ADTF_CLASS_ID(_class, _strcid) ADTF_CLASS_ID_NAME(_class, _strcid, nullptr)
92 #endif //ADTF_CLASS_ID
93 
94 namespace adtf
95 {
96 namespace ucom
97 {
98 namespace ant
99 {
100 
109 template<typename classT>
110 constexpr const char* get_class_id()
111 {
112  using namespace std; //remove_const, remove_pointer, is_same
113  typedef typename remove_const<typename remove_pointer<classT>::type>::type value_type;
114  static_assert(is_same<value_type, typename value_type::class_type>::value,
115  "get_class_id<> failed. Check whether your interface correctly defined ADTF_CLASS_ID()");
116 
117  return value_type::template class_info<(value_type*)nullptr>::CID();
118 }
119 
124 template<typename classT>
125 constexpr const char* get_class_id(const classT&) { return get_class_id<classT>(); }
126 
131 template<typename classT>
132 constexpr const char* get_class_id(const classT*) { return get_class_id<classT>(); }
133 
142 template<typename classT>
143 constexpr const char* get_class_label()
144 {
145  using namespace std; //remove_const, remove_pointer, is_same
146  typedef typename remove_const<typename remove_pointer<classT>::type>::type value_type;
147  static_assert(is_same<value_type, typename value_type::class_type>::value,
148  "get_class_label<> failed. Check whether your interface correctly defined "\
149  "ADTF_CLASS_ID_NAME()");
150 
151  return value_type::template class_info<(value_type*)nullptr>::CLabel();
152 }
153 
158 template<typename classT>
159 constexpr const char* get_class_label(const classT&) { return get_class_label<classT>(); }
160 
165 template<typename classT>
166 constexpr const char* get_class_label(const classT*) { return get_class_label<classT>(); }
167 
168 }//ns ant
169 
171 using ant::get_class_id;
172 
175 
176 }//ns ucom
177 }//ns adtf
178 
179 #endif //_ADTF_UCOM_ANT_CLASS_ID_INCLUDES_HEADER_
constexpr const char * get_class_label()
Get the class label (corresponding to the CID) of the Class type (a readable name !...
Definition: class_id.h:143
constexpr const char * get_class_id()
Get the class id (CID) of the Class type.
Definition: class_id.h:110
Namespace for entire ADTF SDK.