-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.h
35 lines (29 loc) · 2.26 KB
/
macros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef AUTOWIRED_MACROS_H
#define AUTOWIRED_MACROS_H
#include <type_traits>
#include "./types_check/index.h"
#define AUTO_WIRED_DECLARE_BEGIN(ClassType, ...) \
private: \
friend class auto_wired::AutoWired; \
friend class auto_wired::internal::has_get_auto_wired_register_options<ClassType>; \
int auto_wired_flag_{0}; \
\
static const auto_wired::AutoWired::RegisterOptions& getAutoWiredRegisterOptions() { \
static const auto register_options = [](auto&&... opts) { \
auto o = auto_wired::AutoWired::RegisterOptions::CreateRegisterOptions(opts...); \
return o; \
}(__VA_ARGS__); \
\
return register_options; \
} \
\
using ClassTypeForAutoWired = ClassType; \
\
public: \
ClassType([[maybe_unused]] auto_wired::AutoWired& w = auto_wired::AutoWired::Instance()) : auto_wired_flag_(1)
#define AUTO_WIRED_DECLARE_CLASS(name, ...) \
, name(w.GetClassRefWithAddClassRelations<ClassTypeForAutoWired, std::remove_reference_t<decltype(name)>>( \
getAutoWiredRegisterOptions().custom_name, ##__VA_ARGS__))
#define AUTO_WIRED_DECLARE_END() \
{}
#endif // AUTOWIRED_MACROS_H