Registry managing function registration and lookup.
More...
#include <FunctionRegistry.h>
|
| 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 std::string | 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.
|
| template<typename R, typename... Args> |
| static std::string | makeKey (const std::string &name) |
| | Create a unique key combining name and signature.
|
Registry managing function registration and lookup.
Example usage:
[](int a, int b){ return a + b; },
"Adds two ints");
[](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);
}
static void list(std::ostream &os)
List all registered functions to the provided stream.
static std::string add(const std::string &name, F &&f, const std::string &desc={})
Add a function by name and signature, with optional description.
static R call(const std::string &name, Args... args)
Check validity of registration the function and makes the call.
Definition FunctionRegistry.h:78
◆ add()
template<typename R, typename... Args, typename F>
| std::string sf::FunctionRegistry::add |
( |
const std::string & | name, |
|
|
F && | f, |
|
|
const std::string & | desc = {} ) |
|
static |
Add a function by name and signature, with optional description.
- Template Parameters
-
| R | Return type |
| Args | Argument types |
| F | Callable type |
- Parameters
-
| name | Name to register under |
| f | Function or lambda to register |
| desc | Optional description |
- Returns
- Key of the registration.
◆ call()
template<typename R, typename... Args>
| R sf::FunctionRegistry::call |
( |
const std::string & | name, |
|
|
Args... | args ) |
|
inlinestatic |
Check validity of registration the function and makes the call.
◆ contains()
template<typename R, typename... Args>
| bool sf::FunctionRegistry::contains |
( |
const std::string & | name | ) |
|
|
static |
Check if a function is registered.
- Template Parameters
-
| R | Return type |
| Args | Argument types |
- Parameters
-
- Returns
- true if found, false otherwise
◆ isValid()
template<typename R, typename... Args>
| bool sf::FunctionRegistry::isValid |
( |
const std::string & | name | ) |
|
|
inlinestatic |
Check validity of the function using the registration.
◆ list()
| void sf::FunctionRegistry::list |
( |
std::ostream & | os | ) |
|
|
static |
List all registered functions to the provided stream.
- Parameters
-
◆ makeKey()
template<typename R, typename... Args>
| std::string sf::FunctionRegistry::makeKey |
( |
const std::string & | name | ) |
|
|
static |
Create a unique key combining name and signature.
- Template Parameters
-
| R | Return type |
| Args | Argument types |
- Parameters
-
- Returns
- Unique key string
◆ remove()
template<class R, class... Args>
| bool sf::FunctionRegistry::remove |
( |
const std::string & | name | ) |
|
|
static |
Removes a registered function by name and signature. Existing Registration instances are still able to call the function since the Holder does not change.
- Template Parameters
-
| R | Return type |
| Args | Argument types |
- Parameters
-
- Returns
- true if found and removed, false otherwise
The documentation for this class was generated from the following file: