|
SpaghettiKart
|
#include <Registry.h>
Data Structures | |
| struct | Entry |
Public Types | |
| using | Callback = std::function<void(TArgs...)> |
Public Member Functions | |
| void | Add (TInfo &info, Callback func) |
| const TInfo * | GetInfo (const std::string &resourceName) const |
| void | Invoke (const std::string &resourceName, TArgs... args) |
| bool | Find (const std::string &resourceName) const |
| size_t | Size () |
| std::vector< const TInfo * > | GetAllInfo () const |
| bool | Remove (const std::string &resourceName) |
| void | Clear () |
Private Attributes | |
| int32_t | mCounter |
| std::unordered_map< std::string, Registry::Entry > | mMap |
TInfo must have a ResourceName member of type std::string This should be a unique string such as hm:cloud or hm:harbour user_name:my_mod
TArgs the parameters passed into the callback function
Example Usage:
Registry<ActorInfo> gActorRegistry;
ActorInfo actorInfo { .ResourceName = "hm:cloud", }; SpawnParams params; params.Location = FVector(0, 0, 0);
gActorRegistry.Add(actorInfo, [](params) { GetWorld()->AddActor(new ACloud(params)); });
gActorRegistry.Invoke("hm:cloud", params);
| using Registry< TInfo, TArgs >::Callback = std::function<void(TArgs...)> |
Callback explanation
This is just a lambda function.
Usage: gRegistry.Add("hm:harbour", [](parameters) { // My code here })
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
|
private |