ADTF
class_info.h
Go to the documentation of this file.
1 
7 #ifndef _ADTF_UCOM_ANT_CLASS_INFO_INCLUDES_HEADER_
8 #define _ADTF_UCOM_ANT_CLASS_INFO_INCLUDES_HEADER_
9 
10 namespace adtf
11 {
12 namespace ucom
13 {
14 namespace ant
15 {
16 namespace detail
17 {
18 //forward declarations
19 template<typename> struct class_info_detail;
20 }
26 class DOEXPORT cClassInfo : public catwo::object<IClassInfo>
27 {
29 
30 public:
31  cClassInfo() = default;
32  //TODO!!!! Temporarily allow copying by interface, cause factory and runtime make copies!!!
33  cClassInfo(const IClassInfo&);
34  cClassInfo& operator=(const cClassInfo&) = delete;
35 
36  //allow moving
37  cClassInfo(cClassInfo&&) = default;
38  cClassInfo& operator=(cClassInfo&&) = default;
39 
41  virtual ~cClassInfo() = default;
42 
43 public: //Implements IClassInfo
44  const char* GetCID() const override;
45  const char* GetCLabel() const override;
47  const override;
48  iterator_adapter<const tNamedVersion, pointer_iterator> GetCVersions() const override;
49 
50 private:
51  //allow static method to construct class info with detailed information
52  template<typename> friend struct adtf::ucom::ant::detail::class_info_detail;
53 
54  cClassInfo(const char* strIdentifier, //identifier
55  const char* strClassLabel, //label
56  const tDependencyDescription* pFirstDependency, std::size_t nDependencies, //dependencies
57  const tNamedVersion* pVersion, std::size_t nVersions); //versions
58 };//class cClassInfo
59 
68 template<typename classT>
70 {
71  using namespace std; //remove_const, remove_pointer, is_same
72  typedef typename remove_const<typename remove_pointer<classT>::type>::type value_type;
73  static_assert(is_same<value_type, typename value_type::class_type>::value,
74  "get_class_info_reference<> failed. Check whether your interface correctly defined " \
75  "ADTF_CLASS_ID()");
76 
77  return classT::template class_info<(classT*)nullptr>::GetClass_Info();
78 }
79 
84 template<typename classT>
85 constexpr const cClassInfo& get_class_info_reference(const classT*)
86 {
87  return get_class_info_reference<classT>();
88 }
89 
94 template<typename classT>
95 constexpr const cClassInfo& get_class_info_reference(const classT&)
96 {
97  return get_class_info_reference<classT>();
98 }
99 
108 template<typename classT>
110 {
111  return make_object_ptr<const cClassInfo>(
112  static_cast<const IClassInfo&>(get_class_info_reference<classT>()));
113 }
114 
119 template<typename classT>
121 {
122  return get_class_info<classT>();
123 }
124 
129 template<typename classT>
131 {
132  return get_class_info<classT>();
133 }
134 
135 }//ns ant
136 
138 using ant::cClassInfo;
139 
141 using ant::get_class_info;
142 
145 
146 }//ns ucom
147 }//ns adtf
148 
149 #endif // _ADTF_UCOM_ANT_CLASS_INFO_INCLUDES_HEADER_
@ brief The IClassInfo interface provides a standardized way to access type information.
The Helper Storage Class for a IClassInfo.
Definition: class_info.h:27
virtual ~cClassInfo()=default
Default destructor.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
Definition: object.h:379
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
Definition: d_ptr.h:270
object_ptr< const adtf::ucom::ant::IClassInfo > get_class_info()
Get the class info of the Class type.
Definition: class_info.h:109
constexpr const cClassInfo & get_class_info_reference()
Get reference to static class info constant of the classT type.
Definition: class_info.h:69
Namespace for entire ADTF SDK.
Adapter for begin and end iterators - usable as return and parameter value in interfaces.
Dependency description usable for ADTF_CLASS_DEPENDENCIES()
Named version information consisting of the modules name and its adtf_util::tVersion.