diff options
| author | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
|---|---|---|
| committer | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
| commit | 26b5e033ffde3d161382fc9addbfa99738379641 (patch) | |
| tree | a344f369ca32945f787a02dee35c3dbe342bed7e /src/framework/GameSystem | |
| parent | f21f47005dcb6b76e1abc9f35fbcd03eed191bff (diff) | |
*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget
--HG--
branch : trunk
Diffstat (limited to 'src/framework/GameSystem')
| -rw-r--r-- | src/framework/GameSystem/Grid.h | 22 | ||||
| -rw-r--r-- | src/framework/GameSystem/GridLoader.h | 6 | ||||
| -rw-r--r-- | src/framework/GameSystem/GridRefManager.h | 6 | ||||
| -rw-r--r-- | src/framework/GameSystem/GridReference.h | 4 | ||||
| -rw-r--r-- | src/framework/GameSystem/NGrid.h | 26 | ||||
| -rw-r--r-- | src/framework/GameSystem/TypeContainer.h | 18 | ||||
| -rw-r--r-- | src/framework/GameSystem/TypeContainerFunctions.h | 26 | ||||
| -rw-r--r-- | src/framework/GameSystem/TypeContainerVisitor.h | 19 |
8 files changed, 0 insertions, 127 deletions
diff --git a/src/framework/GameSystem/Grid.h b/src/framework/GameSystem/Grid.h index cebaebc68c6..04f0735ce87 100644 --- a/src/framework/GameSystem/Grid.h +++ b/src/framework/GameSystem/Grid.h @@ -17,10 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #ifndef TRINITY_GRID_H #define TRINITY_GRID_H - /* @class Grid Grid is a logical segment of the game world represented inside TrinIty. @@ -31,15 +29,12 @@ this is implementation specific to the loader class. From the Grid's perspective, the loader meets its API requirement is suffice. */ - #include "Platform/Define.h" #include "Policies/ThreadingModel.h" #include "TypeContainer.h" #include "TypeContainerVisitor.h" - // forward declaration template<class A, class T, class O> class GridLoader; - template < class ACTIVE_OBJECT, @@ -52,12 +47,10 @@ class TRINITY_DLL_DECL Grid // allows the GridLoader to access its internals template<class A, class T, class O> friend class GridLoader; public: - /** destructor to clean up its resources. This includes unloading the grid if it has not been unload. */ ~Grid() {} - /** an object of interested enters the grid */ template<class SPECIFIC_OBJECT> void AddWorldObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) @@ -65,7 +58,6 @@ class TRINITY_DLL_DECL Grid if(!i_objects.template insert<SPECIFIC_OBJECT>(hdl, obj)) assert(false); } - /** an object of interested exits the grid */ template<class SPECIFIC_OBJECT> void RemoveWorldObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) @@ -73,47 +65,38 @@ class TRINITY_DLL_DECL Grid if(!i_objects.template remove<SPECIFIC_OBJECT>(obj, hdl)) assert(false); } - /** Accessors: Returns a specific type of object in the WORDL_OBJECT_TYPES */ template<class SPECIFIC_OBJECT> const SPECIFIC_OBJECT* GetWorldObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT* fake) const { return i_objects.template find<SPECIFIC_OBJECT>(hdl); } template<class SPECIFIC_OBJECT> SPECIFIC_OBJECT* GetWorldObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT *fake) { return i_objects.template find<SPECIFIC_OBJECT>(hdl, fake); } - /** Refreshes/update the grid. This required for remote grids. */ void RefreshGrid(void) { /* TBI */} - /** Locks a grid. Any object enters must wait until the grid is unlock. */ void LockGrid(void) { /* TBI */ } - /** Unlocks the grid. */ void UnlockGrid(void) { /* TBI */ } - /** Grid visitor for grid objects */ template<class T> void Visit(TypeContainerVisitor<T, TypeMapContainer<GRID_OBJECT_TYPES> > &visitor) { visitor.Visit(i_container); } - /** Grid visitor for world objects */ template<class T> void Visit(TypeContainerVisitor<T, TypeMapContainer<WORLD_OBJECT_TYPES> > &visitor) { visitor.Visit(i_objects); } - /** Returns the number of object within the grid. */ unsigned int ActiveObjectsInGrid(void) const { return /*m_activeGridObjects.size()+*/i_objects.template Count<ACTIVE_OBJECT>(); } - /** Accessors: Returns a specific type of object in the GRID_OBJECT_TYPES */ template<class SPECIFIC_OBJECT> const SPECIFIC_OBJECT* GetGridObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT *fake) const { return i_container.template find<SPECIFIC_OBJECT>(hdl, fake); } template<class SPECIFIC_OBJECT> SPECIFIC_OBJECT* GetGridObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT *fake) { return i_container.template find<SPECIFIC_OBJECT>(hdl, fake); } - /** Inserts a container type object into the grid. */ template<class SPECIFIC_OBJECT> void AddGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) @@ -121,7 +104,6 @@ class TRINITY_DLL_DECL Grid if(!i_container.template insert<SPECIFIC_OBJECT>(hdl, obj)) assert(false); } - /** Removes a containter type object from the grid */ template<class SPECIFIC_OBJECT> void RemoveGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) @@ -129,21 +111,17 @@ class TRINITY_DLL_DECL Grid if(!i_container.template remove<SPECIFIC_OBJECT>(obj, hdl)) assert(false); } - /*bool NoWorldObjectInGrid() const { return i_objects.GetElements().isEmpty(); } - bool NoGridObjectInGrid() const { return i_container.GetElements().isEmpty(); }*/ private: - typedef typename ThreadModel::Lock Guard; typedef typename ThreadModel::VolatileType VolatileType; - TypeMapContainer<GRID_OBJECT_TYPES> i_container; TypeMapContainer<WORLD_OBJECT_TYPES> i_objects; //typedef std::set<void*> ActiveGridObjects; diff --git a/src/framework/GameSystem/GridLoader.h b/src/framework/GameSystem/GridLoader.h index 8a483044f8f..c5eb1155e48 100644 --- a/src/framework/GameSystem/GridLoader.h +++ b/src/framework/GameSystem/GridLoader.h @@ -17,10 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #ifndef TRINITY_GRIDLOADER_H #define TRINITY_GRIDLOADER_H - /** @class GridLoader The GridLoader is working in conjuction with the Grid and responsible @@ -31,11 +29,9 @@ delicate its loading and unloading for the actualy loader and unloader. GridLoader manages the grid (both local and remote). */ - #include "Platform/Define.h" #include "Grid.h" #include "TypeContainerVisitor.h" - template < class ACTIVE_OBJECT, @@ -45,7 +41,6 @@ class GRID_OBJECT_TYPES class TRINITY_DLL_DECL GridLoader { public: - /** Loads the grid */ template<class LOADER> @@ -55,7 +50,6 @@ class TRINITY_DLL_DECL GridLoader loader.Load(grid); grid.UnlockGrid(); } - /** Stop the grid */ template<class STOPER> diff --git a/src/framework/GameSystem/GridRefManager.h b/src/framework/GameSystem/GridRefManager.h index bd32f836e18..3d97135f867 100644 --- a/src/framework/GameSystem/GridRefManager.h +++ b/src/framework/GameSystem/GridRefManager.h @@ -17,24 +17,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #ifndef _GRIDREFMANAGER #define _GRIDREFMANAGER - #include "Utilities/LinkedReference/RefManager.h" - template<class OBJECT> class GridReference; - template<class OBJECT> class GridRefManager : public RefManager<GridRefManager<OBJECT>, OBJECT> { public: typedef LinkedListHead::Iterator< GridReference<OBJECT> > iterator; - GridReference<OBJECT>* getFirst() { return (GridReference<OBJECT>*)RefManager<GridRefManager<OBJECT>, OBJECT>::getFirst(); } GridReference<OBJECT>* getLast() { return (GridReference<OBJECT>*)RefManager<GridRefManager<OBJECT>, OBJECT>::getLast(); } - iterator begin() { return iterator(getFirst()); } iterator end() { return iterator(NULL); } iterator rbegin() { return iterator(getLast()); } diff --git a/src/framework/GameSystem/GridReference.h b/src/framework/GameSystem/GridReference.h index d4bd6752515..e6bd5da1237 100644 --- a/src/framework/GameSystem/GridReference.h +++ b/src/framework/GameSystem/GridReference.h @@ -17,15 +17,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #ifndef _GRIDREFERENCE_H #define _GRIDREFERENCE_H - #include "Utilities/LinkedReference/Reference.h" - template<class OBJECT> class GridRefManager; - template<class OBJECT> class TRINITY_DLL_SPEC GridReference : public Reference<GridRefManager<OBJECT>, OBJECT> { diff --git a/src/framework/GameSystem/NGrid.h b/src/framework/GameSystem/NGrid.h index 6ba5d10ffc1..f6dac7db955 100644 --- a/src/framework/GameSystem/NGrid.h +++ b/src/framework/GameSystem/NGrid.h @@ -17,17 +17,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #ifndef TRINITY_NGRID_H #define TRINITY_NGRID_H - /** NGrid is nothing more than a wrapper of the Grid with an NxN cells */ - #include "GameSystem/Grid.h" #include "GameSystem/GridReference.h" #include "Timer.h" - class GridInfo { public: @@ -41,18 +37,15 @@ public: void setUnloadReferenceLock( bool on ) { i_unloadReferenceLock = on; } void incUnloadActiveLock() { ++i_unloadActiveLockCount; } void decUnloadActiveLock() { if(i_unloadActiveLockCount) --i_unloadActiveLockCount; } - void setTimer(const TimeTracker& pTimer) { i_timer = pTimer; } void ResetTimeTracker(time_t interval) { i_timer.Reset(interval); } void UpdateTimeTracker(time_t diff) { i_timer.Update(diff); } - private: TimeTracker i_timer; uint16 i_unloadActiveLockCount : 16; // lock from active object spawn points (prevent clone loading) bool i_unloadExplicitLock : 1; // explicit manual lock or config setting bool i_unloadReferenceLock : 1; // lock from instance map copy }; - typedef enum { GRID_STATE_INVALID = 0, @@ -61,7 +54,6 @@ typedef enum GRID_STATE_REMOVAL= 3, MAX_GRID_STATE = 4 } grid_state_t; - template < unsigned int N, @@ -73,42 +65,36 @@ class ThreadModel = Trinity::SingleThreaded<ACTIVE_OBJECT> class TRINITY_DLL_DECL NGrid { public: - typedef Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES, ThreadModel> GridType; NGrid(uint32 id, int32 x, int32 y, time_t expiry, bool unload = true) : i_gridId(id), i_x(x), i_y(y), i_cellstate(GRID_STATE_INVALID), i_GridObjectDataLoaded(false) { i_GridInfo = GridInfo(expiry, unload); } - const GridType& operator()(unsigned short x, unsigned short y) const { ASSERT(x < N); ASSERT(y < N); return i_cells[x][y]; } - GridType& operator()(unsigned short x, unsigned short y) { ASSERT(x < N); ASSERT(y < N); return i_cells[x][y]; } - const uint32& GetGridId(void) const { return i_gridId; } void SetGridId(const uint32 id) const { i_gridId = id; } grid_state_t GetGridState(void) const { return i_cellstate; } void SetGridState(grid_state_t s) { i_cellstate = s; } int32 getX() const { return i_x; } int32 getY() const { return i_y; } - void link(GridRefManager<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES, ThreadModel> >* pTo) { i_Reference.link(pTo, this); } bool isGridObjectDataLoaded() const { return i_GridObjectDataLoaded; } void setGridObjectDataLoaded(bool pLoaded) { i_GridObjectDataLoaded = pLoaded; } - GridInfo* getGridInfoRef() { return &i_GridInfo; } const TimeTracker& getTimeTracker() const { return i_GridInfo.getTimeTracker(); } bool getUnloadLock() const { return i_GridInfo.getUnloadLock(); } @@ -118,29 +104,24 @@ class TRINITY_DLL_DECL NGrid void decUnloadActiveLock() { i_GridInfo.decUnloadActiveLock(); } void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); } void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); } - template<class SPECIFIC_OBJECT> void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { getGridType(x, y).AddWorldObject(obj, hdl); } - template<class SPECIFIC_OBJECT> void RemoveWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { getGridType(x, y).RemoveWorldObject(obj, hdl); } - template<class T, class TT> void Visit(TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor) { for(unsigned int x=0; x < N; ++x) for(unsigned int y=0; y < N; ++y) getGridType(x, y).Visit(visitor); } - template<class T, class TT> void Visit(const uint32 &x, const uint32 &y, TypeContainerVisitor<T, TypeMapContainer<TT> > &visitor) { getGridType(x, y).Visit(visitor); } - unsigned int ActiveObjectsInGrid(void) const { unsigned int count=0; @@ -149,36 +130,29 @@ class TRINITY_DLL_DECL NGrid count += i_cells[x][y].ActiveObjectsInGrid(); return count; } - template<class SPECIFIC_OBJECT> const SPECIFIC_OBJECT* GetGridObject(const uint32 x, const uint32 y, OBJECT_HANDLE hdl) const { return getGridType(x, y).template GetGridObject<SPECIFIC_OBJECT>(hdl); } - template<class SPECIFIC_OBJECT> SPECIFIC_OBJECT* GetGridObject(const uint32 x, const uint32 y, OBJECT_HANDLE hdl) { return getGridType(x, y).template GetGridObject<SPECIFIC_OBJECT>(hdl); } - template<class SPECIFIC_OBJECT> bool AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { return getGridType(x, y).AddGridObject(hdl, obj); } - template<class SPECIFIC_OBJECT> bool RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) { return getGridType(x, y).RemoveGridObject(obj, hdl); } - private: - GridType& getGridType(const uint32& x, const uint32& y) { ASSERT(x < N); ASSERT(y < N); return i_cells[x][y]; } - uint32 i_gridId; GridInfo i_GridInfo; GridReference<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES, ThreadModel> > i_Reference; diff --git a/src/framework/GameSystem/TypeContainer.h b/src/framework/GameSystem/TypeContainer.h index 9e4c6da65e2..9d32d398527 100644 --- a/src/framework/GameSystem/TypeContainer.h +++ b/src/framework/GameSystem/TypeContainer.h @@ -17,21 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #ifndef TRINITY_TYPECONTAINER_H #define TRINITY_TYPECONTAINER_H - /* * Here, you'll find a series of containers that allow you to hold multiple * types of object at the same time. */ - #include <map> #include <vector> #include "Platform/Define.h" #include "Utilities/TypeList.h" #include "GameSystem/GridRefManager.h" - /* * @class ContainerMapList is a mulit-type container for map elements * By itself its meaningless but collaborate along with TypeContainers, @@ -42,7 +38,6 @@ template<class OBJECT> struct ContainerMapList //std::map<OBJECT_HANDLE, OBJECT *> _element; GridRefManager<OBJECT> _element; }; - template<> struct ContainerMapList<TypeNull> /* nothing is in type null */ { }; @@ -51,7 +46,6 @@ template<class H, class T> struct ContainerMapList<TypeList<H, T> > ContainerMapList<H> _elements; ContainerMapList<T> _TailElements; }; - /* * @class ContaierArrayList is a multi-type container for * array of elements. @@ -60,7 +54,6 @@ template<class OBJECT> struct ContainerArrayList { std::vector<OBJECT> _element; }; - // termination condition template<> struct ContainerArrayList<TypeNull> {}; // recursion @@ -69,7 +62,6 @@ template<class H, class T> struct ContainerArrayList<TypeList<H, T> > ContainerArrayList<H> _elements; ContainerArrayList<T> _TailElements; }; - /* * @class ContainerList is a simple list of different types of elements * @@ -78,7 +70,6 @@ template<class OBJECT> struct ContainerList { OBJECT _element; }; - /* TypeNull is underfined */ template<> struct ContainerList<TypeNull> {}; template<class H, class T> struct ContainerList<TypeList<H, T> > @@ -86,44 +77,35 @@ template<class H, class T> struct ContainerList<TypeList<H, T> > ContainerList<H> _elements; ContainerMapList<T> _TailElements; }; - #include "TypeContainerFunctions.h" - /* * @class TypeMapContainer contains a fixed number of types and is * determined at compile time. This is probably the most complicated * class and do its simplest thing, that is, holds objects * of different types. */ - template<class OBJECT_TYPES> class TRINITY_DLL_DECL TypeMapContainer { public: template<class SPECIFIC_TYPE> size_t Count() const { return Trinity::Count(i_elements, (SPECIFIC_TYPE*)NULL); } - template<class SPECIFIC_TYPE> SPECIFIC_TYPE* find(OBJECT_HANDLE hdl, SPECIFIC_TYPE *fake) { return Trinity::Find(i_elements, hdl,fake); } - /// find a specific type of object in the container template<class SPECIFIC_TYPE> const SPECIFIC_TYPE* find(OBJECT_HANDLE hdl, SPECIFIC_TYPE *fake) const { return Trinity::Find(i_elements, hdl,fake); } - /// inserts a specific object into the container template<class SPECIFIC_TYPE> bool insert(OBJECT_HANDLE hdl, SPECIFIC_TYPE *obj) { SPECIFIC_TYPE* t = Trinity::Insert(i_elements, obj, hdl); return (t != NULL); } - /// Removes the object from the container, and returns the removed object template<class SPECIFIC_TYPE> bool remove(SPECIFIC_TYPE* obj, OBJECT_HANDLE hdl) { SPECIFIC_TYPE* t = Trinity::Remove(i_elements, obj, hdl); return (t != NULL); } - ContainerMapList<OBJECT_TYPES> & GetElements(void) { return i_elements; } const ContainerMapList<OBJECT_TYPES> & GetElements(void) const { return i_elements;} - private: ContainerMapList<OBJECT_TYPES> i_elements; }; diff --git a/src/framework/GameSystem/TypeContainerFunctions.h b/src/framework/GameSystem/TypeContainerFunctions.h index f9945f84ac7..618c2584961 100644 --- a/src/framework/GameSystem/TypeContainerFunctions.h +++ b/src/framework/GameSystem/TypeContainerFunctions.h @@ -17,20 +17,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #ifndef TYPECONTAINER_FUNCTIONS_H #define TYPECONTAINER_FUNCTIONS_H - /* * Here you'll find a list of helper functions to make * the TypeContainer usefull. Without it, its hard * to access or mutate the container. */ - #include "Platform/Define.h" #include "Utilities/TypeList.h" #include <map> - namespace Trinity { /* ContainerMapList Helpers */ @@ -39,27 +35,22 @@ namespace Trinity { return elements._element.getSize(); }; - template<class SPECIFIC_TYPE> size_t Count(const ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE* /*fake*/) { return 0; } - template<class SPECIFIC_TYPE, class T> size_t Count(const ContainerMapList<T> &/*elements*/, SPECIFIC_TYPE* /*fake*/) { return 0; } - template<class SPECIFIC_TYPE, class T> size_t Count(const ContainerMapList<TypeList<SPECIFIC_TYPE, T> >&elements, SPECIFIC_TYPE* fake) { return Count(elements._elements,fake); } - template<class SPECIFIC_TYPE, class H, class T> size_t Count(const ContainerMapList<TypeList<H, T> >&elements, SPECIFIC_TYPE* fake) { return Count(elements._TailElements, fake); } - // non-const find functions template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Find(ContainerMapList<SPECIFIC_TYPE> &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) { @@ -67,24 +58,20 @@ namespace Trinity //return (iter == elements._element.end() ? NULL : iter->second); return NULL; }; - template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Find(ContainerMapList<TypeNull> &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) { return NULL; // terminate recursion } - template<class SPECIFIC_TYPE, class T> SPECIFIC_TYPE* Find(ContainerMapList<T> &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) { return NULL; // this is a missed } - template<class SPECIFIC_TYPE, class H, class T> SPECIFIC_TYPE* Find(ContainerMapList<TypeList<H, T> >&/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) { //SPECIFIC_TYPE* t = Find(elements._elements, hdl,fake); //return (t != NULL ? t :Find(elements._TailElements, hdl,fake)); return NULL; } - // const find functions template<class SPECIFIC_TYPE> const SPECIFIC_TYPE* Find(const ContainerMapList<SPECIFIC_TYPE> &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) { @@ -92,26 +79,21 @@ namespace Trinity //return (iter == elements._element.end() ? NULL : iter->second); return NULL; }; - template<class SPECIFIC_TYPE> const SPECIFIC_TYPE* Find(const ContainerMapList<TypeNull> &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) { return NULL; } - template<class SPECIFIC_TYPE, class T> const SPECIFIC_TYPE* Find(const ContainerMapList<T> &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) { return NULL; } - template<class SPECIFIC_TYPE, class H, class T> SPECIFIC_TYPE* Find(const ContainerMapList<TypeList<H, T> >&elements, OBJECT_HANDLE hdl, SPECIFIC_TYPE* fake) { SPECIFIC_TYPE* t = Find(elements._elements, hdl,fake); if( t) return t; - return Find(elements._TailElement, hdl,fake); } - // non-const insert functions template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Insert(ContainerMapList<SPECIFIC_TYPE> &elements, SPECIFIC_TYPE *obj, OBJECT_HANDLE /*hdl*/) { @@ -119,25 +101,21 @@ namespace Trinity obj->GetGridRef().link(&elements._element, obj); return obj; }; - template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Insert(ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/) { return NULL; } - // this is a missed template<class SPECIFIC_TYPE, class T> SPECIFIC_TYPE* Insert(ContainerMapList<T> &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/) { return NULL; // a missed } - // Recursion template<class SPECIFIC_TYPE, class H, class T> SPECIFIC_TYPE* Insert(ContainerMapList<TypeList<H, T> >&elements, SPECIFIC_TYPE *obj, OBJECT_HANDLE hdl) { SPECIFIC_TYPE* t= Insert(elements._elements, obj, hdl); return (t != NULL ? t : Insert(elements._TailElements, obj, hdl)); } - // non-const remove method template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<SPECIFIC_TYPE> & /*elements*/, SPECIFIC_TYPE *obj, OBJECT_HANDLE /*hdl*/) { @@ -151,25 +129,21 @@ namespace Trinity obj->GetGridRef().unlink(); return obj; } - template<class SPECIFIC_TYPE> SPECIFIC_TYPE* Remove(ContainerMapList<TypeNull> &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/) { return NULL; } - // this is a missed template<class SPECIFIC_TYPE, class T> SPECIFIC_TYPE* Remove(ContainerMapList<T> &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/) { return NULL; // a missed } - template<class SPECIFIC_TYPE, class T, class H> SPECIFIC_TYPE* Remove(ContainerMapList<TypeList<H, T> > &elements, SPECIFIC_TYPE *obj, OBJECT_HANDLE hdl) { // The head element is bad SPECIFIC_TYPE* t = Remove(elements._elements, obj, hdl); return ( t != NULL ? t : Remove(elements._TailElements, obj, hdl) ); } - } #endif diff --git a/src/framework/GameSystem/TypeContainerVisitor.h b/src/framework/GameSystem/TypeContainerVisitor.h index 97570b370c2..fc861cfe3da 100644 --- a/src/framework/GameSystem/TypeContainerVisitor.h +++ b/src/framework/GameSystem/TypeContainerVisitor.h @@ -17,101 +17,82 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #ifndef TRINITY_TYPECONTAINERVISITOR_H #define TRINITY_TYPECONTAINERVISITOR_H - /* * @class TypeContainerVisitor is implemented as a visitor pattern. It is * a visitor to the TypeContainerList or TypeContainerMapList. The visitor has * to overload its types as a visit method is called. */ - #include "Platform/Define.h" #include "TypeContainer.h" - // forward declaration template<class T, class Y> class TypeContainerVisitor; - // visitor helper template<class VISITOR, class TYPE_CONTAINER> void VisitorHelper(VISITOR &v, TYPE_CONTAINER &c) { v.Visit(c); }; - // terminate condition for container list template<class VISITOR> void VisitorHelper(VISITOR &v, ContainerList<TypeNull> &c) { } - template<class VISITOR, class T> void VisitorHelper(VISITOR &v, ContainerList<T> &c) { v.Visit(c._element); } - // recursion for container list template<class VISITOR, class H, class T> void VisitorHelper(VISITOR &v, ContainerList<TypeList<H, T> > &c) { VisitorHelper(v, c._elements); VisitorHelper(v, c._TailElements); } - // terminate condition container map list template<class VISITOR> void VisitorHelper(VISITOR &/*v*/, ContainerMapList<TypeNull> &/*c*/) { } - template<class VISITOR, class T> void VisitorHelper(VISITOR &v, ContainerMapList<T> &c) { v.Visit(c._element); } - // recursion container map list template<class VISITOR, class H, class T> void VisitorHelper(VISITOR &v, ContainerMapList<TypeList<H, T> > &c) { VisitorHelper(v, c._elements); VisitorHelper(v, c._TailElements); } - // array list template<class VISITOR, class T> void VisitorHelper(VISITOR &v, ContainerArrayList<T> &c) { v.Visit(c._element); } - template<class VISITOR> void VisitorHelper(VISITOR &/*v*/, ContainerArrayList<TypeNull> &/*c*/) { } - // recursion template<class VISITOR, class H, class T> void VisitorHelper(VISITOR &v, ContainerArrayList<TypeList<H, T> > &c) { VisitorHelper(v, c._elements); VisitorHelper(v, c._TailElements); } - // for TypeMapContainer template<class VISITOR, class OBJECT_TYPES> void VisitorHelper(VISITOR &v, TypeMapContainer<OBJECT_TYPES> &c) { VisitorHelper(v, c.GetElements()); } - template<class VISITOR, class TYPE_CONTAINER> class TRINITY_DLL_DECL TypeContainerVisitor { public: TypeContainerVisitor(VISITOR &v) : i_visitor(v) {} - void Visit(TYPE_CONTAINER &c) { VisitorHelper(i_visitor, c); } - void Visit(const TYPE_CONTAINER &c) const { VisitorHelper(i_visitor, c); } - private: VISITOR &i_visitor; }; |
