|
template<typename R , typename... Args> |
static bool | isValid (const std::string &name) |
| Check validity of the function using the registration.
|
|
template<typename R , typename... Args> |
static R | call (const std::string &name, Args... args) |
| Check validity of registration the function and makes the call.
|
|
template<typename R , typename... Args, typename F > |
static void | add (const std::string &name, F &&f, const std::string &desc={}) |
| Add a function by name and signature, with optional description.
|
|
template<typename R , typename... Args> |
static bool | contains (const std::string &name) |
| Check if a function is registered.
|
|
template<class R , class... Args> |
static bool | remove (const std::string &name) |
| Removes a registered function by name and signature. Existing Registration instances are still able to call the function since the Holder does not change.
|
|
static void | list (std::ostream &os) |
| List all registered functions to the provided stream.
|
|
Registry managing function registration and lookup.
Example usage:
FunctionRegistry::add<int, int, int>("add",
[](int a, int b){ return a + b; },
"Adds two ints");
FunctionRegistry::add<double, double, double>("add",
[](double x, double y){ return x + y; },
"Adds two doubles");
auto func = FunctionRegistry::Registration<int, int, int>("add");
if (func.isValid())
{
int sum = regInt.call(3, 4);
}
FunctionRegistry::call<int, int, int>("add", 1, 2);
static void list(std::ostream &os)
List all registered functions to the provided stream.