IQRF Gateway Daemon
Classes | Macros
LaunchUtils.h File Reference
#include "IqrfLogging.h"
#include <memory>
#include <string>
#include <map>

Go to the source code of this file.

Classes

class  StaticBuildFunctionMap
 Holds pointers to component loader functions. More...
 

Macros

#define INIT_COMPONENT(IComponentClassName, ComponentClassName)
 Convenient macro to register component interface and implementation. More...
 

Macro Definition Documentation

◆ INIT_COMPONENT

#define INIT_COMPONENT (   IComponentClassName,
  ComponentClassName 
)
Value:
std::unique_ptr<IComponentClassName> __launch_create_##ComponentClassName(const std::string& iname) { \
return std::unique_ptr<IComponentClassName>(new ComponentClassName(iname)); } \
\
class __Loader_##ComponentClassName { \
public: \
__Loader_##ComponentClassName() { \
StaticBuildFunctionMap::get().setFunction("__launch_create_" #ComponentClassName, \
(void*)&__launch_create_##ComponentClassName); \
} \
}; \
\
void init_##ComponentClassName() { \
static __Loader_##ComponentClassName cs; \
}
static StaticBuildFunctionMap & get()
StaticBuildFunctionMap singleton getter.
Definition: LaunchUtils.h:30
void setFunction(const std::string &fceName, void *fcePtr)
Set pointer to function.
Definition: LaunchUtils.h:59

Convenient macro to register component interface and implementation.

Parameters
IComponentClassNamecomponent interface name
ComponentClassNamecomponent implementation name

Declare and define define __launch_create_##ComponentClassName() to create implementation declare __Loader_##ComponentClassName class for function registration define init_##ComponentClassName() with static class for function registration This macro shall be added once to a component source code and init_##ComponentClassName() shall be called at the very beginning of application in case of static build