diff options
author | clyne <clyne@bitgloo.com> | 2019-09-03 18:17:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-03 18:17:51 -0400 |
commit | ec1d57aeadbd0f34616eeec8f1a922ca61b90085 (patch) | |
tree | 9d2233f2437b8e85d151f9610b1a147310b9c13e /src/components/Component.hpp | |
parent | 0b3d24c4295bb89eb4ce3f91163cabd64d0ca6e2 (diff) | |
parent | 95cc88ad5f6c2abb4890d00a57ae4ad0db030e9b (diff) |
Merge pull request #1 from tcsullivan/save-load
Save load looks good
Diffstat (limited to 'src/components/Component.hpp')
-rw-r--r-- | src/components/Component.hpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/components/Component.hpp b/src/components/Component.hpp index 5a062bd..2928366 100644 --- a/src/components/Component.hpp +++ b/src/components/Component.hpp @@ -18,13 +18,27 @@ #ifndef COMPONENT_HPP_ #define COMPONENT_HPP_ +#include <cereal/cereal.hpp> +#include <cereal/archives/json.hpp> + +#include <entityx/entityx.h> #include <sol/sol.hpp> template<typename T> -class Component +class Component : public entityx::Component<T> { public: virtual T FromLua(sol::object) = 0; + + virtual void serialize(cereal::JSONOutputArchive& ar) = 0; + virtual void serialize(cereal::JSONInputArchive& ar) = 0; + + void internal_serialize(bool save, void *ar) final { + if (save) + serialize(*reinterpret_cast<cereal::JSONOutputArchive*>(ar)); + else + serialize(*reinterpret_cast<cereal::JSONInputArchive*>(ar)); + } }; #endif // COMPONENT_HPP_ |