SpaghettiKart
Loading...
Searching...
No Matches
Registry< TInfo, TArgs > Class Template Reference

#include <Registry.h>

Collaboration diagram for Registry< TInfo, TArgs >:
[legend]

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::EntrymMap
 

Detailed Description

template<typename TInfo, typename... TArgs>
class Registry< TInfo, TArgs >

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);

Member Typedef Documentation

◆ Callback

template<typename TInfo, typename... TArgs>
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 })

Member Function Documentation

◆ Add()

template<typename TInfo, typename... TArgs>
void Registry< TInfo, TArgs >::Add ( TInfo & info,
Callback func )
inline
Here is the caller graph for this function:

◆ Clear()

template<typename TInfo, typename... TArgs>
void Registry< TInfo, TArgs >::Clear ( )
inline

◆ Find()

template<typename TInfo, typename... TArgs>
bool Registry< TInfo, TArgs >::Find ( const std::string & resourceName) const
inline
Here is the caller graph for this function:

◆ GetAllInfo()

template<typename TInfo, typename... TArgs>
std::vector< const TInfo * > Registry< TInfo, TArgs >::GetAllInfo ( ) const
inline

◆ GetInfo()

template<typename TInfo, typename... TArgs>
const TInfo * Registry< TInfo, TArgs >::GetInfo ( const std::string & resourceName) const
inline

◆ Invoke()

template<typename TInfo, typename... TArgs>
void Registry< TInfo, TArgs >::Invoke ( const std::string & resourceName,
TArgs... args )
inline

◆ Remove()

template<typename TInfo, typename... TArgs>
bool Registry< TInfo, TArgs >::Remove ( const std::string & resourceName)
inline

◆ Size()

template<typename TInfo, typename... TArgs>
size_t Registry< TInfo, TArgs >::Size ( )
inline

Field Documentation

◆ mCounter

template<typename TInfo, typename... TArgs>
int32_t Registry< TInfo, TArgs >::mCounter
private

◆ mMap

template<typename TInfo, typename... TArgs>
std::unordered_map<std::string, Registry::Entry> Registry< TInfo, TArgs >::mMap
private

The documentation for this class was generated from the following file: