-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented JsonSerializer entity serialization
Also fixed Serializer updateEntity and introduced new before/afterUpdate/SaveEntity virtual methods Linked: #164
- Loading branch information
1 parent
be7e08a
commit 3a3645a
Showing
7 changed files
with
292 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,16 @@ namespace ecstasy::serialization | |
{ | ||
} | ||
|
||
/// | ||
/// @brief Construct a new Component Rtti with a custom name. | ||
/// | ||
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2024-10-04) | ||
/// | ||
EntityComponentSerializer(std::string_view name) : IEntityComponentSerializer(), _name(name) | ||
{ | ||
} | ||
|
||
/// | ||
/// @brief Destroy the Component Rtti | ||
/// | ||
|
@@ -72,11 +82,29 @@ namespace ecstasy::serialization | |
.template update<Component>(dynamic_cast<StorageType &>(storage).at(entity.getIndex())); | ||
} | ||
|
||
/// @copydoc IEntityComponentSerializer::getStorageTypeIndex | ||
std::type_index getStorageTypeIndex() const override final | ||
/// @copydoc IEntityComponentSerializer::getStorageTypeInfo | ||
const std::type_info &getStorageTypeInfo() const override final | ||
{ | ||
return std::type_index(typeid(StorageType)); | ||
return typeid(StorageType); | ||
} | ||
|
||
/// @copydoc IEntityComponentSerializer::getComponentTypeInfo | ||
const std::type_info &getComponentTypeInfo() const override final | ||
{ | ||
return typeid(Component); | ||
} | ||
|
||
/// @copydoc IEntityComponentSerializer::getTypeName | ||
std::string_view getTypeName() const override final | ||
{ | ||
if (_name.empty()) | ||
return typeid(Component).name(); | ||
return _name; | ||
} | ||
|
||
private: | ||
/// Name of the component type. | ||
std::string_view _name; | ||
}; | ||
|
||
} // namespace ecstasy::serialization | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,14 +74,36 @@ namespace ecstasy | |
virtual ISerializer &load(ISerializer &serializer, IStorage &storage, RegistryEntity &entity) const = 0; | ||
|
||
/// | ||
/// @brief Get the Storage Type Index of the component. | ||
/// @brief Get the type info of the component storage. | ||
/// | ||
/// @return std::type_index Type index of the storage. | ||
/// @return const std::type_info& Type info of the component storage. | ||
/// | ||
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2024-10-04) | ||
/// | ||
virtual std::type_index getStorageTypeIndex() const = 0; | ||
virtual const std::type_info &getStorageTypeInfo() const = 0; | ||
|
||
/// | ||
/// @brief Get the type info of the component. | ||
/// | ||
/// @return const std::type_info& Type info of the component. | ||
/// | ||
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2024-10-11) | ||
/// | ||
virtual const std::type_info &getComponentTypeInfo() const = 0; | ||
|
||
//// | ||
/// @brief Get the Component Type Name | ||
/// | ||
/// @note Return the explicit name of the component if any and fallback on the type name. | ||
/// | ||
/// @return std::string_view Name of the component type. | ||
/// | ||
/// @author Andréas Leroux ([email protected]) | ||
/// @since 1.0.0 (2024-10-11) | ||
/// | ||
virtual std::string_view getTypeName() const = 0; | ||
}; | ||
|
||
} // namespace serialization | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.