Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
foray::scene::Registry Class Reference

Manages a type identified list of components. More...

#include <foray_registry.hpp>

Inheritance diagram for foray::scene::Registry:
foray::NoMoveDefaults foray::scene::Node foray::scene::Scene

Public Member Functions

 Registry ()
 
 Registry (CallbackDispatcher *root)
 
template<typename TComponent , typename... Args>
TComponentMakeComponent (Args &&... args)
 Instantiates a new componente.
 
template<typename TComponent >
void AddComponent (TComponent *component)
 Adds a manually instantiated component instance (initiate with new, Registry manages finalization)
 
template<typename TComponent >
void MoveComponent (TComponent *component)
 Moves a component registered to a different Registry to this.
 
template<typename TComponent >
bool HasComponent () const
 Test wether a component matching type TComponent is registered.
 
template<typename TComponent >
TComponentGetComponent ()
 Gets first component that can be cast to TComponent type.
 
template<typename TComponent >
const TComponentGetComponent () const
 Gets first component that can be cast to TComponent type.
 
template<typename TComponent >
int32_t GetComponents (std::vector< TComponent * > &out)
 Appends all components which can be cast to TComponent type to the out vector.
 
template<typename TComponent >
int32_t GetComponents (std::vector< const TComponent * > &out) const
 Appends all components which can be cast to TComponent type to the out vector.
 
bool RemoveDeleteComponent (Component *component)
 Removes and finalizes a component.
 
virtual void Destroy ()
 Finalizes all attached components.
 
virtual ~Registry ()
 
RegistrySetCallbackDispatcher (CallbackDispatcher *rootRegistry)
 The root registry manages global callbacks invokable on the components.
 
- Public Member Functions inherited from foray::NoMoveDefaults
 NoMoveDefaults ()=default
 
 NoMoveDefaults (const NoMoveDefaults &other)=delete
 
 NoMoveDefaults (NoMoveDefaults &&other)=default
 
NoMoveDefaultsoperator= (const NoMoveDefaults &other)=delete
 

Protected Member Functions

void Register (Component *component)
 
bool Unregister (Component *component)
 
void RegisterToRoot (Component *component)
 
void UnregisterFromRoot (Component *component)
 

Protected Attributes

CallbackDispatchermCallbackDispatcher = nullptr
 All components attached to the registry.
 
std::vector< Component * > mComponents = {}
 

Detailed Description

Manages a type identified list of components.

Remarks
This class manages lifetime of the attached components

Constructor & Destructor Documentation

◆ Registry() [1/2]

foray::scene::Registry::Registry ( )
inline

◆ Registry() [2/2]

foray::scene::Registry::Registry ( CallbackDispatcher root)
inline

◆ ~Registry()

virtual foray::scene::Registry::~Registry ( )
inlinevirtual

Member Function Documentation

◆ AddComponent()

template<typename TComponent >
void foray::scene::Registry::AddComponent ( TComponent component)
inline

Adds a manually instantiated component instance (initiate with new, Registry manages finalization)

◆ Destroy()

virtual void foray::scene::Registry::Destroy ( )
virtual

Finalizes all attached components.

Reimplemented in foray::scene::Scene.

◆ GetComponent() [1/2]

template<typename TComponent >
TComponent * foray::scene::Registry::GetComponent ( )
inline

Gets first component that can be cast to TComponent type.

◆ GetComponent() [2/2]

template<typename TComponent >
const TComponent * foray::scene::Registry::GetComponent ( ) const
inline

Gets first component that can be cast to TComponent type.

◆ GetComponents() [1/2]

template<typename TComponent >
int32_t foray::scene::Registry::GetComponents ( std::vector< const TComponent * > &  out) const
inline

Appends all components which can be cast to TComponent type to the out vector.

◆ GetComponents() [2/2]

template<typename TComponent >
int32_t foray::scene::Registry::GetComponents ( std::vector< TComponent * > &  out)
inline

Appends all components which can be cast to TComponent type to the out vector.

◆ HasComponent()

template<typename TComponent >
bool foray::scene::Registry::HasComponent ( ) const
inline

Test wether a component matching type TComponent is registered.

◆ MakeComponent()

template<typename TComponent , typename... Args>
TComponent * foray::scene::Registry::MakeComponent ( Args &&...  args)
inline

Instantiates a new componente.

◆ MoveComponent()

template<typename TComponent >
void foray::scene::Registry::MoveComponent ( TComponent component)
inline

Moves a component registered to a different Registry to this.

◆ Register()

void foray::scene::Registry::Register ( Component component)
protected

◆ RegisterToRoot()

void foray::scene::Registry::RegisterToRoot ( Component component)
protected

◆ RemoveDeleteComponent()

bool foray::scene::Registry::RemoveDeleteComponent ( Component component)
inline

Removes and finalizes a component.

◆ SetCallbackDispatcher()

Registry & foray::scene::Registry::SetCallbackDispatcher ( CallbackDispatcher rootRegistry)
inline

The root registry manages global callbacks invokable on the components.

◆ Unregister()

bool foray::scene::Registry::Unregister ( Component component)
protected

◆ UnregisterFromRoot()

void foray::scene::Registry::UnregisterFromRoot ( Component component)
protected

Member Data Documentation

◆ mCallbackDispatcher

CallbackDispatcher* foray::scene::Registry::mCallbackDispatcher = nullptr
protected

All components attached to the registry.

◆ mComponents

std::vector<Component*> foray::scene::Registry::mComponents = {}
protected

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