diff options
author | jjesswan <jessica_wan@brown.edu> | 2024-04-22 21:56:26 -0400 |
---|---|---|
committer | jjesswan <jessica_wan@brown.edu> | 2024-04-22 21:56:26 -0400 |
commit | a556b45abf18f1bd509daaf63b66b7d55e9fd291 (patch) | |
tree | bc9b8a2d184c12aee236e7f9f276a34b84ca552d /engine-ocean/Game/Systems/UI/uielement.h | |
parent | cd7c76017a12bb548036571c1ff13e551369d06d (diff) |
add engine version
Diffstat (limited to 'engine-ocean/Game/Systems/UI/uielement.h')
-rw-r--r-- | engine-ocean/Game/Systems/UI/uielement.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/engine-ocean/Game/Systems/UI/uielement.h b/engine-ocean/Game/Systems/UI/uielement.h new file mode 100644 index 0000000..c2c3a2e --- /dev/null +++ b/engine-ocean/Game/Systems/UI/uielement.h @@ -0,0 +1,40 @@ +#ifndef UIELEMENT_H +#define UIELEMENT_H + + +#include "Game/Systems/UI/UITextures/uitexture.h" +#include "Game/TypeMap.h" +#include <memory> +class UIElement +{ +public: + UIElement(); + + template <typename T> + void addComponent(std::unique_ptr<T> &&component){ + m_components.put<T>(std::forward<std::unique_ptr<T>>(component)); + } + + template <typename T> + bool hasComponent(){ + return m_components.contains<T>(); + } + + template <class T> + T* getComponent(){ + auto comp = m_components.find<T>(); + assert(comp != m_components.end()); + return static_cast<T*>(comp->second.get()); + } + + template <class T> + void removeComponent(){ + m_components.remove<T>(); + } + +private: + + TypeMap<std::unique_ptr<UITexture>> m_components; +}; + +#endif // UIELEMENT_H |