https://github.com/rdbo/functionmanager
https://github.com/rdbo/functionmanager
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rdbo/functionmanager
- Owner: rdbo
- Created: 2020-03-21T03:57:36.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-15T19:24:53.000Z (about 6 years ago)
- Last Synced: 2025-12-29T02:14:17.278Z (6 months ago)
- Language: C++
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FunctionManager
# Usage
Usage for fman.h + fman.cpp
The functions only have one type, which is functype, defined in fman.h
```C++
FunctionManager::Register("FunctionName", []() -> functype { /*function code*/ }, bOverwrite /*overwrite function with same name*/)
```
OBS: bOverwrite is defined as true by default in both cases
Example:
```C++
FunctionManager::Register("ExampleFunc", []() -> functype { return 1337; }, false);
FunctionManager::Call("ExampleFunc");
```
2. Usage for fman.hpp
The functions can have any type, everything is defined on this single file (no need of fman.cpp)
OBS: bOverwrite is defined as true by default in both cases
```C++
FunctionManager::Register("FunctionName", []() -> type_here { /*function code*/ }, bOverwrite /*overwrite function with same name*/)
```
Example:
```C++
FunctionManager::Register("ExampleFunc", []() -> std::string { return "hello"; }, false);
FunctionManager::Call("ExampleFunc");
```
3. Additional notes
.To add variables into the scope of the function, put them between \[ and ] on the lambda function. Example:
```C++
int a = 10;
FunctionManager::Register("Example", [&a]() -> void { std::cout << a << std::endl; });
```