diff options
author | max-001 <maxsmits21@kpnmail.nl> | 2024-12-20 12:01:36 +0100 |
---|---|---|
committer | max-001 <maxsmits21@kpnmail.nl> | 2024-12-20 12:01:36 +0100 |
commit | 79d3a9f4311e6684b6df83a15ca7844f58c1959c (patch) | |
tree | b2883e83f61cee9edf290a6a7228c7f0b1fbae8a /src/crepe/Component.h | |
parent | 9140b73e4af7aa925b53e4fb4e6aa7f4ea2e3385 (diff) | |
parent | 03aea832aa0bc2edba2cc5ab4d9f8eba42d355be (diff) |
Merge remote-tracking branch 'origin/master' into max/game
Diffstat (limited to 'src/crepe/Component.h')
-rw-r--r-- | src/crepe/Component.h | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/crepe/Component.h b/src/crepe/Component.h index eff5a58..52e06d5 100644 --- a/src/crepe/Component.h +++ b/src/crepe/Component.h @@ -1,5 +1,7 @@ #pragma once +#include <memory> + #include "types.h" namespace crepe { @@ -32,11 +34,33 @@ protected: //! Only ComponentManager can create components friend class ComponentManager; - Component(const Component &) = delete; + // components are never moved Component(Component &&) = delete; - virtual Component & operator=(const Component &) = delete; virtual Component & operator=(Component &&) = delete; +protected: + /** + * \name ReplayManager (Memento) functions + * \{ + */ + /** + * \brief Save a snapshot of this component's state + * \note This function should only be implemented on components that should be saved/restored + * by ReplayManager. + * \returns Unique pointer to a deep copy of this component + */ + virtual std::unique_ptr<Component> save() const; + //! Copy constructor (used by \c save()) + Component(const Component &) = default; + /** + * \brief Restore this component from a snapshot + * \param snapshot Data to fill this component with (as returned by \c save()) + */ + virtual void restore(const Component & snapshot); + //! Copy assignment operator (used by \c restore()) + virtual Component & operator=(const Component &); + //! \} + public: virtual ~Component() = default; |