00001 // ///////////////////////////////////////////////////////////////////////////// 00002 // 00003 // Name: EntityManager.h 00004 // Author: Michael Bartsch (ZCCdark203) 00005 // 00006 // Desc : Declaration of the EntityManager class. 00007 // 00008 // License: Copyright (C) 2009 Michael Bartsch and Contributors 00009 // 00010 // This program is free software: you can redistribute it 00011 // and/or modify it under the terms of the zlib/libpng License. 00012 // See main.cpp for conditions of distribution and use. 00013 // 00014 // ///////////////////////////////////////////////////////////////////////////// 00015 00016 #ifndef __ENTITYMANAGER_H__ 00017 #define __ENTITYMANAGER_H__ 00018 00019 // Include files 00020 #include "../dependencies.h" 00021 #include "ReferenceCounted.h" 00022 #include "Entity.h" 00023 00024 // Forward declarations 00025 class Entity; 00026 00027 00028 // EntityManager class 00031 class EntityManager : public ReferenceCounted 00032 { 00033 public: 00034 00035 // Initialisation and deinitialisation 00037 EntityManager(); 00039 ~EntityManager(); 00040 00042 void init(); 00044 void clear(); 00045 00046 // Reference counting 00049 void grab(); 00052 void drop(); 00053 00054 // Methods 00058 bool addEntity(Entity *entity); 00064 Entity* createEntity(const std::string &name, Entity *parent = NULL, bool grab = true); 00072 Entity* createEntityFromXML(const std::string &fileName, Entity *parent = NULL, 00073 AssetGroup *assets = NULL, bool grab = true); 00081 Entity* createEntityFromXML(IXMLReader *file, Entity *parent = NULL, AssetGroup *assets = NULL, 00082 bool grab = true); 00083 00086 Entity* getEntity(const u32 id); 00089 Entity* getEntity(const std::string &name); 00090 00092 void removeEntities(); 00096 bool removeEntity(Entity *entity); 00100 bool removeEntity(const u32 id); 00104 bool removeEntity(const std::string &name); 00105 00106 private: 00107 00108 // Private members 00109 vector<Entity*> mEntities; 00110 }; 00111 00112 #endif