#pragma once #include #include #include namespace yage { /** * The component mask represents all the components that the entity is * currently attached to. */ typedef std::bitset<64> ComponentMask; typedef unsigned int GroupId; class BaseComponent { protected: virtual GroupId getGroup() = 0; static GroupId group_id_counter_; private: friend class EntityManager; }; template class Component : public BaseComponent { private: GroupId getGroup() override; }; class ComponentGroup { public: typedef std::vector> Container; ComponentGroup &add(std::unique_ptr &&component); Container::iterator begin(); Container::iterator end(); private: Container components_; }; template GroupId Component::getGroup() { static GroupId group_id = group_id_counter_++; return group_id; } } // namespace yage