ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
class_dependencies.h
Go to the documentation of this file.
1
7#ifndef _ADTF_UCOM_ANT_CLASS_DEPENDENCIES_INCLUDES_HEADER_
8#define _ADTF_UCOM_ANT_CLASS_DEPENDENCIES_INCLUDES_HEADER_
9
10#include <tuple>
11#include <array>
12#include <type_traits>
13
14//#################################################################################################
15//##################################### DEFINES ###################################################
16//#################################################################################################
17
18#ifndef ADTF_CLASS_DEPENDENCIES
19
20#ifndef PROVIDE_INTERFACE
25#define PROVIDE_INTERFACE(_interface) \
26 adtf::ucom::ant::tDependencyDescription { \
27 adtf::ucom::ant::tDependencyDescription::eDescriptionType::DT_PROVIDE, \
28 adtf::ucom::ant::get_iid<_interface>() }
29#endif // !PROVIDE_INTERFACE
30
31#ifndef REQUIRE_INTERFACE
36#define REQUIRE_INTERFACE(_interface) \
37 adtf::ucom::ant::tDependencyDescription{ \
38 adtf::ucom::ant::tDependencyDescription::eDescriptionType::DT_REQUIRE, \
39 adtf::ucom::ant::get_iid<_interface>() }
40#endif // !REQUIRE_INTERFACE
41
42#ifndef REQUIRE_OPTIONAL_INTERFACE
47#define REQUIRE_OPTIONAL_INTERFACE(_interface) \
48 adtf::ucom::ant::tDependencyDescription{ \
49 adtf::ucom::ant::tDependencyDescription::eDescriptionType::DT_REQUIRE_OPTIONAL, \
50 adtf::ucom::ant::get_iid<_interface>() }
51#endif // !REQUIRE_OPTIONAL_INTERFACE
61#define ADTF_CLASS_DEPENDENCIES(...) \
62 /* the parameter is only used for compile time check with @c has_class_dependencies_type */ \
63 /* without this neat trick, the compile time check would also succeed if any base class */ \
64 /* defines the static method. Note: \c class_type is declared in ADTF_CLASS_ID_NAME() ! */ \
65 template<class_type*> struct class_dependencies \
66 { /* number of args needed for array during compile time - how this is done: */ \
67 /* https://tinyurl.com/zhd3kly */ \
68 template<std::size_t ArrSize = \
69 std::tuple_size<decltype(std::make_tuple(__VA_ARGS__))>::value> \
70 static const std::array<adtf::ucom::tDependencyDescription, ArrSize>& get_dependencies()\
71 { \
72 static const std::array<adtf::ucom::tDependencyDescription, ArrSize> arr = { \
73 __VA_ARGS__ }; \
74 return arr; \
75 } \
76 }
77#endif //ADTF_CLASS_DEPENDENCIES
78
79namespace adtf
80{
81namespace ucom
82{
83namespace ant
84{
85
94template<typename classT>
97{
98 using namespace std; //remove_const, remove_pointer, is_same
99 typedef typename remove_const<typename remove_pointer<classT>::type>::type value_type;
100 static_assert(is_same<value_type, typename value_type::class_type>::value,
101 "get_class_dependencies<> failed. Check whether your interface correctly defined " \
102 "ADTF_CLASS_ID()");
103
104 return value_type::template class_info<(value_type*)nullptr>::CDependencies();
105}
106
111template<typename classT>
114{
116}
117
122template<typename classT>
125{
127}
128
129}//ns ant
130
133
134}//ns ucom
135}//ns adtf
136
137#endif //_ADTF_UCOM_ANT_CLASS_DEPENDENCIES_INCLUDES_HEADER_
constexpr iterator_adapter< const tDependencyDescription, pointer_iterator > get_class_dependencies()
Get the class dependencies (corresponding to the CID) of the Class type.
ant::iterator_adapter< T, IteratorType > iterator_adapter
Alias always bringing the latest version of ant::iterator_adapter into scope.
Namespace for entire ADTF SDK.