ECSTASY
All in the name
Loading...
Searching...
No Matches
ObjectWrapper.hpp
Go to the documentation of this file.
1
11
12#ifndef ECSTASY_RESOURCES_OBJECTWRAPPER_HPP_
13#define ECSTASY_RESOURCES_OBJECTWRAPPER_HPP_
14
15#include "IResource.hpp"
16
17namespace ecstasy
18{
27 template <typename T>
28 class ObjectWrapper : public IResource {
29 public:
40 template <typename... Args>
41 ObjectWrapper(Args &&...args) : _object(std::forward<Args>(args)...)
42 {
43 }
44
51 ~ObjectWrapper() = default;
52
61 [[nodiscard]] constexpr T &operator*() noexcept
62 {
63 return _object;
64 }
65
74 [[nodiscard]] constexpr const T &operator*() const noexcept
75 {
76 return _object;
77 }
78
87 [[nodiscard]] constexpr T *operator->() noexcept
88 {
89 return &_object;
90 }
91
99 [[nodiscard]] constexpr T const *operator->() const noexcept
100 {
101 return &_object;
102 }
103
112 [[nodiscard]] constexpr T &get() noexcept
113 {
114 return _object;
115 }
116
125 [[nodiscard]] constexpr const T &get() const noexcept
126 {
127 return _object;
128 }
129
130 protected:
133 };
134} // namespace ecstasy
135
136#endif /* !ECSTASY_RESOURCES_OBJECTWRAPPER_HPP_ */
Base class of all registry resources.
Base class of all registry resources.
Definition IResource.hpp:33
Basic object wrapper as a resource.
constexpr const T & get() const noexcept
Get a const reference to the object.
constexpr T & operator*() noexcept
Access the wrapped object.
T _object
Wrapped object.
~ObjectWrapper()=default
Destroy the Object Wrapper.
constexpr T & get() noexcept
Get a reference to the object.
ObjectWrapper(Args &&...args)
Construct a new Object Wrapper.
constexpr T const * operator->() const noexcept
Access the wrapped object pointer.
constexpr T * operator->() noexcept
Access the wrapped object pointer.
constexpr const T & operator*() const noexcept
Access the wrapped object.
Namespace containing all symbols specific to ecstasy.
Definition ecstasy.hpp:30