ADTF  3.18.2
class_versions.h
Go to the documentation of this file.
1 
7 #ifndef _ADTF_UCOM_ANT_CLASS_VERSIONS_INCLUDES_HEADER_
8 #define _ADTF_UCOM_ANT_CLASS_VERSIONS_INCLUDES_HEADER_
9 
10 #include <tuple>
11 #include <array>
12 #include <type_traits>
13 
14 //#################################################################################################
15 //##################################### DEFINES ###################################################
16 //#################################################################################################
17 #ifndef UCOM_CLASS_VERSIONS
25 #define UCOM_CLASS_VERSIONS(...) \
26  /* the parameter is only used for compile time check with @c has_class_versions_type */ \
27  /* without this neat trick, the compile time check would also succeed if any base class */ \
28  /* defines the static method. Note: \c class_type is declared in ADTF_CLASS_ID_NAME() ! */ \
29  template<class_type*> struct class_versions \
30  { /* See above. Also note the +1 of array size due to the default version which is not */ \
31  /* given via macro argument but by class_info<T*> */ \
32  template<std::size_t ArrSize = \
33  std::tuple_size<decltype(std::make_tuple(__VA_ARGS__, 1))>::value> \
34  static const std::array<adtf::ucom::tNamedVersion, ArrSize>& get_versions() \
35  { \
36  static const std::array<adtf::ucom::tNamedVersion, ArrSize> arr = { \
37  __VA_ARGS__ , \
38  class_type::class_info<(class_type*)nullptr>::DefaultCVersion() \
39  }; \
40  return arr; \
41  } \
42  }
43 #endif //UCOM_CLASS_VERSIONS
44 
45 
46 namespace adtf
47 {
48 namespace ucom
49 {
50 namespace ant
51 {
52 
60 template<typename ...Args>
61 constexpr tNamedVersion add_version(const char* i_strProduct, Args... args)
62 {
63  return tNamedVersion {
64  i_strProduct,
65  adtf_util::tVersion{ static_cast<adtf_util::tVersion::value_type>(args)...}
66  };
67 }
68 
77 template<typename classT>
79 {
80  using namespace std; //remove_const, remove_pointer, is_same
81  typedef typename remove_const<typename remove_pointer<classT>::type>::type value_type;
82  static_assert(is_same<value_type, typename value_type::class_type>::value,
83  "get_class_versions<> failed. Check whether your interface correctly defined "\
84  "ADTF_CLASS_ID()");
85 
86  return value_type::template class_info<(value_type*)nullptr>::CVersions();
87 }
88 
93 template<typename classT>
95 {
96  return get_class_versions<classT>();
97 }
98 
103 template<typename classT>
105 {
106  return get_class_versions<classT>();
107 }
108 
109 }//ns ant
110 
112 using ant::add_version;
113 
116 
117 }//ns ucom
118 }//ns adtf
119 
120 #endif //_ADTF_UCOM_ANT_CLASS_VERSIONS_INCLUDES_HEADER_
constexpr iterator_adapter< const tNamedVersion, pointer_iterator > get_class_versions()
Get the class versions (corresponding to the CID) of the Class type.
constexpr tNamedVersion add_version(const char *i_strProduct, Args... args)
Used for parameter list in ADTF_CLASS_DEPENDENCIES() to define version information.
Namespace for entire ADTF SDK.
Adapter for begin and end iterators - usable as return and parameter value in interfaces.
Named version information consisting of the modules name and its adtf_util::tVersion.