From 0d5fe48f19a71d57be483d3266cc3b1e882fa499 Mon Sep 17 00:00:00 2001 From: Ricardo Antunes Date: Thu, 28 Sep 2023 23:00:40 +0100 Subject: [PATCH] refactor(serialization): move to old namespace --- .../core/data/old/binary_deserializer.hpp | 4 +- .../cubos/core/data/old/binary_serializer.hpp | 4 +- core/include/cubos/core/data/old/context.hpp | 4 +- .../cubos/core/data/old/debug_serializer.hpp | 10 ++--- .../cubos/core/data/old/deserializer.hpp | 10 ++--- .../cubos/core/data/old/json_deserializer.hpp | 4 +- .../cubos/core/data/old/json_serializer.hpp | 4 +- core/include/cubos/core/data/old/package.hpp | 4 +- .../cubos/core/data/old/serialization_map.hpp | 4 +- .../cubos/core/data/old/serializer.hpp | 10 ++--- core/include/cubos/core/ecs/blueprint.hpp | 25 ++++++----- core/include/cubos/core/ecs/commands.hpp | 6 +-- .../cubos/core/ecs/component_manager.hpp | 5 ++- .../include/cubos/core/ecs/entity_manager.hpp | 2 +- core/include/cubos/core/ecs/registry.hpp | 6 +-- core/include/cubos/core/ecs/storage.hpp | 10 ++--- core/include/cubos/core/ecs/world.hpp | 4 +- core/include/cubos/core/geom/box.hpp | 4 +- core/include/cubos/core/geom/capsule.hpp | 4 +- core/include/cubos/core/geom/plane.hpp | 4 +- core/include/cubos/core/geom/simplex.hpp | 4 +- core/samples/data/serialization/main.cpp | 6 +-- core/samples/ecs/general/main.cpp | 4 +- core/samples/logging/main.cpp | 2 +- core/samples/logging/page.md | 6 +-- .../core/data/old/binary_deserializer.cpp | 2 +- .../cubos/core/data/old/binary_serializer.cpp | 2 +- core/src/cubos/core/data/old/context.cpp | 2 +- .../cubos/core/data/old/debug_serializer.cpp | 2 +- core/src/cubos/core/data/old/deserializer.cpp | 38 ++++++++-------- .../cubos/core/data/old/json_deserializer.cpp | 2 +- .../cubos/core/data/old/json_serializer.cpp | 2 +- core/src/cubos/core/data/old/package.cpp | 2 +- core/src/cubos/core/data/old/serializer.cpp | 45 ++++++++++--------- core/src/cubos/core/ecs/blueprint.cpp | 8 ++-- core/src/cubos/core/ecs/commands.cpp | 6 +-- core/src/cubos/core/ecs/component_manager.cpp | 6 +-- core/src/cubos/core/ecs/entity_manager.cpp | 4 +- core/src/cubos/core/ecs/registry.cpp | 2 +- core/src/cubos/core/ecs/world.cpp | 8 ++-- core/src/cubos/core/io/gamepad.cpp | 12 ++--- core/src/cubos/core/io/keyboard.cpp | 12 ++--- core/tests/data/context.cpp | 4 +- core/tests/ecs/blueprint.cpp | 4 +- core/tests/ecs/registry.cpp | 4 +- core/tests/ecs/world.cpp | 2 +- engine/include/cubos/engine/assets/asset.hpp | 8 ++-- .../cubos/engine/assets/bridges/binary.hpp | 4 +- .../cubos/engine/assets/bridges/json.hpp | 4 +- .../include/cubos/engine/collisions/aabb.hpp | 4 +- .../cubos/engine/imgui/serialization.hpp | 8 ++-- .../include/cubos/engine/renderer/vertex.hpp | 4 +- engine/include/cubos/engine/voxels/grid.hpp | 10 ++--- .../include/cubos/engine/voxels/material.hpp | 4 +- .../include/cubos/engine/voxels/palette.hpp | 11 ++--- engine/samples/assets/json/main.cpp | 8 ++-- engine/samples/assets/saving/main.cpp | 8 ++-- engine/samples/input/main.cpp | 2 +- engine/samples/scene/main.cpp | 6 +-- engine/src/cubos/engine/assets/asset.cpp | 4 +- engine/src/cubos/engine/assets/assets.cpp | 34 +++++++------- engine/src/cubos/engine/assets/meta.cpp | 4 +- .../src/cubos/engine/imgui/serialization.cpp | 2 +- engine/src/cubos/engine/input/bindings.cpp | 10 ++--- engine/src/cubos/engine/renderer/vertex.cpp | 4 +- engine/src/cubos/engine/scene/bridge.cpp | 4 +- engine/src/cubos/engine/settings/plugin.cpp | 2 +- engine/src/cubos/engine/settings/settings.cpp | 4 +- .../engine/tools/entity_inspector/plugin.cpp | 4 +- .../engine/tools/scene_editor/plugin.cpp | 2 +- engine/src/cubos/engine/voxels/grid.cpp | 4 +- engine/src/cubos/engine/voxels/material.cpp | 4 +- engine/src/cubos/engine/voxels/palette.cpp | 4 +- tools/quadrados-gen/src/main.cpp | 5 ++- tools/quadrados/src/convert.cpp | 6 +-- 75 files changed, 253 insertions(+), 244 deletions(-) diff --git a/core/include/cubos/core/data/old/binary_deserializer.hpp b/core/include/cubos/core/data/old/binary_deserializer.hpp index f35325ec9..d17ef7fb3 100644 --- a/core/include/cubos/core/data/old/binary_deserializer.hpp +++ b/core/include/cubos/core/data/old/binary_deserializer.hpp @@ -3,7 +3,7 @@ #include #include -namespace cubos::core::data +namespace cubos::core::data::old { /// Implementation of the abstract Deserializer class for deserializing from raw binary data. /// This class allows data to be deserialized from both little and big endian formats. @@ -39,4 +39,4 @@ namespace cubos::core::data memory::Stream& mStream; ///< The stream to serialize from. bool mReadLittleEndian; ///< Whether to write in little endian or big endian format. }; -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/data/old/binary_serializer.hpp b/core/include/cubos/core/data/old/binary_serializer.hpp index 4b57ec5ff..b8ce5099e 100644 --- a/core/include/cubos/core/data/old/binary_serializer.hpp +++ b/core/include/cubos/core/data/old/binary_serializer.hpp @@ -3,7 +3,7 @@ #include #include -namespace cubos::core::data +namespace cubos::core::data::old { /// Implementation of the abstract Serializer class for serializing to binary data. /// This class allows data to be serialized in both little and big endian formats. @@ -40,4 +40,4 @@ namespace cubos::core::data memory::Stream& mStream; ///< The stream to serialize to. bool mWriteLittleEndian; ///< Whether to write in little endian or big endian format. }; -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/data/old/context.hpp b/core/include/cubos/core/data/old/context.hpp index 55dda0e85..8d46f21ac 100644 --- a/core/include/cubos/core/data/old/context.hpp +++ b/core/include/cubos/core/data/old/context.hpp @@ -3,7 +3,7 @@ #include #include -namespace cubos::core::data +namespace cubos::core::data::old { /// Stores the context necessary to serialize or deserialize data. /// This is done through a type map, which stores an instance for each type added (akin to the @@ -83,4 +83,4 @@ namespace cubos::core::data std::vector mEntries; ///< Entries in the context. }; -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/data/old/debug_serializer.hpp b/core/include/cubos/core/data/old/debug_serializer.hpp index 1aa9b0e90..cd5bf3fb9 100644 --- a/core/include/cubos/core/data/old/debug_serializer.hpp +++ b/core/include/cubos/core/data/old/debug_serializer.hpp @@ -7,7 +7,7 @@ #include #include -namespace cubos::core::data +namespace cubos::core::data::old { /// Used to wrap a value to be printed using the debug serializer. /// Can be pretty-printed using the `p` option. Types can be printed using the `t` option. @@ -89,13 +89,13 @@ namespace cubos::core::data bool mPretty; ///< Whether to pretty-print the output. bool mTypeNames; ///< Whether to print the type names. }; -} // namespace cubos::core::data +} // namespace cubos::core::data::old // Add a formatter for Debug. /// @cond template -struct fmt::formatter> : formatter +struct fmt::formatter> : formatter { bool pretty = false; ///< Whether to pretty print the data. bool types = false; ///< Whether to print the type name. @@ -128,10 +128,10 @@ struct fmt::formatter> : formatter } template - inline auto format(const cubos::core::data::Debug& dbg, FormatContext& ctx) -> decltype(ctx.out()) + inline auto format(const cubos::core::data::old::Debug& dbg, FormatContext& ctx) -> decltype(ctx.out()) { auto stream = cubos::core::memory::BufferStream(32); - cubos::core::data::DebugSerializer serializer(stream, this->pretty, this->types); + cubos::core::data::old::DebugSerializer serializer(stream, this->pretty, this->types); serializer.write(dbg.value, nullptr); stream.put('\0'); // Skip the '?: ' prefix. diff --git a/core/include/cubos/core/data/old/deserializer.hpp b/core/include/cubos/core/data/old/deserializer.hpp index 0fbba2d1e..3e1125cbf 100644 --- a/core/include/cubos/core/data/old/deserializer.hpp +++ b/core/include/cubos/core/data/old/deserializer.hpp @@ -6,7 +6,7 @@ #include -namespace cubos::core::data +namespace cubos::core::data::old { class Deserializer; @@ -25,7 +25,7 @@ namespace cubos::core::data /// deserialization methods: `readI8`, `readString`, etc. /// /// @details More complex types can be deserialized by implementing a specialization of the - /// `cubos::core::data::deserialize` function: + /// `cubos::core::data::old::deserialize` function: /// /// struct MyType /// { @@ -33,7 +33,7 @@ namespace cubos::core::data /// }; /// /// // In the corresponding .cpp file. - /// void cubos::core::data::deserialize(Deserializer& d, MyType& obj) + /// void cubos::core::data::old::deserialize(Deserializer& d, MyType& obj) /// { /// d.read(obj.a, "a"); /// } @@ -118,7 +118,7 @@ namespace cubos::core::data virtual void readString(std::string& value) = 0; /// Deserializes an object. - /// The `cubos::core::data::deserialize` function must be implemented for the given type. + /// The `cubos::core::data::old::deserialize` function must be implemented for the given type. /// The fail bit is set if the deserialization fails. /// @tparam T The type of the object. /// @param obj The object to deserialize. @@ -247,4 +247,4 @@ namespace cubos::core::data des.read(obj.second); des.endObject(); } -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/data/old/json_deserializer.hpp b/core/include/cubos/core/data/old/json_deserializer.hpp index d24dd77d2..2ccbed442 100644 --- a/core/include/cubos/core/data/old/json_deserializer.hpp +++ b/core/include/cubos/core/data/old/json_deserializer.hpp @@ -6,7 +6,7 @@ #include -namespace cubos::core::data +namespace cubos::core::data::old { /// Implementation of the abstract Deserializer class for deserializing from JSON. class JSONDeserializer : public Deserializer @@ -56,4 +56,4 @@ namespace cubos::core::data std::stack mFrame; ///< The current frame of the deserializer. nlohmann::ordered_json mJson; ///< The current JSON value being read. }; -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/data/old/json_serializer.hpp b/core/include/cubos/core/data/old/json_serializer.hpp index ed0d8321e..4371cd922 100644 --- a/core/include/cubos/core/data/old/json_serializer.hpp +++ b/core/include/cubos/core/data/old/json_serializer.hpp @@ -7,7 +7,7 @@ #include #include -namespace cubos::core::data +namespace cubos::core::data::old { /// Implementation of the abstract Serializer class for serializing to JSON. /// Each time a top-level primitive/object/array/dictionary is written, its JSON output is written to the underlying @@ -64,4 +64,4 @@ namespace cubos::core::data std::stack mFrames; ///< The stack of frames. int mIndent; ///< The indentation of the JSON output. }; -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/data/old/package.hpp b/core/include/cubos/core/data/old/package.hpp index e049eccd6..95542af89 100644 --- a/core/include/cubos/core/data/old/package.hpp +++ b/core/include/cubos/core/data/old/package.hpp @@ -8,7 +8,7 @@ #include #include -namespace cubos::core::data +namespace cubos::core::data::old { namespace impl { @@ -382,4 +382,4 @@ namespace cubos::core::data return !unpackager.failed(); } -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/data/old/serialization_map.hpp b/core/include/cubos/core/data/old/serialization_map.hpp index a5abed2bd..80f2f5df0 100644 --- a/core/include/cubos/core/data/old/serialization_map.hpp +++ b/core/include/cubos/core/data/old/serialization_map.hpp @@ -5,7 +5,7 @@ #include -namespace cubos::core::data +namespace cubos::core::data::old { /// Class used to map between references and their serialized identifiers. /// @tparam R Reference type. @@ -133,4 +133,4 @@ namespace cubos::core::data std::unordered_map mRefToId; ///< Map of references to serialized IDs. std::unordered_map mIdToRef; ///< Map of serialized IDs to references. }; -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/data/old/serializer.hpp b/core/include/cubos/core/data/old/serializer.hpp index 6015ea4ea..67263ce73 100644 --- a/core/include/cubos/core/data/old/serializer.hpp +++ b/core/include/cubos/core/data/old/serializer.hpp @@ -6,7 +6,7 @@ #include -namespace cubos::core::data +namespace cubos::core::data::old { class Serializer; @@ -26,7 +26,7 @@ namespace cubos::core::data /// serialization methods: `writeI8`, `writeString`, etc. /// /// @details More complex types can be serialized by implementing a specialization of the - /// `cubos::core::data::serialize` function: + /// `cubos::core::data::old::serialize` function: /// /// struct MyType /// { @@ -34,7 +34,7 @@ namespace cubos::core::data /// }; /// /// // In the corresponding .cpp file. - /// void cubos::core::data::serialize(Serializer& s, const MyType& obj, const char* name) + /// void cubos::core::data::old::serialize(Serializer& s, const MyType& obj, const char* name) /// { /// s.write(obj.a, "a"); /// } @@ -123,7 +123,7 @@ namespace cubos::core::data virtual void writeString(const char* str, const char* name) = 0; /// Serializes an object. - /// The `cubos::core::data::serialize` function must be implemented for the given type. + /// The `cubos::core::data::old::serialize` function must be implemented for the given type. /// @tparam T The type of the object. /// @param obj The object to serialize. /// @param name The name of the object (optional). @@ -256,4 +256,4 @@ namespace cubos::core::data ser.write(obj.second, "second"); ser.endObject(); } -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/ecs/blueprint.hpp b/core/include/cubos/core/ecs/blueprint.hpp index febfab82a..8edf8e52a 100644 --- a/core/include/cubos/core/ecs/blueprint.hpp +++ b/core/include/cubos/core/ecs/blueprint.hpp @@ -45,7 +45,7 @@ namespace cubos::core::ecs /// @param entity Entity identifier. /// @param name Component type name. /// @param deserializer Ddeserializer to deserialize from. - bool addFromDeserializer(Entity entity, const std::string& name, data::Deserializer& deserializer); + bool addFromDeserializer(Entity entity, const std::string& name, data::old::Deserializer& deserializer); /// @brief Returns an entity from its name. /// @param name Entity name. @@ -85,14 +85,15 @@ namespace cubos::core::ecs /// @brief Adds all of the components stored in the buffer to the specified commands object. /// @param commands Commands object to add the components to. /// @param context Context to use when deserializing the components. - virtual void addAll(CommandBuffer& commands, data::Context& context) = 0; + virtual void addAll(CommandBuffer& commands, data::old::Context& context) = 0; /// @brief Merges the data of another buffer of the same type into this one. /// @param other Buffer to merge from. /// @param prefix Prefix to add to the names of the components of the other buffer. /// @param src Context to use when serializing the components from the other buffer. /// @param dst Context to use when deserializing the components to this buffer. - virtual void merge(IBuffer* other, const std::string& prefix, data::Context& src, data::Context& dst) = 0; + virtual void merge(IBuffer* other, const std::string& prefix, data::old::Context& src, + data::old::Context& dst) = 0; /// @brief Creates a new buffer of the same type as this one. /// @return New buffer. @@ -106,15 +107,15 @@ namespace cubos::core::ecs { // Interface methods implementation. - inline void addAll(CommandBuffer& commands, data::Context& context) override + inline void addAll(CommandBuffer& commands, data::old::Context& context) override { this->mutex.lock(); auto pos = this->stream.tell(); this->stream.seek(0, memory::SeekOrigin::Begin); - auto des = data::BinaryDeserializer(this->stream); + auto des = data::old::BinaryDeserializer(this->stream); des.context().pushSubContext(context); - auto& map = des.context().get>(); + auto& map = des.context().get>(); for (const auto& name : this->names) { ComponentType type; @@ -131,16 +132,16 @@ namespace cubos::core::ecs } } - inline void merge(IBuffer* other, const std::string& prefix, data::Context& src, - data::Context& dst) override + inline void merge(IBuffer* other, const std::string& prefix, data::old::Context& src, + data::old::Context& dst) override { auto buffer = static_cast*>(other); buffer->mutex.lock(); auto pos = buffer->stream.tell(); buffer->stream.seek(0, memory::SeekOrigin::Begin); - auto ser = data::BinarySerializer(this->stream); - auto des = data::BinaryDeserializer(buffer->stream); + auto ser = data::old::BinarySerializer(this->stream); + auto des = data::old::BinaryDeserializer(buffer->stream); ser.context().pushSubContext(dst); des.context().pushSubContext(src); for (const auto& name : buffer->names) @@ -164,7 +165,7 @@ namespace cubos::core::ecs }; /// @brief Stores the entity handles and the associated names. - data::SerializationMap mMap; + data::old::SerializationMap mMap; /// @brief Buffers which store the serialized components of each type in this blueprint. memory::TypeMap mBuffers; @@ -201,7 +202,7 @@ namespace cubos::core::ecs buf = *ptr; } - auto ser = data::BinarySerializer(buf->stream); + auto ser = data::old::BinarySerializer(buf->stream); ser.context().push(mMap); ser.write(components, "data"); buf->names.push_back(mMap.getId(entity)); diff --git a/core/include/cubos/core/ecs/commands.hpp b/core/include/cubos/core/ecs/commands.hpp index 5bccf5347..c04de3a03 100644 --- a/core/include/cubos/core/ecs/commands.hpp +++ b/core/include/cubos/core/ecs/commands.hpp @@ -91,13 +91,13 @@ namespace cubos::core::ecs private: friend CommandBuffer; - data::SerializationMap mMap; ///< Maps entity names to the instantiated entities. - CommandBuffer& mCommands; ///< Commands object that created this entity. + data::old::SerializationMap mMap; ///< Maps entity names to the instantiated entities. + CommandBuffer& mCommands; ///< Commands object that created this entity. /// @brief Constructs. /// @param map Map of entity names to the instantiated entities. /// @param commands Commands object that created this entity. - BlueprintBuilder(data::SerializationMap&& map, CommandBuffer& commands); + BlueprintBuilder(data::old::SerializationMap&& map, CommandBuffer& commands); }; /// @brief Used to write ECS commands and execute them at a later time. diff --git a/core/include/cubos/core/ecs/component_manager.hpp b/core/include/cubos/core/ecs/component_manager.hpp index 35551afe7..9e0de1ea4 100644 --- a/core/include/cubos/core/ecs/component_manager.hpp +++ b/core/include/cubos/core/ecs/component_manager.hpp @@ -167,7 +167,7 @@ namespace cubos::core::ecs /// @param componentId Component identifier. /// @param context Optional context to use for serialization. /// @return Package containing the component. - data::Package pack(uint32_t id, std::size_t componentId, data::Context* context) const; + data::old::Package pack(uint32_t id, std::size_t componentId, data::old::Context* context) const; /// @brief Inserts a component into an entity, by unpacking a package. /// @param id Entity index. @@ -175,7 +175,8 @@ namespace cubos::core::ecs /// @param package Package to unpack. /// @param context Optional context to use for deserialization. /// @return Whether the unpacking was successful. - bool unpack(uint32_t id, std::size_t componentId, const data::Package& package, data::Context* context); + bool unpack(uint32_t id, std::size_t componentId, const data::old::Package& package, + data::old::Context* context); private: struct Entry diff --git a/core/include/cubos/core/ecs/entity_manager.hpp b/core/include/cubos/core/ecs/entity_manager.hpp index 826bfacb9..20c2380b6 100644 --- a/core/include/cubos/core/ecs/entity_manager.hpp +++ b/core/include/cubos/core/ecs/entity_manager.hpp @@ -16,7 +16,7 @@ namespace cubos::core::ecs /// @brief Identifies an entity. /// /// When serializing/deserializing, if there's a - /// data::SerializationMap in the context, it will be used to + /// data::old::SerializationMap in the context, it will be used to /// (de)serialize strings representing the entities. Otherwise, the identifiers will be /// (de)serialized as objects with two fields: their index and their generation. /// diff --git a/core/include/cubos/core/ecs/registry.hpp b/core/include/cubos/core/ecs/registry.hpp index 483b0972b..6337e4a13 100644 --- a/core/include/cubos/core/ecs/registry.hpp +++ b/core/include/cubos/core/ecs/registry.hpp @@ -30,7 +30,7 @@ namespace cubos::core::ecs /// @param blueprint Blueprint to instantiate the component into. /// @param id Blueprint entity to add the component to. /// @return Whether the instantiation was successful. - static bool create(std::string_view name, data::Deserializer& des, Blueprint& blueprint, Entity id); + static bool create(std::string_view name, data::old::Deserializer& des, Blueprint& blueprint, Entity id); /// @brief Instantiates a component storage for the given component type. /// @param type Type index of the component. @@ -63,7 +63,7 @@ namespace cubos::core::ecs std::string name; ///< Name of the component. /// Function for creating the component from a deserializer. - bool (*componentCreator)(data::Deserializer&, Blueprint&, Entity); + bool (*componentCreator)(data::old::Deserializer&, Blueprint&, Entity); /// Function for creating the storage for the component. std::unique_ptr (*storageCreator)(); @@ -91,7 +91,7 @@ namespace cubos::core::ecs .type = typeid(T), .name = std::string(name), .componentCreator = - [](data::Deserializer& des, Blueprint& blueprint, Entity id) { + [](data::old::Deserializer& des, Blueprint& blueprint, Entity id) { T comp; des.read(comp); if (des.failed()) diff --git a/core/include/cubos/core/ecs/storage.hpp b/core/include/cubos/core/ecs/storage.hpp index c07968507..c4b65a608 100644 --- a/core/include/cubos/core/ecs/storage.hpp +++ b/core/include/cubos/core/ecs/storage.hpp @@ -29,14 +29,14 @@ namespace cubos::core::ecs /// @param index Index of the value to package. /// @param context Optional context used for serialization. /// @return Packaged value. - virtual data::Package pack(uint32_t index, data::Context* context) const = 0; + virtual data::old::Package pack(uint32_t index, data::old::Context* context) const = 0; /// @brief Unpackages a value. /// @param index Index of the value to unpackage. /// @param package Package to unpackage. /// @param context Optional context used for deserialization. /// @return Whether the unpackaging was successful. - virtual bool unpack(uint32_t index, const data::Package& package, data::Context* context) = 0; + virtual bool unpack(uint32_t index, const data::old::Package& package, data::old::Context* context) = 0; /// @brief Gets the type the components being stored here. /// @return Component type. @@ -70,12 +70,12 @@ namespace cubos::core::ecs // Implementation. - inline data::Package pack(uint32_t index, data::Context* context) const override + inline data::old::Package pack(uint32_t index, data::old::Context* context) const override { - return data::Package::from(*this->get(index), context); + return data::old::Package::from(*this->get(index), context); } - inline bool unpack(uint32_t index, const data::Package& package, data::Context* context) override + inline bool unpack(uint32_t index, const data::old::Package& package, data::old::Context* context) override { T value; if (package.into(value, context)) diff --git a/core/include/cubos/core/ecs/world.hpp b/core/include/cubos/core/ecs/world.hpp index 6b3d63144..eb502b785 100644 --- a/core/include/cubos/core/ecs/world.hpp +++ b/core/include/cubos/core/ecs/world.hpp @@ -106,7 +106,7 @@ namespace cubos::core::ecs /// @param entity Entity identifier. /// @param context Optional context for serializing the components. /// @return Package containing the components of the entity. - data::Package pack(Entity entity, data::Context* context = nullptr) const; + data::old::Package pack(Entity entity, data::old::Context* context = nullptr) const; /// @brief Unpacks components specified in a package into an entity. /// @@ -116,7 +116,7 @@ namespace cubos::core::ecs /// @param package Package to unpack. /// @param context Optional context for deserializing the components. /// @return Whether the package was unpacked successfully. - bool unpack(Entity entity, const data::Package& package, data::Context* context = nullptr); + bool unpack(Entity entity, const data::old::Package& package, data::old::Context* context = nullptr); /// @brief Returns an iterator which points to the first entity of the world. /// @return Iterator. diff --git a/core/include/cubos/core/geom/box.hpp b/core/include/cubos/core/geom/box.hpp index 1ee1426f7..974502018 100644 --- a/core/include/cubos/core/geom/box.hpp +++ b/core/include/cubos/core/geom/box.hpp @@ -52,7 +52,7 @@ namespace cubos::core::geom }; } // namespace cubos::core::geom -namespace cubos::core::data +namespace cubos::core::data::old { inline void serialize(Serializer& ser, const geom::Box& box, const char* name) { @@ -67,4 +67,4 @@ namespace cubos::core::data des.read(box.halfSize); des.endObject(); } -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/geom/capsule.hpp b/core/include/cubos/core/geom/capsule.hpp index 94616b2e0..8b777f13f 100644 --- a/core/include/cubos/core/geom/capsule.hpp +++ b/core/include/cubos/core/geom/capsule.hpp @@ -33,7 +33,7 @@ namespace cubos::core::geom }; } // namespace cubos::core::geom -namespace cubos::core::data +namespace cubos::core::data::old { inline void serialize(Serializer& ser, const geom::Capsule& capsule, const char* name) { @@ -50,4 +50,4 @@ namespace cubos::core::data des.read(capsule.length); des.endObject(); } -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/geom/plane.hpp b/core/include/cubos/core/geom/plane.hpp index 199f570a3..66e008a44 100644 --- a/core/include/cubos/core/geom/plane.hpp +++ b/core/include/cubos/core/geom/plane.hpp @@ -19,7 +19,7 @@ namespace cubos::core::geom }; } // namespace cubos::core::geom -namespace cubos::core::data +namespace cubos::core::data::old { inline void serialize(Serializer& ser, const geom::Plane& plane, const char* name) { @@ -34,4 +34,4 @@ namespace cubos::core::data des.read(plane.normal); des.endObject(); } -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/geom/simplex.hpp b/core/include/cubos/core/geom/simplex.hpp index 87c3c1aeb..dd9200ee7 100644 --- a/core/include/cubos/core/geom/simplex.hpp +++ b/core/include/cubos/core/geom/simplex.hpp @@ -68,7 +68,7 @@ namespace cubos::core::geom }; } // namespace cubos::core::geom -namespace cubos::core::data +namespace cubos::core::data::old { inline void serialize(Serializer& ser, const geom::Simplex& simplex, const char* name) { @@ -79,4 +79,4 @@ namespace cubos::core::data { des.read(simplex.points); } -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/core/samples/data/serialization/main.cpp b/core/samples/data/serialization/main.cpp index c76ce205f..1938f7dc5 100644 --- a/core/samples/data/serialization/main.cpp +++ b/core/samples/data/serialization/main.cpp @@ -3,7 +3,7 @@ #include using namespace cubos::core::memory; -using namespace cubos::core::data; +using namespace cubos::core::data::old; // Simple serializable type. struct Fruit @@ -22,7 +22,7 @@ struct Human }; template <> -void cubos::core::data::serialize(Serializer& ser, const Fruit& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const Fruit& obj, const char* name) { ser.beginObject(name); ser.write(obj.name, "name"); @@ -31,7 +31,7 @@ void cubos::core::data::serialize(Serializer& ser, const Fruit& obj, cons } template <> -void cubos::core::data::serialize(Serializer& ser, const Human& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const Human& obj, const char* name) { // Get necessary context from the serializer. auto& map = ser.context().get>(); diff --git a/core/samples/ecs/general/main.cpp b/core/samples/ecs/general/main.cpp index 3f771d069..ba219dba2 100644 --- a/core/samples/ecs/general/main.cpp +++ b/core/samples/ecs/general/main.cpp @@ -31,7 +31,7 @@ struct Parent ecs::Entity entity; }; -namespace cubos::core::data +namespace cubos::core::data::old { void serialize(Serializer& /*unused*/, const Player& /*unused*/, const char* /*unused*/) { @@ -88,7 +88,7 @@ namespace cubos::core::data { des.read(parent.entity); } -} // namespace cubos::core::data +} // namespace cubos::core::data::old CUBOS_REGISTER_COMPONENT(Player, ecs::NullStorage, "Player") CUBOS_REGISTER_COMPONENT(Position, ecs::VecStorage, "Position") diff --git a/core/samples/logging/main.cpp b/core/samples/logging/main.cpp index a28546c79..65eb33554 100644 --- a/core/samples/logging/main.cpp +++ b/core/samples/logging/main.cpp @@ -7,7 +7,7 @@ /// [Debug wrapper include] #include -using namespace cubos::core::data; +using cubos::core::data::old::Debug; /// [Debug wrapper include] /// [Logger initialization] diff --git a/core/samples/logging/page.md b/core/samples/logging/page.md index ccc3d31f0..ffcfa61d4 100644 --- a/core/samples/logging/page.md +++ b/core/samples/logging/page.md @@ -24,11 +24,11 @@ These macros can also take arguments: severity level @ref CUBOS_LOG_LEVEL_INFO or higher are logged. This can be changed by defining @ref CUBOS_LOG_LEVEL to the desired level. -Serializable types can also be logged, using @ref cubos::core::data::Debug. +Serializable types can also be logged, using @ref cubos::core::data::old::Debug. @snippet logging/main.cpp Debug wrapper include -By wrapping the value in @ref cubos::core::data::Debug, the type is serialized using the -@ref cubos::core::data::DebugSerializer, and the result is logged. +By wrapping the value in @ref cubos::core::data::old::Debug, the type is serialized using the +@ref cubos::core::data::old::DebugSerializer, and the result is logged. @snippet logging/main.cpp Debug wrapper usage \ No newline at end of file diff --git a/core/src/cubos/core/data/old/binary_deserializer.cpp b/core/src/cubos/core/data/old/binary_deserializer.cpp index 9794fcb36..1c4de7ff3 100644 --- a/core/src/cubos/core/data/old/binary_deserializer.cpp +++ b/core/src/cubos/core/data/old/binary_deserializer.cpp @@ -2,7 +2,7 @@ #include using namespace cubos::core; -using namespace cubos::core::data; +using namespace cubos::core::data::old; template static inline T fromEndianness(T val, bool fromLittleEndian) diff --git a/core/src/cubos/core/data/old/binary_serializer.cpp b/core/src/cubos/core/data/old/binary_serializer.cpp index 719d690a0..b87879664 100644 --- a/core/src/cubos/core/data/old/binary_serializer.cpp +++ b/core/src/cubos/core/data/old/binary_serializer.cpp @@ -4,7 +4,7 @@ #include using namespace cubos::core; -using namespace cubos::core::data; +using namespace cubos::core::data::old; template static inline T toEndianness(T val, bool toLittleEndian) diff --git a/core/src/cubos/core/data/old/context.cpp b/core/src/cubos/core/data/old/context.cpp index 3e253161e..a3f6757e1 100644 --- a/core/src/cubos/core/data/old/context.cpp +++ b/core/src/cubos/core/data/old/context.cpp @@ -1,7 +1,7 @@ #include #include -using namespace cubos::core::data; +using namespace cubos::core::data::old; Context::~Context() { diff --git a/core/src/cubos/core/data/old/debug_serializer.cpp b/core/src/cubos/core/data/old/debug_serializer.cpp index 39d4f98c8..dca1cba49 100644 --- a/core/src/cubos/core/data/old/debug_serializer.cpp +++ b/core/src/cubos/core/data/old/debug_serializer.cpp @@ -1,7 +1,7 @@ #include using namespace cubos::core; -using namespace cubos::core::data; +using namespace cubos::core::data::old; DebugSerializer::DebugSerializer(memory::Stream& stream, bool pretty, bool typeNames) : mStream(stream) diff --git a/core/src/cubos/core/data/old/deserializer.cpp b/core/src/cubos/core/data/old/deserializer.cpp index 032e846b7..080f9478d 100644 --- a/core/src/cubos/core/data/old/deserializer.cpp +++ b/core/src/cubos/core/data/old/deserializer.cpp @@ -5,7 +5,7 @@ #include -using namespace cubos::core::data; +using namespace cubos::core::data::old; Deserializer::Deserializer() { @@ -25,78 +25,78 @@ void Deserializer::fail() // Implementation of deserialize() for primitive types. template <> -void cubos::core::data::deserialize(Deserializer& des, int8_t& obj) +void cubos::core::data::old::deserialize(Deserializer& des, int8_t& obj) { des.readI8(obj); } template <> -void cubos::core::data::deserialize(Deserializer& des, int16_t& obj) +void cubos::core::data::old::deserialize(Deserializer& des, int16_t& obj) { des.readI16(obj); } template <> -void cubos::core::data::deserialize(Deserializer& des, int32_t& obj) +void cubos::core::data::old::deserialize(Deserializer& des, int32_t& obj) { des.readI32(obj); } template <> -void cubos::core::data::deserialize(Deserializer& des, int64_t& obj) +void cubos::core::data::old::deserialize(Deserializer& des, int64_t& obj) { des.readI64(obj); } template <> -void cubos::core::data::deserialize(Deserializer& des, uint8_t& obj) +void cubos::core::data::old::deserialize(Deserializer& des, uint8_t& obj) { des.readU8(obj); } template <> -void cubos::core::data::deserialize(Deserializer& des, uint16_t& obj) +void cubos::core::data::old::deserialize(Deserializer& des, uint16_t& obj) { des.readU16(obj); } template <> -void cubos::core::data::deserialize(Deserializer& des, uint32_t& obj) +void cubos::core::data::old::deserialize(Deserializer& des, uint32_t& obj) { des.readU32(obj); } template <> -void cubos::core::data::deserialize(Deserializer& des, uint64_t& obj) +void cubos::core::data::old::deserialize(Deserializer& des, uint64_t& obj) { des.readU64(obj); } template <> -void cubos::core::data::deserialize(Deserializer& des, float& obj) +void cubos::core::data::old::deserialize(Deserializer& des, float& obj) { des.readF32(obj); } template <> -void cubos::core::data::deserialize(Deserializer& des, double& obj) +void cubos::core::data::old::deserialize(Deserializer& des, double& obj) { des.readF64(obj); } template <> -void cubos::core::data::deserialize(Deserializer& des, bool& obj) +void cubos::core::data::old::deserialize(Deserializer& des, bool& obj) { des.readBool(obj); } template <> -void cubos::core::data::deserialize(Deserializer& des, std::string& obj) +void cubos::core::data::old::deserialize(Deserializer& des, std::string& obj) { des.readString(obj); } -void cubos::core::data::deserialize(Deserializer& des, std::vector::reference obj) +void cubos::core::data::old::deserialize(Deserializer& des, std::vector::reference obj) { bool boolean; des.readBool(boolean); @@ -108,7 +108,7 @@ void cubos::core::data::deserialize(Deserializer& des, std::vector::refere // NOLINTBEGIN(bugprone-macro-parentheses) #define IMPL_DESERIALIZE_GLM(T) \ template <> \ - void cubos::core::data::deserialize>(Deserializer & des, glm::tvec2 & obj) \ + void cubos::core::data::old::deserialize>(Deserializer & des, glm::tvec2 & obj) \ { \ des.beginObject(); \ des.read(obj.x); \ @@ -117,7 +117,7 @@ void cubos::core::data::deserialize(Deserializer& des, std::vector::refere } \ \ template <> \ - void cubos::core::data::deserialize>(Deserializer & des, glm::tvec3 & obj) \ + void cubos::core::data::old::deserialize>(Deserializer & des, glm::tvec3 & obj) \ { \ des.beginObject(); \ des.read(obj.x); \ @@ -127,7 +127,7 @@ void cubos::core::data::deserialize(Deserializer& des, std::vector::refere } \ \ template <> \ - void cubos::core::data::deserialize>(Deserializer & des, glm::tvec4 & obj) \ + void cubos::core::data::old::deserialize>(Deserializer & des, glm::tvec4 & obj) \ { \ des.beginObject(); \ des.read(obj.x); \ @@ -138,7 +138,7 @@ void cubos::core::data::deserialize(Deserializer& des, std::vector::refere } \ \ template <> \ - void cubos::core::data::deserialize>(Deserializer & des, glm::tquat & obj) \ + void cubos::core::data::old::deserialize>(Deserializer & des, glm::tquat & obj) \ { \ des.beginObject(); \ des.read(obj.w); \ @@ -149,7 +149,7 @@ void cubos::core::data::deserialize(Deserializer& des, std::vector::refere } \ \ template <> \ - void cubos::core::data::deserialize>(Deserializer & des, glm::tmat4x4 & obj) \ + void cubos::core::data::old::deserialize>(Deserializer & des, glm::tmat4x4 & obj) \ { \ des.beginObject(); \ des.read(obj[0]); \ diff --git a/core/src/cubos/core/data/old/json_deserializer.cpp b/core/src/cubos/core/data/old/json_deserializer.cpp index df506f733..38ad73376 100644 --- a/core/src/cubos/core/data/old/json_deserializer.cpp +++ b/core/src/cubos/core/data/old/json_deserializer.cpp @@ -2,7 +2,7 @@ #include using namespace cubos::core; -using namespace cubos::core::data; +using namespace cubos::core::data::old; #define CHECK_ERROR(exp) \ do \ diff --git a/core/src/cubos/core/data/old/json_serializer.cpp b/core/src/cubos/core/data/old/json_serializer.cpp index 3854e3828..d5374d761 100644 --- a/core/src/cubos/core/data/old/json_serializer.cpp +++ b/core/src/cubos/core/data/old/json_serializer.cpp @@ -1,7 +1,7 @@ #include #include -using namespace cubos::core::data; +using namespace cubos::core::data::old; JSONSerializer::JSONSerializer(memory::Stream& stream, int indent) : mStream(stream) diff --git a/core/src/cubos/core/data/old/package.cpp b/core/src/cubos/core/data/old/package.cpp index cbafdf163..eecf4f199 100644 --- a/core/src/cubos/core/data/old/package.cpp +++ b/core/src/cubos/core/data/old/package.cpp @@ -2,7 +2,7 @@ #include -using namespace cubos::core::data; +using namespace cubos::core::data::old; Package::Package(Type type) { diff --git a/core/src/cubos/core/data/old/serializer.cpp b/core/src/cubos/core/data/old/serializer.cpp index 9f5bd69df..c784c06f8 100644 --- a/core/src/cubos/core/data/old/serializer.cpp +++ b/core/src/cubos/core/data/old/serializer.cpp @@ -7,7 +7,7 @@ #include -using namespace cubos::core::data; +using namespace cubos::core::data::old; Serializer::Serializer() { @@ -27,84 +27,84 @@ bool Serializer::failed() const // Implementation of serialize() for primitive types. template <> -void cubos::core::data::serialize(Serializer& ser, const int8_t& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const int8_t& obj, const char* name) { ser.writeI8(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const int16_t& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const int16_t& obj, const char* name) { ser.writeI16(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const int32_t& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const int32_t& obj, const char* name) { ser.writeI32(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const int64_t& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const int64_t& obj, const char* name) { ser.writeI64(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const uint8_t& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const uint8_t& obj, const char* name) { ser.writeU8(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const uint16_t& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const uint16_t& obj, const char* name) { ser.writeU16(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const uint32_t& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const uint32_t& obj, const char* name) { ser.writeU32(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const uint64_t& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const uint64_t& obj, const char* name) { ser.writeU64(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const float& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const float& obj, const char* name) { ser.writeF32(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const double& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const double& obj, const char* name) { ser.writeF64(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const bool& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const bool& obj, const char* name) { ser.writeBool(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const char* const& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const char* const& obj, const char* name) { ser.writeString(obj, name); } template <> -void cubos::core::data::serialize(Serializer& ser, const std::string& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const std::string& obj, const char* name) { ser.writeString(obj.c_str(), name); } -void cubos::core::data::serialize(Serializer& ser, std::vector::const_reference obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, std::vector::const_reference obj, const char* name) { ser.writeBool(obj, name); } @@ -114,7 +114,8 @@ void cubos::core::data::serialize(Serializer& ser, std::vector::const_refe // NOLINTBEGIN(bugprone-macro-parentheses) #define IMPL_SERIALIZE_GLM(T) \ template <> \ - void cubos::core::data::serialize>(Serializer & ser, const glm::tvec2& obj, const char* name) \ + void cubos::core::data::old::serialize>(Serializer & ser, const glm::tvec2& obj, \ + const char* name) \ { \ ser.beginObject(name); \ ser.write(obj.x, "x"); \ @@ -123,7 +124,8 @@ void cubos::core::data::serialize(Serializer& ser, std::vector::const_refe } \ \ template <> \ - void cubos::core::data::serialize>(Serializer & ser, const glm::tvec3& obj, const char* name) \ + void cubos::core::data::old::serialize>(Serializer & ser, const glm::tvec3& obj, \ + const char* name) \ { \ ser.beginObject(name); \ ser.write(obj.x, "x"); \ @@ -133,7 +135,8 @@ void cubos::core::data::serialize(Serializer& ser, std::vector::const_refe } \ \ template <> \ - void cubos::core::data::serialize>(Serializer & ser, const glm::tvec4& obj, const char* name) \ + void cubos::core::data::old::serialize>(Serializer & ser, const glm::tvec4& obj, \ + const char* name) \ { \ ser.beginObject(name); \ ser.write(obj.x, "x"); \ @@ -144,7 +147,8 @@ void cubos::core::data::serialize(Serializer& ser, std::vector::const_refe } \ \ template <> \ - void cubos::core::data::serialize>(Serializer & ser, const glm::tquat& obj, const char* name) \ + void cubos::core::data::old::serialize>(Serializer & ser, const glm::tquat& obj, \ + const char* name) \ { \ ser.beginObject(name); \ ser.write(obj.w, "w"); \ @@ -155,7 +159,8 @@ void cubos::core::data::serialize(Serializer& ser, std::vector::const_refe } \ \ template <> \ - void cubos::core::data::serialize>(Serializer & ser, const glm::tmat4x4& obj, const char* name) \ + void cubos::core::data::old::serialize>(Serializer & ser, const glm::tmat4x4& obj, \ + const char* name) \ { \ ser.beginObject(name); \ ser.write(obj[0], "0"); \ diff --git a/core/src/cubos/core/ecs/blueprint.cpp b/core/src/cubos/core/ecs/blueprint.cpp index c165b86e7..71beba080 100644 --- a/core/src/cubos/core/ecs/blueprint.cpp +++ b/core/src/cubos/core/ecs/blueprint.cpp @@ -11,7 +11,7 @@ Blueprint::~Blueprint() } } -bool Blueprint::addFromDeserializer(Entity entity, const std::string& name, data::Deserializer& deserializer) +bool Blueprint::addFromDeserializer(Entity entity, const std::string& name, data::old::Deserializer& deserializer) { assert(entity.generation == 0); return Registry::create(name, deserializer, *this, entity); @@ -30,7 +30,7 @@ Entity Blueprint::entity(const std::string& name) const void Blueprint::merge(const std::string& prefix, const Blueprint& other) { // First, merge the maps. - data::SerializationMap srcMap; + data::old::SerializationMap srcMap; for (uint32_t i = 0; i < static_cast(other.mMap.size()); ++i) { // Deserialize from the source buffer using the original entity names. @@ -44,8 +44,8 @@ void Blueprint::merge(const std::string& prefix, const Blueprint& other) mMap.add(Entity(static_cast(mMap.size()), 0), dstName); } - data::Context src; - data::Context dst; + data::old::Context src; + data::old::Context dst; src.push(srcMap); dst.push(mMap); diff --git a/core/src/cubos/core/ecs/commands.cpp b/core/src/cubos/core/ecs/commands.cpp index 9da9b6d12..e326fbd4c 100644 --- a/core/src/cubos/core/ecs/commands.cpp +++ b/core/src/cubos/core/ecs/commands.cpp @@ -15,7 +15,7 @@ Entity EntityBuilder::entity() const return mEntity; } -BlueprintBuilder::BlueprintBuilder(data::SerializationMap&& map, CommandBuffer& commands) +BlueprintBuilder::BlueprintBuilder(data::old::SerializationMap&& map, CommandBuffer& commands) : mMap(std::move(map)) , mCommands(commands) { @@ -69,13 +69,13 @@ void CommandBuffer::destroy(Entity entity) BlueprintBuilder CommandBuffer::spawn(const Blueprint& blueprint) { - data::SerializationMap map; + data::old::SerializationMap map; for (uint32_t i = 0; i < static_cast(blueprint.mMap.size()); ++i) { map.add(this->create().entity(), blueprint.mMap.getId(Entity(i, 0))); } - data::Context context; + data::old::Context context; context.push(map); for (const auto& buf : blueprint.mBuffers) { diff --git a/core/src/cubos/core/ecs/component_manager.cpp b/core/src/cubos/core/ecs/component_manager.cpp index edc572b55..0927b9a73 100644 --- a/core/src/cubos/core/ecs/component_manager.cpp +++ b/core/src/cubos/core/ecs/component_manager.cpp @@ -69,13 +69,13 @@ ComponentManager::Entry::Entry(std::unique_ptr storage) this->mutex = std::make_unique(); } -data::Package ComponentManager::pack(uint32_t id, std::size_t componentId, data::Context* context) const +data::old::Package ComponentManager::pack(uint32_t id, std::size_t componentId, data::old::Context* context) const { return mEntries[componentId - 1].storage->pack(id, context); } -bool ComponentManager::unpack(uint32_t id, std::size_t componentId, const data::Package& package, - data::Context* context) +bool ComponentManager::unpack(uint32_t id, std::size_t componentId, const data::old::Package& package, + data::old::Context* context) { return mEntries[componentId - 1].storage->unpack(id, package, context); } diff --git a/core/src/cubos/core/ecs/entity_manager.cpp b/core/src/cubos/core/ecs/entity_manager.cpp index b7d0f0264..3620dfc14 100644 --- a/core/src/cubos/core/ecs/entity_manager.cpp +++ b/core/src/cubos/core/ecs/entity_manager.cpp @@ -7,7 +7,7 @@ using namespace cubos::core::ecs; using namespace cubos::core::data; template <> -void cubos::core::data::serialize(Serializer& ser, const Entity& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const Entity& obj, const char* name) { if (ser.context().has>()) { @@ -30,7 +30,7 @@ void cubos::core::data::serialize(Serializer& ser, const Entity& obj, co } template <> -void cubos::core::data::deserialize(Deserializer& des, Entity& obj) +void cubos::core::data::old::deserialize(Deserializer& des, Entity& obj) { if (des.context().has>()) { diff --git a/core/src/cubos/core/ecs/registry.cpp b/core/src/cubos/core/ecs/registry.cpp index 176463752..ca7cefd0e 100644 --- a/core/src/cubos/core/ecs/registry.cpp +++ b/core/src/cubos/core/ecs/registry.cpp @@ -3,7 +3,7 @@ using namespace cubos::core; using namespace cubos::core::ecs; -bool Registry::create(std::string_view name, data::Deserializer& des, Blueprint& blueprint, Entity id) +bool Registry::create(std::string_view name, data::old::Deserializer& des, Blueprint& blueprint, Entity id) { auto& creators = Registry::entriesByName(); if (auto it = creators.find(std::string(name)); it != creators.end()) diff --git a/core/src/cubos/core/ecs/world.cpp b/core/src/cubos/core/ecs/world.cpp index 64b08f942..23fbd5e07 100644 --- a/core/src/cubos/core/ecs/world.cpp +++ b/core/src/cubos/core/ecs/world.cpp @@ -23,13 +23,13 @@ bool World::isAlive(Entity entity) const return mEntityManager.isAlive(entity); } -data::Package World::pack(Entity entity, data::Context* context) const +data::old::Package World::pack(Entity entity, data::old::Context* context) const { CUBOS_ASSERT(this->isAlive(entity), "Entity is not alive"); Entity::Mask mask = mEntityManager.getMask(entity); - auto pkg = data::Package(data::Package::Type::Object); + auto pkg = data::old::Package(data::old::Package::Type::Object); for (std::size_t i = 1; i < mask.size(); ++i) { if (mask.test(i)) @@ -42,9 +42,9 @@ data::Package World::pack(Entity entity, data::Context* context) const return pkg; } -bool World::unpack(Entity entity, const data::Package& package, data::Context* context) +bool World::unpack(Entity entity, const data::old::Package& package, data::old::Context* context) { - if (package.type() != data::Package::Type::Object) + if (package.type() != data::old::Package::Type::Object) { CUBOS_ERROR("Entities must be packaged as objects"); return false; diff --git a/core/src/cubos/core/io/gamepad.cpp b/core/src/cubos/core/io/gamepad.cpp index bd3063058..56d804395 100644 --- a/core/src/cubos/core/io/gamepad.cpp +++ b/core/src/cubos/core/io/gamepad.cpp @@ -2,8 +2,8 @@ #include #include -using cubos::core::data::Deserializer; -using cubos::core::data::Serializer; +using cubos::core::data::old::Deserializer; +using cubos::core::data::old::Serializer; using cubos::core::io::GamepadAxis; using cubos::core::io::GamepadButton; using namespace cubos::core; @@ -37,7 +37,7 @@ std::string io::gamepadButtonToString(GamepadButton button) } template <> -void data::serialize(Serializer& ser, const GamepadButton& obj, const char* name) +void data::old::serialize(Serializer& ser, const GamepadButton& obj, const char* name) { ser.write(io::gamepadButtonToString(obj), name); } @@ -68,7 +68,7 @@ GamepadButton io::stringToGamepadButton(const std::string& str) } template <> -void data::deserialize(Deserializer& des, GamepadButton& obj) +void data::old::deserialize(Deserializer& des, GamepadButton& obj) { std::string axis; des.read(axis); @@ -95,7 +95,7 @@ std::string io::gamepadAxisToString(GamepadAxis axis) } template <> -void data::serialize(Serializer& ser, const GamepadAxis& obj, const char* name) +void data::old::serialize(Serializer& ser, const GamepadAxis& obj, const char* name) { ser.write(io::gamepadAxisToString(obj), name); } @@ -117,7 +117,7 @@ GamepadAxis io::stringToGamepadAxis(const std::string& str) } template <> -void data::deserialize(Deserializer& des, GamepadAxis& obj) +void data::old::deserialize(Deserializer& des, GamepadAxis& obj) { std::string axis; des.read(axis); diff --git a/core/src/cubos/core/io/keyboard.cpp b/core/src/cubos/core/io/keyboard.cpp index 10c857ced..eae5c873d 100644 --- a/core/src/cubos/core/io/keyboard.cpp +++ b/core/src/cubos/core/io/keyboard.cpp @@ -2,8 +2,8 @@ #include #include -using cubos::core::data::Deserializer; -using cubos::core::data::Serializer; +using cubos::core::data::old::Deserializer; +using cubos::core::data::old::Serializer; using cubos::core::io::Key; using cubos::core::io::Modifiers; using namespace cubos::core; @@ -36,7 +36,7 @@ std::string io::modifiersToString(Modifiers modifiers) } template <> -void data::serialize(Serializer& ser, const Modifiers& obj, const char* name) +void data::old::serialize(Serializer& ser, const Modifiers& obj, const char* name) { ser.write(io::modifiersToString(obj), name); } @@ -69,7 +69,7 @@ Modifiers io::stringToModifiers(const std::string& str) } template <> -void data::deserialize(Deserializer& des, Modifiers& obj) +void data::old::deserialize(Deserializer& des, Modifiers& obj) { std::string str; des.read(str); @@ -188,7 +188,7 @@ std::string io::keyToString(Key key) } template <> -void data::serialize(Serializer& ser, const Key& obj, const char* name) +void data::old::serialize(Serializer& ser, const Key& obj, const char* name) { ser.write(io::keyToString(obj), name); } @@ -302,7 +302,7 @@ Key io::stringToKey(const std::string& str) } template <> -void data::deserialize(Deserializer& des, Key& obj) +void data::old::deserialize(Deserializer& des, Key& obj) { std::string str; des.read(str); diff --git a/core/tests/data/context.cpp b/core/tests/data/context.cpp index ace53a623..c185ab09d 100644 --- a/core/tests/data/context.cpp +++ b/core/tests/data/context.cpp @@ -4,9 +4,9 @@ #include "utils.hpp" -using cubos::core::data::Context; +using cubos::core::data::old::Context; -TEST_CASE("data::Context") +TEST_CASE("data::old::Context") { SUBCASE("empty does not have int") { diff --git a/core/tests/ecs/blueprint.cpp b/core/tests/ecs/blueprint.cpp index 28b34504e..98e528cfc 100644 --- a/core/tests/ecs/blueprint.cpp +++ b/core/tests/ecs/blueprint.cpp @@ -4,8 +4,8 @@ #include "utils.hpp" -using cubos::core::data::Package; -using cubos::core::data::Unpackager; +using cubos::core::data::old::Package; +using cubos::core::data::old::Unpackager; using cubos::core::ecs::Blueprint; using cubos::core::ecs::CommandBuffer; using cubos::core::ecs::Commands; diff --git a/core/tests/ecs/registry.cpp b/core/tests/ecs/registry.cpp index de70c4023..3a2a82501 100644 --- a/core/tests/ecs/registry.cpp +++ b/core/tests/ecs/registry.cpp @@ -5,8 +5,8 @@ #include "utils.hpp" -using cubos::core::data::Package; -using cubos::core::data::Unpackager; +using cubos::core::data::old::Package; +using cubos::core::data::old::Unpackager; using cubos::core::ecs::Blueprint; using cubos::core::ecs::CommandBuffer; using cubos::core::ecs::Commands; diff --git a/core/tests/ecs/world.cpp b/core/tests/ecs/world.cpp index 74eee3871..7f877907e 100644 --- a/core/tests/ecs/world.cpp +++ b/core/tests/ecs/world.cpp @@ -4,7 +4,7 @@ #include "utils.hpp" -using cubos::core::data::Package; +using cubos::core::data::old::Package; using cubos::core::ecs::Entity; using cubos::core::ecs::World; diff --git a/engine/include/cubos/engine/assets/asset.hpp b/engine/include/cubos/engine/assets/asset.hpp index 0e89d5c75..3683e33d4 100644 --- a/engine/include/cubos/engine/assets/asset.hpp +++ b/engine/include/cubos/engine/assets/asset.hpp @@ -6,11 +6,11 @@ #include -namespace cubos::core::data +namespace cubos::core::data::old { class Serializer; class Deserializer; -} // namespace cubos::core::data +} // namespace cubos::core::data::old namespace cubos::engine { @@ -88,8 +88,8 @@ namespace cubos::engine template inline operator Asset() const; - void serialize(core::data::Serializer& ser, const char* name) const; - void deserialize(core::data::Deserializer& des); + void serialize(core::data::old::Serializer& ser, const char* name) const; + void deserialize(core::data::old::Deserializer& des); private: friend class Assets; diff --git a/engine/include/cubos/engine/assets/bridges/binary.hpp b/engine/include/cubos/engine/assets/bridges/binary.hpp index b26c55a42..349d6a822 100644 --- a/engine/include/cubos/engine/assets/bridges/binary.hpp +++ b/engine/include/cubos/engine/assets/bridges/binary.hpp @@ -36,7 +36,7 @@ namespace cubos::engine bool loadFromFile(Assets& assets, const AnyAsset& handle, core::memory::Stream& stream) override { // Initialize a binary deserializer with the file stream. - core::data::BinaryDeserializer deserializer{stream, mLittleEndian}; + core::data::old::BinaryDeserializer deserializer{stream, mLittleEndian}; // Deserialize the asset and store it in the asset manager. T data{}; @@ -54,7 +54,7 @@ namespace cubos::engine bool saveToFile(const Assets& assets, const AnyAsset& handle, core::memory::Stream& stream) override { // Initialize a binary serializer with the file stream. - core::data::BinarySerializer serializer{stream, mLittleEndian}; + core::data::old::BinarySerializer serializer{stream, mLittleEndian}; // Read the asset from the asset manager and serialize it to the file stream. auto data = assets.read(handle); diff --git a/engine/include/cubos/engine/assets/bridges/json.hpp b/engine/include/cubos/engine/assets/bridges/json.hpp index e9ba003f7..5cfab9b13 100644 --- a/engine/include/cubos/engine/assets/bridges/json.hpp +++ b/engine/include/cubos/engine/assets/bridges/json.hpp @@ -41,7 +41,7 @@ namespace cubos::engine // Dump the file stream into a string and initialize a JSON deserializer with it. std::string json{}; stream.readUntil(json, nullptr); - core::data::JSONDeserializer deserializer{json}; + core::data::old::JSONDeserializer deserializer{json}; // Deserialize the asset and store it in the asset manager. T data{}; @@ -59,7 +59,7 @@ namespace cubos::engine bool saveToFile(const Assets& assets, const AnyAsset& handle, core::memory::Stream& stream) override { // Initialize a JSON serializer with the file stream. - core::data::JSONSerializer serializer{stream, mIndentation}; + core::data::old::JSONSerializer serializer{stream, mIndentation}; // Read the asset from the asset manager and serialize it to the file stream. auto data = assets.read(handle); diff --git a/engine/include/cubos/engine/collisions/aabb.hpp b/engine/include/cubos/engine/collisions/aabb.hpp index 52be651e3..4ab19b257 100644 --- a/engine/include/cubos/engine/collisions/aabb.hpp +++ b/engine/include/cubos/engine/collisions/aabb.hpp @@ -72,7 +72,7 @@ namespace cubos::engine }; } // namespace cubos::engine -namespace cubos::core::data +namespace cubos::core::data::old { inline void serialize(Serializer& ser, const engine::ColliderAABB& aabb, const char* name) { @@ -89,4 +89,4 @@ namespace cubos::core::data des.read(aabb.max); des.endObject(); } -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/engine/include/cubos/engine/imgui/serialization.hpp b/engine/include/cubos/engine/imgui/serialization.hpp index 56a1d6d61..ebcd0baaa 100644 --- a/engine/include/cubos/engine/imgui/serialization.hpp +++ b/engine/include/cubos/engine/imgui/serialization.hpp @@ -17,7 +17,7 @@ namespace cubos::engine /// @param pkg Packaged object to show. /// @param name Name of the object. /// @ingroup imgui-plugin - void imguiShowPackage(const core::data::Package& pkg, const std::string& name); + void imguiShowPackage(const core::data::old::Package& pkg, const std::string& name); /// @brief Shows a packaged object's properties in the UI, allowing the user to edit the /// object. Should be called inside a `ImGui::BeginTable(3)` and `ImGui::EndTable()` block. @@ -30,7 +30,7 @@ namespace cubos::engine /// @param name Name of the object. /// @return True if the object was modified, false otherwise. /// @ingroup imgui-plugin - bool imguiEditPackage(core::data::Package& pkg, const std::string& name); + bool imguiEditPackage(core::data::old::Package& pkg, const std::string& name); /// @brief Shows a serializable object's properties in the UI. Should be called inside a /// `ImGui::BeginTable(2)` and `ImGui::EndTable()` block. @@ -44,7 +44,7 @@ namespace cubos::engine template inline void imguiShow(const T& object, const std::string& name) { - auto pkg = core::data::Package::from(object); + auto pkg = core::data::old::Package::from(object); imguiShowPackage(pkg, name); } @@ -62,7 +62,7 @@ namespace cubos::engine template inline bool imguiEdit(T& object, const std::string& name) { - auto pkg = core::data::Package::from(object); + auto pkg = core::data::old::Package::from(object); if (imguiEditPackage(pkg, name)) { pkg.into(object); diff --git a/engine/include/cubos/engine/renderer/vertex.hpp b/engine/include/cubos/engine/renderer/vertex.hpp index b4a6541a0..5b5621473 100644 --- a/engine/include/cubos/engine/renderer/vertex.hpp +++ b/engine/include/cubos/engine/renderer/vertex.hpp @@ -30,8 +30,8 @@ namespace cubos::engine void triangulate(const VoxelGrid& grid, std::vector& vertices, std::vector& indices); } // namespace cubos::engine -namespace cubos::core::data +namespace cubos::core::data::old { void serialize(Serializer& serializer, const engine::VoxelVertex& vertex, const char* name); void deserialize(Deserializer& deserializer, engine::VoxelVertex& vertex); -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/engine/include/cubos/engine/voxels/grid.hpp b/engine/include/cubos/engine/voxels/grid.hpp index 845c0c9d2..060fce5c2 100644 --- a/engine/include/cubos/engine/voxels/grid.hpp +++ b/engine/include/cubos/engine/voxels/grid.hpp @@ -17,11 +17,11 @@ namespace cubos::engine class VoxelGrid; } // namespace cubos::engine -namespace cubos::core::data +namespace cubos::core::data::old { void serialize(Serializer& serializer, const engine::VoxelGrid& grid, const char* name); void deserialize(Deserializer& deserializer, engine::VoxelGrid& grid); -} // namespace cubos::core::data +} // namespace cubos::core::data::old namespace cubos::engine { @@ -89,9 +89,9 @@ namespace cubos::engine bool convert(const VoxelPalette& src, const VoxelPalette& dst, float minSimilarity); private: - friend void core::data::serialize(core::data::Serializer& /*serializer*/, const VoxelGrid& /*grid*/, - const char* /*name*/); - friend void core::data::deserialize(core::data::Deserializer& /*deserializer*/, VoxelGrid& /*grid*/); + friend void core::data::old::serialize(core::data::old::Serializer& /*serializer*/, const VoxelGrid& /*grid*/, + const char* /*name*/); + friend void core::data::old::deserialize(core::data::old::Deserializer& /*deserializer*/, VoxelGrid& /*grid*/); glm::uvec3 mSize; ///< Size of the grid. std::vector mIndices; ///< Indices of the grid. diff --git a/engine/include/cubos/engine/voxels/material.hpp b/engine/include/cubos/engine/voxels/material.hpp index 6b9d158ed..dc9e521b2 100644 --- a/engine/include/cubos/engine/voxels/material.hpp +++ b/engine/include/cubos/engine/voxels/material.hpp @@ -31,8 +31,8 @@ namespace cubos::engine }; } // namespace cubos::engine -namespace cubos::core::data +namespace cubos::core::data::old { void serialize(Serializer& serializer, const engine::VoxelMaterial& mat, const char* name); void deserialize(Deserializer& deserializer, engine::VoxelMaterial& mat); -} // namespace cubos::core::data +} // namespace cubos::core::data::old diff --git a/engine/include/cubos/engine/voxels/palette.hpp b/engine/include/cubos/engine/voxels/palette.hpp index c236f3d19..6ff4b1dee 100644 --- a/engine/include/cubos/engine/voxels/palette.hpp +++ b/engine/include/cubos/engine/voxels/palette.hpp @@ -13,11 +13,11 @@ namespace cubos::engine class VoxelPalette; } -namespace cubos::core::data +namespace cubos::core::data::old { void serialize(Serializer& serializer, const engine::VoxelPalette& palette, const char* name); void deserialize(Deserializer& deserializer, engine::VoxelPalette& palette); -} // namespace cubos::core::data +} // namespace cubos::core::data::old namespace cubos::engine { @@ -84,9 +84,10 @@ namespace cubos::engine void merge(const VoxelPalette& palette, float similarity = 1.0F); private: - friend void core::data::serialize(core::data::Serializer& /*serializer*/, const VoxelPalette& /*palette*/, - const char* /*name*/); - friend void core::data::deserialize(core::data::Deserializer& /*deserializer*/, VoxelPalette& /*palette*/); + friend void core::data::old::serialize(core::data::old::Serializer& /*serializer*/, + const VoxelPalette& /*palette*/, const char* /*name*/); + friend void core::data::old::deserialize(core::data::old::Deserializer& /*deserializer*/, + VoxelPalette& /*palette*/); std::vector mMaterials; ///< Materials in the palette. }; diff --git a/engine/samples/assets/json/main.cpp b/engine/samples/assets/json/main.cpp index f17035324..29ac738b2 100644 --- a/engine/samples/assets/json/main.cpp +++ b/engine/samples/assets/json/main.cpp @@ -6,9 +6,9 @@ #include #include -using cubos::core::data::Deserializer; using cubos::core::data::FileSystem; -using cubos::core::data::Serializer; +using cubos::core::data::old::Deserializer; +using cubos::core::data::old::Serializer; using cubos::core::ecs::Read; using cubos::core::ecs::Write; using cubos::core::memory::Stream; @@ -25,7 +25,7 @@ struct Strings /// [Serialization definition] template <> -void cubos::core::data::serialize(Serializer& ser, const Strings& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const Strings& obj, const char* name) { ser.beginObject(name); ser.write(obj.strings, "strings"); @@ -33,7 +33,7 @@ void cubos::core::data::serialize(Serializer& ser, const Strings& obj, } template <> -void cubos::core::data::deserialize(Deserializer& des, Strings& obj) +void cubos::core::data::old::deserialize(Deserializer& des, Strings& obj) { des.beginObject(); des.read(obj.strings); diff --git a/engine/samples/assets/saving/main.cpp b/engine/samples/assets/saving/main.cpp index ce4c28c97..82bf093e3 100644 --- a/engine/samples/assets/saving/main.cpp +++ b/engine/samples/assets/saving/main.cpp @@ -4,9 +4,9 @@ #include #include -using cubos::core::data::Deserializer; using cubos::core::data::FileSystem; -using cubos::core::data::Serializer; +using cubos::core::data::old::Deserializer; +using cubos::core::data::old::Serializer; using cubos::core::ecs::Read; using cubos::core::ecs::Write; using cubos::core::memory::Stream; @@ -20,7 +20,7 @@ struct IntegerAsset /// [Asset type] template <> -void cubos::core::data::serialize(Serializer& ser, const IntegerAsset& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const IntegerAsset& obj, const char* name) { ser.beginObject(name); ser.write(obj.value, "value"); @@ -28,7 +28,7 @@ void cubos::core::data::serialize(Serializer& ser, const IntegerAs } template <> -void cubos::core::data::deserialize(Deserializer& des, IntegerAsset& obj) +void cubos::core::data::old::deserialize(Deserializer& des, IntegerAsset& obj) { des.beginObject(); des.read(obj.value); diff --git a/engine/samples/input/main.cpp b/engine/samples/input/main.cpp index 45a17105c..5e0a8c321 100644 --- a/engine/samples/input/main.cpp +++ b/engine/samples/input/main.cpp @@ -5,7 +5,7 @@ #include #include -using cubos::core::data::Debug; +using cubos::core::data::old::Debug; using cubos::core::ecs::Read; using cubos::core::ecs::Write; using cubos::core::io::Window; diff --git a/engine/samples/scene/main.cpp b/engine/samples/scene/main.cpp index 5d9f99e24..216a312fc 100644 --- a/engine/samples/scene/main.cpp +++ b/engine/samples/scene/main.cpp @@ -35,9 +35,9 @@ static void spawnScene(Commands commands, Read assets) /// [Displaying the scene] static void printStuff(Read world) { - using cubos::core::data::Context; - using cubos::core::data::DebugSerializer; - using cubos::core::data::SerializationMap; + using cubos::core::data::old::Context; + using cubos::core::data::old::DebugSerializer; + using cubos::core::data::old::SerializationMap; using cubos::core::memory::Stream; for (auto entity : *world) diff --git a/engine/src/cubos/engine/assets/asset.cpp b/engine/src/cubos/engine/assets/asset.cpp index bca23791d..49456eac0 100644 --- a/engine/src/cubos/engine/assets/asset.cpp +++ b/engine/src/cubos/engine/assets/asset.cpp @@ -116,12 +116,12 @@ void AnyAsset::decRef() const } } -void AnyAsset::serialize(core::data::Serializer& ser, const char* name) const +void AnyAsset::serialize(core::data::old::Serializer& ser, const char* name) const { ser.write(uuids::to_string(this->getId()), name); } -void AnyAsset::deserialize(core::data::Deserializer& des) +void AnyAsset::deserialize(core::data::old::Deserializer& des) { std::string str; des.read(str); diff --git a/engine/src/cubos/engine/assets/assets.cpp b/engine/src/cubos/engine/assets/assets.cpp index 6845a2706..35581a989 100644 --- a/engine/src/cubos/engine/assets/assets.cpp +++ b/engine/src/cubos/engine/assets/assets.cpp @@ -74,7 +74,7 @@ void Assets::cleanup() entry.second->status = Status::Unloaded; entry.second->destructor(entry.second->data); entry.second->data = nullptr; - CUBOS_DEBUG("Unloaded asset {}", core::data::Debug(AnyAsset(entry.first))); + CUBOS_DEBUG("Unloaded asset {}", core::data::old::Debug(AnyAsset(entry.first))); } } } @@ -110,7 +110,7 @@ void Assets::loadMeta(std::string_view path) // Deserialize the asset metadata from the JSON string. auto meta = AssetMeta(); - auto des = core::data::JSONDeserializer(contents); + auto des = core::data::old::JSONDeserializer(contents); des.read(meta); if (des.failed()) { @@ -157,7 +157,7 @@ void Assets::loadMeta(std::string_view path) this->invalidate(handle, false); } - CUBOS_DEBUG("Loaded asset {} metadata from '{}'", core::data::Debug(handle), path); + CUBOS_DEBUG("Loaded asset {} metadata from '{}'", core::data::old::Debug(handle), path); } } @@ -186,7 +186,7 @@ AnyAsset Assets::load(AnyAsset handle) const std::unique_lock lock(mLoaderMutex); if (assetEntry->status == Assets::Status::Unloaded && std::this_thread::get_id() != mLoaderThread.get_id()) { - CUBOS_TRACE("Queuing asset {} for loading", core::data::Debug(handle)); + CUBOS_TRACE("Queuing asset {} for loading", core::data::old::Debug(handle)); assetEntry->status = Assets::Status::Loading; mLoaderQueue.push_back(Task{handle, bridge}); mLoaderCond.notify_one(); @@ -206,7 +206,7 @@ bool Assets::saveMeta(const AnyAsset& handle) const auto meta = this->readMeta(handle); if (auto path = meta->get("path")) { - CUBOS_DEBUG("Saving metadata for asset {}", core::data::Debug(handle)); + CUBOS_DEBUG("Saving metadata for asset {}", core::data::old::Debug(handle)); auto file = core::data::FileSystem::create(*path + ".meta"); if (file == nullptr) @@ -222,7 +222,7 @@ bool Assets::saveMeta(const AnyAsset& handle) const return false; } - auto serializer = core::data::JSONSerializer(*stream, 4); + auto serializer = core::data::old::JSONSerializer(*stream, 4); serializer.context().push(AssetMeta::Exclude{{"path"}}); // Don't save the path field. serializer.write(*meta, nullptr); return true; @@ -249,7 +249,7 @@ bool Assets::save(const AnyAsset& handle) const } // Call the bridge's save method. - CUBOS_DEBUG("Saving data for asset {}", core::data::Debug(handle)); + CUBOS_DEBUG("Saving data for asset {}", core::data::old::Debug(handle)); return bridge->save(*this, handle); } @@ -312,7 +312,7 @@ void Assets::invalidate(const AnyAsset& handle, bool shouldLock) assetEntry->status = Status::Unloaded; assetEntry->version++; - CUBOS_DEBUG("Invalidated asset {}", core::data::Debug(handle)); + CUBOS_DEBUG("Invalidated asset {}", core::data::old::Debug(handle)); } } @@ -376,7 +376,7 @@ AnyAsset Assets::store(AnyAsset handle, std::type_index type, void* data, void ( assetEntry->destructor = destructor; assetEntry->cond.notify_all(); - CUBOS_DEBUG("Stored data of type {} for asset {}", type.name(), core::data::Debug(handle)); + CUBOS_DEBUG("Stored data of type {} for asset {}", type.name(), core::data::old::Debug(handle)); // Return a strong handle to the asset. assetEntry->refCount.fetch_add(1); @@ -397,7 +397,7 @@ void* Assets::access(const AnyAsset& handle, std::type_index type, Lock& lock, b // If this is being called from the loader thread, we should load the asset synchronously. if (std::this_thread::get_id() == mLoaderThread.get_id() && assetEntry->status != Status::Loaded) { - CUBOS_DEBUG("Loading asset {} as a dependency", core::data::Debug(handle)); + CUBOS_DEBUG("Loading asset {} as a dependency", core::data::old::Debug(handle)); auto bridge = this->bridge(handle); CUBOS_ASSERT(bridge != nullptr, "Could not access asset"); @@ -408,7 +408,7 @@ void* Assets::access(const AnyAsset& handle, std::type_index type, Lock& lock, b lock.unlock(); if (!bridge->load(const_cast(*this), handle)) { - CUBOS_CRITICAL("Could not load asset {}", core::data::Debug(handle)); + CUBOS_CRITICAL("Could not load asset {}", core::data::old::Debug(handle)); abort(); } lock.lock(); @@ -426,7 +426,7 @@ void* Assets::access(const AnyAsset& handle, std::type_index type, Lock& lock, b if (incVersion) { assetEntry->version++; - CUBOS_DEBUG("Incremented version of asset {}", core::data::Debug(handle)); + CUBOS_DEBUG("Incremented version of asset {}", core::data::old::Debug(handle)); } return assetEntry->data; @@ -478,7 +478,7 @@ std::shared_ptr Assets::entry(const AnyAsset& handle) const auto it = mEntries.find(handle.getId()); if (it == mEntries.end()) { - CUBOS_ERROR("No such asset {}", core::data::Debug(handle)); + CUBOS_ERROR("No such asset {}", core::data::old::Debug(handle)); return nullptr; } @@ -518,11 +518,11 @@ std::shared_ptr Assets::entry(const AnyAsset& handle, bool create auto entry = std::make_shared(); entry->meta.set("id", uuids::to_string(handle.getId())); it = mEntries.emplace(handle.getId(), std::move(entry)).first; - CUBOS_TRACE("Created new asset entry for {}", core::data::Debug(handle)); + CUBOS_TRACE("Created new asset entry for {}", core::data::old::Debug(handle)); } else { - CUBOS_ERROR("No such asset {}", core::data::Debug(handle)); + CUBOS_ERROR("No such asset {}", core::data::old::Debug(handle)); return nullptr; } } @@ -557,7 +557,7 @@ std::shared_ptr Assets::bridge(const AnyAsset& handle) const return best; } - CUBOS_ERROR("Cannot find a bridge for asset {}: asset does not have a path", core::data::Debug(handle)); + CUBOS_ERROR("Cannot find a bridge for asset {}: asset does not have a path", core::data::old::Debug(handle)); return nullptr; } @@ -582,7 +582,7 @@ void Assets::loader() if (!task.bridge->load(*this, task.handle)) { - CUBOS_ERROR("Failed to load asset '{}'", core::data::Debug(task.handle)); + CUBOS_ERROR("Failed to load asset '{}'", core::data::old::Debug(task.handle)); auto assetEntry = this->entry(task.handle); CUBOS_ASSERT(assetEntry != nullptr, "This should never happen"); diff --git a/engine/src/cubos/engine/assets/meta.cpp b/engine/src/cubos/engine/assets/meta.cpp index 4bea4fd70..4436a83d5 100644 --- a/engine/src/cubos/engine/assets/meta.cpp +++ b/engine/src/cubos/engine/assets/meta.cpp @@ -6,7 +6,7 @@ using namespace cubos::engine; template <> -void cubos::core::data::serialize(Serializer& ser, const AssetMeta& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const AssetMeta& obj, const char* name) { // Create a copy of the parameters, so we can remove the excluded ones. std::unordered_map params = obj.params(); @@ -23,7 +23,7 @@ void cubos::core::data::serialize(Serializer& ser, const AssetMeta& o } template <> -void cubos::core::data::deserialize(Deserializer& des, AssetMeta& obj) +void cubos::core::data::old::deserialize(Deserializer& des, AssetMeta& obj) { des.read(obj.params()); } diff --git a/engine/src/cubos/engine/imgui/serialization.cpp b/engine/src/cubos/engine/imgui/serialization.cpp index 396fdda06..4aea0e611 100644 --- a/engine/src/cubos/engine/imgui/serialization.cpp +++ b/engine/src/cubos/engine/imgui/serialization.cpp @@ -6,7 +6,7 @@ using namespace cubos::engine; -using Package = cubos::core::data::Package; +using Package = cubos::core::data::old::Package; // Converts a scalar (must not be an Object, Array or Dictionary) value to a // string. diff --git a/engine/src/cubos/engine/input/bindings.cpp b/engine/src/cubos/engine/input/bindings.cpp index 0f0324c55..a29bbe90a 100644 --- a/engine/src/cubos/engine/input/bindings.cpp +++ b/engine/src/cubos/engine/input/bindings.cpp @@ -32,7 +32,7 @@ std::unordered_map& InputBindings::axes() } template <> -void cubos::core::data::serialize(Serializer& ser, const InputBindings& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const InputBindings& obj, const char* name) { ser.beginObject(name); ser.beginDictionary(obj.actions().size(), "actions"); @@ -60,7 +60,7 @@ void cubos::core::data::serialize(Serializer& ser, const InputBin } template <> -void cubos::core::data::deserialize(Deserializer& des, InputBindings& obj) +void cubos::core::data::old::deserialize(Deserializer& des, InputBindings& obj) { des.beginObject(); @@ -96,14 +96,14 @@ void cubos::core::data::deserialize(Deserializer& des, InputBindi // Overloading these functions allows for human-readable serialization of the keybindings. template <> -void cubos::core::data::serialize(Serializer& ser, const std::pair& obj, - const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const std::pair& obj, + const char* name) { ser.write(modifiersToString(obj.second) + keyToString(obj.first), name); } template <> -void cubos::core::data::deserialize(Deserializer& des, std::pair& obj) +void cubos::core::data::old::deserialize(Deserializer& des, std::pair& obj) { std::string str; des.readString(str); diff --git a/engine/src/cubos/engine/renderer/vertex.cpp b/engine/src/cubos/engine/renderer/vertex.cpp index 9d1628c3f..ee142156f 100644 --- a/engine/src/cubos/engine/renderer/vertex.cpp +++ b/engine/src/cubos/engine/renderer/vertex.cpp @@ -5,7 +5,7 @@ using namespace cubos::engine; -void cubos::core::data::serialize(Serializer& serializer, const VoxelVertex& vertex, const char* name) +void cubos::core::data::old::serialize(Serializer& serializer, const VoxelVertex& vertex, const char* name) { serializer.beginObject(name); serializer.write(vertex.position, "position"); @@ -14,7 +14,7 @@ void cubos::core::data::serialize(Serializer& serializer, const VoxelVertex& ver serializer.endObject(); } -void cubos::core::data::deserialize(Deserializer& deserializer, VoxelVertex& vertex) +void cubos::core::data::old::deserialize(Deserializer& deserializer, VoxelVertex& vertex) { deserializer.beginObject(); deserializer.read(vertex.position); diff --git a/engine/src/cubos/engine/scene/bridge.cpp b/engine/src/cubos/engine/scene/bridge.cpp index 87c0c8d68..7910a79b8 100644 --- a/engine/src/cubos/engine/scene/bridge.cpp +++ b/engine/src/cubos/engine/scene/bridge.cpp @@ -8,7 +8,7 @@ using namespace cubos::engine; using namespace cubos::core; -using cubos::core::data::SerializationMap; +using cubos::core::data::old::SerializationMap; using cubos::core::ecs::Entity; bool SceneBridge::load(Assets& assets, const AnyAsset& handle) @@ -28,7 +28,7 @@ bool SceneBridge::load(Assets& assets, const AnyAsset& handle) stream.reset(); // Close the file. // Deserialize the scene file. - auto deserializer = data::JSONDeserializer(contents); + auto deserializer = data::old::JSONDeserializer(contents); if (deserializer.failed()) { CUBOS_ERROR("Could not parse scene file '{}' as JSON", path); diff --git a/engine/src/cubos/engine/settings/plugin.cpp b/engine/src/cubos/engine/settings/plugin.cpp index 3e637b134..8b78ce17a 100644 --- a/engine/src/cubos/engine/settings/plugin.cpp +++ b/engine/src/cubos/engine/settings/plugin.cpp @@ -6,8 +6,8 @@ using cubos::core::data::File; using cubos::core::data::FileSystem; -using cubos::core::data::JSONDeserializer; using cubos::core::data::StandardArchive; +using cubos::core::data::old::JSONDeserializer; using cubos::core::ecs::Read; using cubos::core::ecs::Write; diff --git a/engine/src/cubos/engine/settings/settings.cpp b/engine/src/cubos/engine/settings/settings.cpp index 9bfc5bea3..02d88b4b7 100644 --- a/engine/src/cubos/engine/settings/settings.cpp +++ b/engine/src/cubos/engine/settings/settings.cpp @@ -6,13 +6,13 @@ using namespace cubos::engine; template <> -void cubos::core::data::serialize(Serializer& ser, const Settings& obj, const char* name) +void cubos::core::data::old::serialize(Serializer& ser, const Settings& obj, const char* name) { ser.write(obj.getValues(), name); } template <> -void cubos::core::data::deserialize(Deserializer& des, Settings& obj) +void cubos::core::data::old::deserialize(Deserializer& des, Settings& obj) { des.read(obj.getValues()); } diff --git a/engine/src/cubos/engine/tools/entity_inspector/plugin.cpp b/engine/src/cubos/engine/tools/entity_inspector/plugin.cpp index b42a490f4..b82adbbcd 100644 --- a/engine/src/cubos/engine/tools/entity_inspector/plugin.cpp +++ b/engine/src/cubos/engine/tools/entity_inspector/plugin.cpp @@ -5,8 +5,8 @@ #include #include -using cubos::core::data::Context; -using cubos::core::data::SerializationMap; +using cubos::core::data::old::Context; +using cubos::core::data::old::SerializationMap; using cubos::core::ecs::Entity; using cubos::core::ecs::World; using cubos::core::ecs::Write; diff --git a/engine/src/cubos/engine/tools/scene_editor/plugin.cpp b/engine/src/cubos/engine/tools/scene_editor/plugin.cpp index 16e9aa758..4731b6329 100644 --- a/engine/src/cubos/engine/tools/scene_editor/plugin.cpp +++ b/engine/src/cubos/engine/tools/scene_editor/plugin.cpp @@ -11,7 +11,7 @@ #include #include -using cubos::core::data::Debug; +using cubos::core::data::old::Debug; using cubos::core::ecs::Commands; using cubos::core::ecs::Entity; diff --git a/engine/src/cubos/engine/voxels/grid.cpp b/engine/src/cubos/engine/voxels/grid.cpp index 02af4b57b..2d9df62e8 100644 --- a/engine/src/cubos/engine/voxels/grid.cpp +++ b/engine/src/cubos/engine/voxels/grid.cpp @@ -143,7 +143,7 @@ bool VoxelGrid::convert(const VoxelPalette& src, const VoxelPalette& dst, float return true; } -void cubos::core::data::serialize(Serializer& serializer, const VoxelGrid& grid, const char* name) +void cubos::core::data::old::serialize(Serializer& serializer, const VoxelGrid& grid, const char* name) { serializer.beginObject(name); serializer.write(grid.mSize, "size"); @@ -151,7 +151,7 @@ void cubos::core::data::serialize(Serializer& serializer, const VoxelGrid& grid, serializer.endObject(); } -void cubos::core::data::deserialize(Deserializer& deserializer, VoxelGrid& grid) +void cubos::core::data::old::deserialize(Deserializer& deserializer, VoxelGrid& grid) { deserializer.beginObject(); deserializer.read(grid.mSize); diff --git a/engine/src/cubos/engine/voxels/material.cpp b/engine/src/cubos/engine/voxels/material.cpp index 56c55bd2c..35a46cb56 100644 --- a/engine/src/cubos/engine/voxels/material.cpp +++ b/engine/src/cubos/engine/voxels/material.cpp @@ -15,7 +15,7 @@ float VoxelMaterial::similarity(const VoxelMaterial& other) const return colorSimilarity(this->color, other.color); } -void cubos::core::data::serialize(Serializer& serializer, const VoxelMaterial& mat, const char* name) +void cubos::core::data::old::serialize(Serializer& serializer, const VoxelMaterial& mat, const char* name) { serializer.beginObject(name); serializer.write(mat.color.r, "r"); @@ -25,7 +25,7 @@ void cubos::core::data::serialize(Serializer& serializer, const VoxelMaterial& m serializer.endObject(); } -void cubos::core::data::deserialize(Deserializer& deserializer, VoxelMaterial& mat) +void cubos::core::data::old::deserialize(Deserializer& deserializer, VoxelMaterial& mat) { deserializer.beginObject(); deserializer.read(mat.color.r); diff --git a/engine/src/cubos/engine/voxels/palette.cpp b/engine/src/cubos/engine/voxels/palette.cpp index 736a213f6..4305cab45 100644 --- a/engine/src/cubos/engine/voxels/palette.cpp +++ b/engine/src/cubos/engine/voxels/palette.cpp @@ -98,7 +98,7 @@ void VoxelPalette::merge(const VoxelPalette& palette, float similarity) } } -void cubos::core::data::serialize(Serializer& serializer, const VoxelPalette& palette, const char* name) +void cubos::core::data::old::serialize(Serializer& serializer, const VoxelPalette& palette, const char* name) { // Count non-empty materials. std::size_t count = 0; @@ -122,7 +122,7 @@ void cubos::core::data::serialize(Serializer& serializer, const VoxelPalette& pa serializer.endDictionary(); } -void cubos::core::data::deserialize(Deserializer& deserializer, VoxelPalette& palette) +void cubos::core::data::old::deserialize(Deserializer& deserializer, VoxelPalette& palette) { palette.mMaterials.clear(); diff --git a/tools/quadrados-gen/src/main.cpp b/tools/quadrados-gen/src/main.cpp index 6c67c0318..fbf3f6416 100644 --- a/tools/quadrados-gen/src/main.cpp +++ b/tools/quadrados-gen/src/main.cpp @@ -822,7 +822,7 @@ static bool generate(const GenerateOptions& options) file << std::endl; file << "template <>" << std::endl; - file << "void cubos::core::data::serialize<" << id << ">(Serializer& ser, const " << id << "& obj," + file << "void cubos::core::data::old::serialize<" << id << ">(Serializer& ser, const " << id << "& obj," << std::endl; file << " const char* name)" << std::endl; file << "{" << std::endl; @@ -849,7 +849,8 @@ static bool generate(const GenerateOptions& options) file << "}" << std::endl; file << std::endl; file << "template <>" << std::endl; - file << "void cubos::core::data::deserialize<" << id << ">(Deserializer& des, " << id << "& obj)" << std::endl; + file << "void cubos::core::data::old::deserialize<" << id << ">(Deserializer& des, " << id << "& obj)" + << std::endl; file << "{" << std::endl; if (component.fields.size() == 1) { diff --git a/tools/quadrados/src/convert.cpp b/tools/quadrados/src/convert.cpp index 417233768..99107f1c3 100644 --- a/tools/quadrados/src/convert.cpp +++ b/tools/quadrados/src/convert.cpp @@ -329,7 +329,7 @@ static bool loadPalette(const fs::path& path, VoxelPalette& palette) } auto stream = memory::StandardStream(file, true); - auto deserializer = data::BinaryDeserializer(stream); + auto deserializer = data::old::BinaryDeserializer(stream); deserializer.read(palette); if (deserializer.failed()) { @@ -367,7 +367,7 @@ static bool savePalette(const fs::path& path, const VoxelPalette& palette) } auto stream = memory::StandardStream(file, true); - auto serializer = data::BinarySerializer(stream); + auto serializer = data::old::BinarySerializer(stream); serializer.write(palette, nullptr); if (serializer.failed()) { @@ -390,7 +390,7 @@ static bool saveGrid(const fs::path& path, const VoxelGrid& grid) } auto stream = memory::StandardStream(file, true); - auto serializer = data::BinarySerializer(stream); + auto serializer = data::old::BinarySerializer(stream); serializer.write(grid, nullptr); if (serializer.failed()) {