<commit_before>#include "serializer.hpp"

#include "../asset/asset_manager.hpp"
#include "ecs.hpp"
#include "../utils/template_utils.hpp"
#include "serializer_impl.hpp"

#include <unordered_map>
#include <vector>
#include <sf2/sf2.hpp>
#include <iostream>


namespace mo {
namespace ecs {
	using namespace asset;
	using namespace sf2;
	using namespace sf2::io;

	class Blueprint : public std::enable_shared_from_this<const Blueprint> {
		public:
			struct Data;

			Blueprint(asset::Asset_manager& assets, AID name, Data&& data);
			~Blueprint()noexcept;
			Blueprint& operator=(Blueprint&&);

			void apply(Entity_ptr target)const;
			void detach(Entity_ptr target)const;


			const AID name;

		private:
			asset::Asset_manager& _assets;
			struct PImpl;
			std::unique_ptr<PImpl> _impl;

			Blueprint(const Blueprint&) = delete;
			Blueprint(Blueprint&& s) = delete;
			Blueprint& operator=(const Blueprint&) = delete;
	};

	/// connects a entity to its assigned blueprint
	class BlueprintComponent : public ecs::Component<BlueprintComponent> {
		public:
			static constexpr const char* name() {return "Blueprint";}

			void load(ecs::Entity_state& state)override {
				std::string blueprintName;
				sf2::details::fundamentals::_parseMember(state.char_source(), blueprintName);

				blueprintId = AID{Asset_type::blueprint, blueprintName};
				blueprint = state.asset_mgr().load<Blueprint>(blueprintId);
			};
			void store(ecs::Entity_state& state)override {
				sf2::details::fundamentals::_writeMember(state.char_sink(), blueprintId.name());
			}

			BlueprintComponent(ecs::Entity& owner, std::shared_ptr<const Blueprint> blueprint=std::shared_ptr<const Blueprint>())noexcept
			  : Component(owner), blueprint(blueprint), blueprintId(blueprint ? blueprint->name : AID{Asset_type::blueprint, ""}) {}
			~BlueprintComponent()noexcept {
				if(blueprint) {
					blueprint->detach(owner_ptr());
					blueprint.reset();
				}
			}

			BlueprintComponent& operator=(BlueprintComponent&& o) noexcept {
				ecs::Component<BlueprintComponent>::operator=(static_cast<Component&&>(o));

				blueprint = std::move(o.blueprint); // deatch/attach not required, Comp-move accors entities is undefined
				blueprintId = std::move(blueprintId);
				return *this;
			}<commit_msg>fixed Déjà-vu<commit_after>#include "serializer.hpp"

#include "../asset/asset_manager.hpp"
#include "ecs.hpp"
#include "../utils/template_utils.hpp"
#include "serializer_impl.hpp"

#include <unordered_map>
#include <vector>
#include <sf2/sf2.hpp>
#include <iostream>


namespace mo {
namespace ecs {
	using namespace asset;
	using namespace sf2;
	using namespace sf2::io;

	class Blueprint : public std::enable_shared_from_this<const Blueprint> {
		public:
			struct Data;

			Blueprint(asset::Asset_manager& assets, AID name, Data&& data);
			~Blueprint()noexcept;
			Blueprint& operator=(Blueprint&&);

			void apply(Entity_ptr target)const;
			void detach(Entity_ptr target)const;


			const AID name;

		private:
			asset::Asset_manager& _assets;
			struct PImpl;
			std::unique_ptr<PImpl> _impl;

			Blueprint(const Blueprint&) = delete;
			Blueprint(Blueprint&& s) = delete;
			Blueprint& operator=(const Blueprint&) = delete;
	};

	/// connects a entity to its assigned blueprint
	class BlueprintComponent : public ecs::Component<BlueprintComponent> {
		public:
			static constexpr const char* name() {return "Blueprint";}

			void load(ecs::Entity_state& state)override {
				std::string blueprintName;
				sf2::details::fundamentals::_parseMember(state.char_source(), blueprintName);

				blueprintId = AID{Asset_type::blueprint, blueprintName};
				blueprint = state.asset_mgr().load<Blueprint>(blueprintId);
			};
			void store(ecs::Entity_state& state)override {
				sf2::details::fundamentals::_writeMember(state.char_sink(), blueprintId.name());
			}

			BlueprintComponent(ecs::Entity& owner, std::shared_ptr<const Blueprint> blueprint=std::shared_ptr<const Blueprint>())noexcept
			  : Component(owner), blueprint(blueprint), blueprintId(blueprint ? blueprint->name : AID{Asset_type::blueprint, ""}) {}
			~BlueprintComponent()noexcept {
				if(blueprint) {
					blueprint->detach(owner_ptr());
					blueprint.reset();
				}
			}

			BlueprintComponent& operator=(BlueprintComponent&& o) noexcept {
				ecs::Component<BlueprintComponent>::operator=(static_cast<Component&&>(o));

				blueprint = std::move(o.blueprint); // deatch/attach not required, Comp-move accors entities is undefined
				blueprintId = std::move(o.blueprintId);
				return *this;
			}
{'fraction_non_alphanumeric': 0.13424295774647887, 'fraction_numerical': 0.002640845070422535, 'mean_word_length': 5.226027397260274, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2732672', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1432, 'n_words': 289}