|
27 | 27 | * POSSIBILITY OF SUCH DAMAGE.
|
28 | 28 | */
|
29 | 29 |
|
30 |
| -#ifndef CLASS_LOADER_REGISTER_MACRO_H_DEFINED |
31 |
| -#define CLASS_LOADER_REGISTER_MACRO_H_DEFINED |
| 30 | +#ifndef CLASS_LOADER__CLASS_LOADER_REGISTER_MACRO_H_ |
| 31 | +#define CLASS_LOADER__CLASS_LOADER_REGISTER_MACRO_H_ |
32 | 32 |
|
33 |
| -#include "class_loader_core.h" |
34 |
| -#include <console_bridge/console.h> |
| 33 | +#include <string> |
35 | 34 |
|
| 35 | +#include "class_loader/class_loader_core.h" |
36 | 36 | #include "class_loader/console_bridge_compatibility.h"
|
37 | 37 |
|
| 38 | +#include "console_bridge/console.h" |
| 39 | + |
38 | 40 | #define CLASS_LOADER_REGISTER_CLASS_INTERNAL_WITH_MESSAGE(Derived, Base, UniqueID, Message) \
|
39 |
| -namespace \ |
40 |
| -{\ |
41 |
| - struct ProxyExec##UniqueID \ |
42 |
| - {\ |
| 41 | + namespace \ |
| 42 | + { \ |
| 43 | + struct ProxyExec ## UniqueID \ |
| 44 | + { \ |
43 | 45 | typedef Derived _derived; \
|
44 |
| - typedef Base _base; \ |
45 |
| - ProxyExec##UniqueID() \ |
| 46 | + typedef Base _base; \ |
| 47 | + ProxyExec ## UniqueID() \ |
46 | 48 | { \
|
47 |
| - if(std::string(Message)!="")\ |
48 |
| - CONSOLE_BRIDGE_logInform("%s", Message);\ |
| 49 | + if (std::string(Message) != "") { \ |
| 50 | + CONSOLE_BRIDGE_logInform("%s", Message);} \ |
49 | 51 | class_loader::class_loader_private::registerPlugin<_derived, _base>(#Derived, #Base); \
|
50 |
| - }\ |
51 |
| - };\ |
52 |
| - static ProxyExec##UniqueID g_register_plugin_##UniqueID;\ |
53 |
| -} |
| 52 | + } \ |
| 53 | + }; \ |
| 54 | + static ProxyExec ## UniqueID g_register_plugin_ ## UniqueID; \ |
| 55 | + } // namespace |
54 | 56 |
|
55 |
| -#define CLASS_LOADER_REGISTER_CLASS_INTERNAL_HOP1_WITH_MESSAGE(Derived, Base, UniqueID, Message) CLASS_LOADER_REGISTER_CLASS_INTERNAL_WITH_MESSAGE(Derived, Base, UniqueID, Message) |
| 57 | +#define CLASS_LOADER_REGISTER_CLASS_INTERNAL_HOP1_WITH_MESSAGE(Derived, Base, UniqueID, Message) \ |
| 58 | + CLASS_LOADER_REGISTER_CLASS_INTERNAL_WITH_MESSAGE(Derived, Base, UniqueID, Message) |
56 | 59 |
|
57 | 60 | /**
|
58 | 61 | * @macro This macro is same as CLASS_LOADER_REGISTER_CLASS, but will spit out a message when the plugin is registered
|
59 | 62 | * at library load time
|
60 | 63 | */
|
61 |
| -#define CLASS_LOADER_REGISTER_CLASS_WITH_MESSAGE(Derived, Base, Message) CLASS_LOADER_REGISTER_CLASS_INTERNAL_HOP1_WITH_MESSAGE(Derived, Base, __COUNTER__, Message) |
| 64 | +#define CLASS_LOADER_REGISTER_CLASS_WITH_MESSAGE(Derived, Base, Message) \ |
| 65 | + CLASS_LOADER_REGISTER_CLASS_INTERNAL_HOP1_WITH_MESSAGE(Derived, Base, __COUNTER__, Message) |
62 | 66 |
|
63 | 67 | /**
|
64 | 68 | * @macro This is the macro which must be declared within the source (.cpp) file for each class that is to be exported as plugin.
|
65 | 69 | * The macro utilizes a trick where a new struct is generated along with a declaration of static global variable of same type after it. The struct's constructor invokes a registration function with the plugin system. When the plugin system loads a library with registered classes in it, the initialization of static variables forces the invocation of the struct constructors, and all exported classes are automatically registerd.
|
66 | 70 | */
|
67 |
| -#define CLASS_LOADER_REGISTER_CLASS(Derived, Base) CLASS_LOADER_REGISTER_CLASS_WITH_MESSAGE(Derived, Base, "") |
68 |
| - |
69 |
| -#endif |
| 71 | +#define CLASS_LOADER_REGISTER_CLASS(Derived, Base) \ |
| 72 | + CLASS_LOADER_REGISTER_CLASS_WITH_MESSAGE(Derived, Base, "") |
70 | 73 |
|
| 74 | +#endif // CLASS_LOADER__CLASS_LOADER_REGISTER_MACRO_H_ |
0 commit comments