#include <stdexcept>
#include <sstream>
#include "includes/registry.h"
#include "includes/registry_item.h"
Go to the source code of this file.
|
#define | KRATOS_REGISTRY_NAME_(A, B) A##B |
|
#define | KRATOS_REGISTRY_NAME(A, B) KRATOS_REGISTRY_NAME_(A,B) |
|
#define | KRATOS_REGISTRY_ADD_PROTOTYPE(NAME, X, Y) |
| Macro to register class prototypes This macro creates a static bool in the class (which value is not relevant and is supposed to be never accessed) This macro must be placed within the private section of the class (e.g. Process, Controller, DerivedProcess, etc) The macro forces a function to be evaluated in the declaration of the class First it checks if the provided key has been already registered (note that it checks the key but not the object) to then create a dispacher function that will initialize the registry object the first time it is accessed NOTE 1: The return type is intentionally the HasItem of the added item (and not a simple bool) in order to avoid the compiler to statically analize the function. NOTE 2: Also note that it is explicitly needed to define the dispatcher as TFunctionType or, in other words, putting the dispatcher function directly inside the std::move would break current code as the compiler will deduce the type of the lambda function to something that is not an std::function. More...
|
|
#define | KRATOS_REGISTRY_ADD_TEMPLATE_PROTOTYPE(NAME, X, Y, ...) |
|
◆ KRATOS_REGISTRY_ADD_PROTOTYPE
#define KRATOS_REGISTRY_ADD_PROTOTYPE |
( |
|
NAME, |
|
|
|
X, |
|
|
|
Y |
|
) |
| |
Value:
using TFunctionType = std::function<std::shared_ptr<X>()>; \
std::string key_name = NAME + std::string(".") + std::string(#Y); \
if (!Registry::HasItem(key_name)) \
{ \
auto &r_item = Registry::AddItem<RegistryItem>(key_name); \
TFunctionType dispatcher = [](){return std::make_shared<Y>();}; \
r_item.AddItem<TFunctionType>("Prototype", std::move(dispatcher)); \
} \
return Registry::HasItem(key_name); \
}();
#define KRATOS_REGISTRY_NAME(A, B)
Definition: define_registry.h:28
Macro to register class prototypes This macro creates a static bool in the class (which value is not relevant and is supposed to be never accessed) This macro must be placed within the private section of the class (e.g. Process, Controller, DerivedProcess, etc) The macro forces a function to be evaluated in the declaration of the class First it checks if the provided key has been already registered (note that it checks the key but not the object) to then create a dispacher function that will initialize the registry object the first time it is accessed NOTE 1: The return type is intentionally the HasItem of the added item (and not a simple bool) in order to avoid the compiler to statically analize the function. NOTE 2: Also note that it is explicitly needed to define the dispatcher as TFunctionType or, in other words, putting the dispatcher function directly inside the std::move would break current code as the compiler will deduce the type of the lambda function to something that is not an std::function.
◆ KRATOS_REGISTRY_ADD_TEMPLATE_PROTOTYPE
#define KRATOS_REGISTRY_ADD_TEMPLATE_PROTOTYPE |
( |
|
NAME, |
|
|
|
X, |
|
|
|
Y, |
|
|
|
... |
|
) |
| |
Value:
using TFunctionType = std::function<std::shared_ptr<X>()>; \
if (!Registry::HasItem(key_name)) \
{ \
auto &r_item = Registry::AddItem<RegistryItem>(key_name); \
TFunctionType dispatcher = [](){return std::make_shared<Y<__VA_ARGS__>>();}; \
r_item.AddItem<TFunctionType>("Prototype", std::move(dispatcher)); \
} else { \
} \
return Registry::HasItem(key_name); \
}();
static std::string RegistryTemplateToString(Types &&... args)
Definition: registry.h:108
◆ KRATOS_REGISTRY_NAME
◆ KRATOS_REGISTRY_NAME_
#define KRATOS_REGISTRY_NAME_ |
( |
|
A, |
|
|
|
B |
|
) |
| A##B |