1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #include "utils/HashMap.h"
- #include "utils/List.h"
- #include "utils/Types.h"
- typedef uint32 Entity;
- template<typename T>
- class Components final {
- HashMap<Entity, T> components;
- public:
- Components() {
- }
- template<typename... Args>
- void add(Entity e, Args&&... args) {
- components.tryEmplace(e, std::forward<Args>(args)...);
- }
- void remove(Entity e) {
- components.remove(e);
- }
- T* search(Entity e) {
- return components.search(e);
- }
- const T* search(Entity e) const {
- return components.search(e);
- }
- auto begin() {
- return components.begin();
- }
- const auto begin() const {
- return components.begin();
- }
- auto end() {
- return components.end();
- }
- const auto end() const {
- return components.end();
- }
- };
|