PageRenderTime 27ms CodeModel.GetById 12ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/TGame/TCommon/Entity/EntityManager.h

http://awoe.googlecode.com/
C++ Header | 61 lines | 26 code | 10 blank | 25 comment | 0 complexity | 5d97bc0890679ad242d131b5e2280dcd MD5 | raw file
 1#ifndef		__ENTITY_MANAGER_BASE_
 2#define		__ENTITY_MANAGER_BASE_
 3
 4
 5#include "EntityManagerIf.h"
 6
 7//
 8//	Entity Manager
 9//	
10//
11class TCOM_API  EntityManager : public IEntityManager
12{
13public:
14	EntityManager(bool bLoad = true);
15	virtual	~EntityManager()	{}
16
17	virtual IEntity*	getEntity(int nID);
18
19	//
20	//	add/remove entities
21	//
22	//	add/remove entities
23	//
24	virtual bool	addEntity(int nID, IEntity*  e);
25	virtual bool	addEntity(int nID, IEntityBuilder* b);
26	virtual bool	rmvEntity(int nID, IEntity*& e);
27
28	//
29	//	visit all entities in current manager
30	//
31	virtual void	forEach(IEntityVisitor& v);
32public:
33	//
34	//	for gene host
35	//
36	//	add/remove gene to gene host
37	//	Note that gene is organized by group id in gene
38	//
39	virtual bool addGene(IGeneCreateData* pDynamicData);
40	virtual	bool addGene(IGene*);
41	virtual bool rmvGene(int nGrpID);
42
43	//
44	//	register/unregister an gene event to gene host
45	//	gene host will broadcast gene event only to those who has already registered it
46	//
47	virtual bool	addRegEvt(int nEvtGrp, int nEvt, IGene* pGene);
48	virtual bool	rmvRegEvt(int nEvtGrp, int nEvt, IGene* pGene);
49
50	//
51	//	fire an gene event to all registered gene on current host
52	//	
53	virtual bool onEvent(IEvt& evt);
54private:
55	bool	m_bLoad;// load entity when adding
56
57	typedef stdext::hash_map<int, IEntity*>	EntityMap;
58	EntityMap				m_theEntities;
59};
60
61#endif