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); 00066 Entity* createEntity(const std::string &name, Entity *parent = NULL, AssetGroup* assets = 0, bool grab = true); 00074 Entity* createEntityFromXML(const std::string &fileName, Entity *parent = NULL, 00075 AssetGroup *assets = NULL, bool grab = true); 00083 Entity* createEntityFromXML(IXMLReader *file, Entity *parent = NULL, AssetGroup *assets = NULL, 00084 bool grab = true); 00085 00088 Entity* getEntity(const u32 id); 00091 Entity* getEntity(const std::string &name); 00092 00094 void removeEntities(); 00098 bool removeEntity(Entity *entity); 00102 bool removeEntity(const u32 id); 00106 bool removeEntity(const std::string &name); 00107 00108 private: 00109 00110 // Private members 00111 vector<Entity*> mEntities; 00112 }; 00113 00114 #endif
1.5.8