2#include "../foray_basics.hpp"
3#include "../foray_exception.hpp"
22 template <
typename TComponent>
26 template <
typename TComponent>
30 template <
typename TComponent>
34 template <
typename TComponent>
38 template <
typename TComponent>
42 template <
typename TComponent>
46 template <
typename TComponent>
76 template <
typename TComponent,
typename... Args>
86 template <
typename TComponent>
90 Assert(
component,
"Registry::AddComponent: Parameter component is nullptr!");
91 Assert(!
component->GetRegistry(),
"Registry::AddComponent: Component is already attached to other registry!");
96 template <
typename TComponent>
100 Assert(
component,
"Registry::AddComponent: Parameter component is nullptr!");
109 template <
typename TComponent>
113 return value !=
nullptr;
116 template <
typename TComponent>
130 template <
typename TComponent>
144 template <
typename TComponent>
160 template <
typename TComponent>
178 Assert(
component,
"Registry::RemoveDeleteComponent: Parameter component is nullptr!");
189 Assert(
mComponents.size() == 0,
"Registry::SetCallbackDispatcher: Cannot transfer root registry with components. Finalize first!");
Simple types for supressing automatic definition of duplicating move constructors & operator.
Definition foray_basics.hpp:19
Type maintaining callback lists for event distribution.
Definition foray_callbackdispatcher.hpp:12
Base class for all types manageable by registry.
Definition foray_component.hpp:13
Manages a type identified list of components.
Definition foray_registry.hpp:12
Registry()
Definition foray_registry.hpp:14
virtual ~Registry()
Definition foray_registry.hpp:55
Registry & SetCallbackDispatcher(CallbackDispatcher *rootRegistry)
The root registry manages global callbacks invokable on the components.
Definition foray_registry.hpp:187
bool HasComponent() const
Test wether a component matching type TComponent is registered.
Definition foray_registry.hpp:110
void RegisterToRoot(Component *component)
CallbackDispatcher * mCallbackDispatcher
All components attached to the registry.
Definition foray_registry.hpp:66
std::vector< Component * > mComponents
Definition foray_registry.hpp:67
void AddComponent(TComponent *component)
Adds a manually instantiated component instance (initiate with new, Registry manages finalization)
Definition foray_registry.hpp:87
void Register(Component *component)
TComponent * MakeComponent(Args &&... args)
Instantiates a new componente.
Definition foray_registry.hpp:77
TComponent * GetComponent()
Gets first component that can be cast to TComponent type.
Definition foray_registry.hpp:117
bool Unregister(Component *component)
void MoveComponent(TComponent *component)
Moves a component registered to a different Registry to this.
Definition foray_registry.hpp:97
void UnregisterFromRoot(Component *component)
Registry(CallbackDispatcher *root)
Definition foray_registry.hpp:15
bool RemoveDeleteComponent(Component *component)
Removes and finalizes a component.
Definition foray_registry.hpp:176
virtual void Destroy()
Finalizes all attached components.
int32_t GetComponents(std::vector< TComponent * > &out)
Appends all components which can be cast to TComponent type to the out vector.
Definition foray_registry.hpp:145
#define FORAY_GETTER_V(member)
Return value.
Definition foray_basics.hpp:39
#define FORAY_GETTER_CR(member)
Return constant reference.
Definition foray_basics.hpp:60
Definition foray_animation.hpp:8
void Assert(bool condition, const source_location location=source_location::current())
Asserts condition. Throws a generic error message if conditition is false.
Definition foray_exception.hpp:52