KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
Macros
define_registry.h File Reference
#include <stdexcept>
#include <sstream>
#include "includes/registry.h"
#include "includes/registry_item.h"
Include dependency graph for define_registry.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#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, ...)
 

Macro Definition Documentation

◆ KRATOS_REGISTRY_ADD_PROTOTYPE

#define KRATOS_REGISTRY_ADD_PROTOTYPE (   NAME,
  X,
 
)
Value:
static inline bool KRATOS_REGISTRY_NAME(_is_registered_, __LINE__) = []() -> bool { \
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:
static inline bool KRATOS_REGISTRY_NAME(_is_registered_, __LINE__) = []() -> bool { \
using TFunctionType = std::function<std::shared_ptr<X>()>; \
std::string key_name = NAME + std::string(".") + std::string(#Y) + "<" + Kratos::Registry::RegistryTemplateToString(__VA_ARGS__) + ">"; \
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

#define KRATOS_REGISTRY_NAME (   A,
 
)    KRATOS_REGISTRY_NAME_(A,B)

◆ KRATOS_REGISTRY_NAME_

#define KRATOS_REGISTRY_NAME_ (   A,
 
)    A##B