From 7532061a79eec01830837c351dfa15d0a9eef8fb Mon Sep 17 00:00:00 2001 From: XTZGZoReX Date: Thu, 22 Apr 2010 11:49:36 +0200 Subject: [PATCH] [9775] Cleanups in framework library. * Removed last bits of threading in grid code. * Removed some weird and unneeded declarations. * General code style fixes. * (Perhaps some things I forgot.) Thanks to Lynx3d for the usual GCC-stabbing... --- src/framework/GameSystem/Grid.h | 49 ++- src/framework/GameSystem/GridLoader.h | 14 +- src/framework/GameSystem/GridRefManager.h | 15 +- src/framework/GameSystem/GridReference.h | 29 +- src/framework/GameSystem/NGrid.h | 122 +++--- src/framework/GameSystem/TypeContainer.h | 101 +++-- .../GameSystem/TypeContainerFunctions.h | 45 ++- .../GameSystem/TypeContainerVisitor.h | 25 +- src/framework/Policies/CreationPolicy.h | 44 +- src/framework/Policies/MemoryManagement.cpp | 12 +- src/framework/Policies/ObjectLifeTime.cpp | 4 +- src/framework/Policies/ObjectLifeTime.h | 17 +- src/framework/Policies/Singleton.h | 25 +- src/framework/Policies/SingletonImp.h | 15 +- src/framework/Policies/ThreadingModel.h | 90 +++-- src/framework/Utilities/ByteConverter.h | 11 +- src/framework/Utilities/Callback.h | 378 ++++++++++++------ src/framework/Utilities/EventProcessor.cpp | 12 +- src/framework/Utilities/EventProcessor.h | 13 +- src/framework/Utilities/LinkedList.h | 63 +-- .../Utilities/LinkedReference/RefManager.h | 16 +- .../Utilities/LinkedReference/Reference.h | 52 ++- src/framework/Utilities/TypeList.h | 11 +- src/framework/Utilities/UnorderedMap.h | 7 +- src/shared/revision_nr.h | 2 +- 25 files changed, 774 insertions(+), 398 deletions(-) diff --git a/src/framework/GameSystem/Grid.h b/src/framework/GameSystem/Grid.h index bfd7934f9..fb0165445 100644 --- a/src/framework/GameSystem/Grid.h +++ b/src/framework/GameSystem/Grid.h @@ -42,13 +42,13 @@ template < class ACTIVE_OBJECT, class WORLD_OBJECT_TYPES, -class GRID_OBJECT_TYPES, -class ThreadModel = MaNGOS::SingleThreaded +class GRID_OBJECT_TYPES > class MANGOS_DLL_DECL Grid { // allows the GridLoader to access its internals template friend class GridLoader; + public: /** destructor to clean up its resources. This includes unloading the @@ -58,74 +58,71 @@ class MANGOS_DLL_DECL Grid /** an object of interested enters the grid */ - template bool AddWorldObject(SPECIFIC_OBJECT *obj) + template + bool AddWorldObject(SPECIFIC_OBJECT *obj) { return i_objects.template insert(obj); } /** an object of interested exits the grid */ - template bool RemoveWorldObject(SPECIFIC_OBJECT *obj) + template + bool RemoveWorldObject(SPECIFIC_OBJECT *obj) { return i_objects.template remove(obj); } - /** 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 void Visit(TypeContainerVisitor > &visitor) + template + void Visit(TypeContainerVisitor > &visitor) { visitor.Visit(i_container); } /** Grid visitor for world objects */ - template void Visit(TypeContainerVisitor > &visitor) + template + void Visit(TypeContainerVisitor > &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(); } + uint32 ActiveObjectsInGrid() const + { + return m_activeGridObjects.size() + i_objects.template Count(); + } /** Inserts a container type object into the grid. */ - template bool AddGridObject(SPECIFIC_OBJECT *obj) + template + bool AddGridObject(SPECIFIC_OBJECT *obj) { - if(obj->isActiveObject()) + if (obj->isActiveObject()) m_activeGridObjects.insert(obj); + return i_container.template insert(obj); } /** Removes a containter type object from the grid */ - template bool RemoveGridObject(SPECIFIC_OBJECT *obj) + template + bool RemoveGridObject(SPECIFIC_OBJECT *obj) { - if(obj->isActiveObject()) + if (obj->isActiveObject()) m_activeGridObjects.erase(obj); + return i_container.template remove(obj); } private: - typedef typename ThreadModel::Lock Guard; - typedef typename ThreadModel::VolatileType VolatileType; - TypeMapContainer i_container; TypeMapContainer i_objects; typedef std::set ActiveGridObjects; ActiveGridObjects m_activeGridObjects; }; + #endif diff --git a/src/framework/GameSystem/GridLoader.h b/src/framework/GameSystem/GridLoader.h index 486e0b145..e28eeffd3 100644 --- a/src/framework/GameSystem/GridLoader.h +++ b/src/framework/GameSystem/GridLoader.h @@ -47,30 +47,26 @@ class MANGOS_DLL_DECL GridLoader /** Loads the grid */ template - void Load(Grid &grid, LOADER &loader) + void Load(Grid &grid, LOADER &loader) { - grid.LockGrid(); loader.Load(grid); - grid.UnlockGrid(); } /** Stop the grid */ template - void Stop(Grid &grid, STOPER &stoper) + void Stop(Grid &grid, STOPER &stoper) { - grid.LockGrid(); stoper.Stop(grid); - grid.UnlockGrid(); } + /** Unloads the grid */ template - void Unload(Grid &grid, UNLOADER &unloader) + void Unload(Grid &grid, UNLOADER &unloader) { - grid.LockGrid(); unloader.Unload(grid); - grid.UnlockGrid(); } }; + #endif diff --git a/src/framework/GameSystem/GridRefManager.h b/src/framework/GameSystem/GridRefManager.h index 77f611a08..b81cb09d3 100644 --- a/src/framework/GameSystem/GridRefManager.h +++ b/src/framework/GameSystem/GridRefManager.h @@ -21,17 +21,24 @@ #include "Utilities/LinkedReference/RefManager.h" -template -class GridReference; +template class GridReference; template class GridRefManager : public RefManager, OBJECT> { public: + typedef LinkedListHead::Iterator< GridReference > iterator; - GridReference* getFirst() { return (GridReference*)RefManager, OBJECT>::getFirst(); } - GridReference* getLast() { return (GridReference*)RefManager, OBJECT>::getLast(); } + GridReference* getFirst() + { + return (GridReference*)RefManager, OBJECT>::getFirst(); + } + + GridReference* getLast() + { + return (GridReference*)RefManager, OBJECT>::getLast(); + } iterator begin() { return iterator(getFirst()); } iterator end() { return iterator(NULL); } diff --git a/src/framework/GameSystem/GridReference.h b/src/framework/GameSystem/GridReference.h index 1e67f4359..b54bcbef9 100644 --- a/src/framework/GameSystem/GridReference.h +++ b/src/framework/GameSystem/GridReference.h @@ -21,32 +21,49 @@ #include "Utilities/LinkedReference/Reference.h" -template -class GridRefManager; +template class GridRefManager; template class MANGOS_DLL_SPEC GridReference : public Reference, OBJECT> { protected: + void targetObjectBuildLink() { // called from link() this->getTarget()->insertFirst(this); this->getTarget()->incSize(); } + void targetObjectDestroyLink() { // called from unlink() - if(this->isValid()) this->getTarget()->decSize(); + if (this->isValid()) + this->getTarget()->decSize(); } + void sourceObjectDestroyLink() { // called from invalidate() this->getTarget()->decSize(); } + public: - GridReference() : Reference, OBJECT>() {} - ~GridReference() { this->unlink(); } - GridReference *next() { return (GridReference*)Reference, OBJECT>::next(); } + + GridReference() + : Reference, OBJECT>() + { + } + + ~GridReference() + { + this->unlink(); + } + + GridReference *next() + { + return (GridReference*)Reference, OBJECT>::next(); + } }; + #endif diff --git a/src/framework/GameSystem/NGrid.h b/src/framework/GameSystem/NGrid.h index d19b495f1..b3422c8bc 100644 --- a/src/framework/GameSystem/NGrid.h +++ b/src/framework/GameSystem/NGrid.h @@ -28,27 +28,42 @@ class GridInfo { -public: - GridInfo() - : i_timer(0), i_unloadActiveLockCount(0), i_unloadExplicitLock(false), i_unloadReferenceLock(false) {} - GridInfo(time_t expiry, bool unload = true ) - : i_timer(expiry), i_unloadActiveLockCount(0), i_unloadExplicitLock(!unload), i_unloadReferenceLock(false) {} - const TimeTracker& getTimeTracker() const { return i_timer; } - bool getUnloadLock() const { return i_unloadActiveLockCount || i_unloadExplicitLock || i_unloadReferenceLock; } - void setUnloadExplicitLock( bool on ) { i_unloadExplicitLock = on; } - void setUnloadReferenceLock( bool on ) { i_unloadReferenceLock = on; } - void incUnloadActiveLock() { ++i_unloadActiveLockCount; } - void decUnloadActiveLock() { if(i_unloadActiveLockCount) --i_unloadActiveLockCount; } + public: - 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); } + GridInfo() + : i_timer(0), i_unloadActiveLockCount(0), i_unloadExplicitLock(false), + i_unloadReferenceLock(false) + { + } -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 + GridInfo(time_t expiry, bool unload = true ) + : i_timer(expiry), i_unloadActiveLockCount(0), i_unloadExplicitLock(!unload), + i_unloadReferenceLock(false) + { + } + + const TimeTracker& getTimeTracker() const { return i_timer; } + + bool getUnloadLock() const + { + return i_unloadActiveLockCount || i_unloadExplicitLock || i_unloadReferenceLock; + } + + void setUnloadExplicitLock( bool on ) { i_unloadExplicitLock = on; } + 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 @@ -56,104 +71,112 @@ typedef enum GRID_STATE_INVALID = 0, GRID_STATE_ACTIVE = 1, GRID_STATE_IDLE = 2, - GRID_STATE_REMOVAL= 3, + GRID_STATE_REMOVAL = 3, MAX_GRID_STATE = 4 } grid_state_t; template < -unsigned int N, +uint32 N, class ACTIVE_OBJECT, class WORLD_OBJECT_TYPES, -class GRID_OBJECT_TYPES, -class ThreadModel = MaNGOS::SingleThreaded +class GRID_OBJECT_TYPES > class MANGOS_DLL_DECL NGrid { public: - typedef Grid GridType; - NGrid(uint32 id, int32 x, int32 y, time_t expiry, bool unload = true) + typedef Grid GridType; + + NGrid(uint32 id, uint32 x, uint32 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 + const GridType& operator()(uint32 x, uint32 y) const { ASSERT(x < N); ASSERT(y < N); return i_cells[x][y]; } - GridType& operator()(unsigned short x, unsigned short y) + GridType& operator()(uint32 x, uint32 y) { ASSERT(x < N); ASSERT(y < N); return i_cells[x][y]; } - const uint32& GetGridId(void) const { return i_gridId; } + const uint32& GetGridId() const { return i_gridId; } void SetGridId(const uint32 id) const { i_gridId = id; } - grid_state_t GetGridState(void) const { return i_cellstate; } + grid_state_t GetGridState() 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; } + uint32 getX() const { return i_x; } + uint32 getY() const { return i_y; } - void link(GridRefManager >* pTo) + void link(GridRefManager >* 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(); } - void setUnloadExplicitLock( bool on ) { i_GridInfo.setUnloadExplicitLock(on); } - void setUnloadReferenceLock( bool on ) { i_GridInfo.setUnloadReferenceLock(on); } + void setUnloadExplicitLock(bool on) { i_GridInfo.setUnloadExplicitLock(on); } + void setUnloadReferenceLock(bool on) { i_GridInfo.setUnloadReferenceLock(on); } void incUnloadActiveLock() { i_GridInfo.incUnloadActiveLock(); } void decUnloadActiveLock() { i_GridInfo.decUnloadActiveLock(); } void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); } void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); } - template void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) + template + void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { getGridType(x, y).AddWorldObject(obj); } - template void RemoveWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) + template + void RemoveWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { getGridType(x, y).RemoveWorldObject(obj); } - template void Visit(TypeContainerVisitor > &visitor) + template + void Visit(TypeContainerVisitor > &visitor) { - for(unsigned int x=0; x < N; ++x) - for(unsigned int y=0; y < N; ++y) + for (uint32 x = 0; x < N; ++x) + for (uint32 y = 0; y < N; ++y) i_cells[x][y].Visit(visitor); } - template void Visit(const uint32 &x, const uint32 &y, TypeContainerVisitor > &visitor) + template + void Visit(const uint32 &x, const uint32 &y, TypeContainerVisitor > &visitor) { getGridType(x, y).Visit(visitor); } - unsigned int ActiveObjectsInGrid(void) const + uint32 ActiveObjectsInGrid() const { - unsigned int count=0; - for(unsigned int x=0; x < N; ++x) - for(unsigned int y=0; y < N; ++y) + uint32 count = 0; + for (uint32 x = 0; x < N; ++x) + for (uint32 y = 0; y < N; ++y) count += i_cells[x][y].ActiveObjectsInGrid(); + return count; } - template bool AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) + template + bool AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { return getGridType(x, y).AddGridObject(obj); } - template bool RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) + template + bool RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { return getGridType(x, y).RemoveGridObject(obj); } @@ -169,11 +192,12 @@ class MANGOS_DLL_DECL NGrid uint32 i_gridId; GridInfo i_GridInfo; - GridReference > i_Reference; - int32 i_x; - int32 i_y; + GridReference > i_Reference; + uint32 i_x; + uint32 i_y; grid_state_t i_cellstate; GridType i_cells[N][N]; bool i_GridObjectDataLoaded; }; + #endif diff --git a/src/framework/GameSystem/TypeContainer.h b/src/framework/GameSystem/TypeContainer.h index eb3f8984d..a05ea7165 100644 --- a/src/framework/GameSystem/TypeContainer.h +++ b/src/framework/GameSystem/TypeContainer.h @@ -31,14 +31,19 @@ #include "Utilities/UnorderedMap.h" #include "GameSystem/GridRefManager.h" -template struct ContainerUnorderedMap +template +struct ContainerUnorderedMap { UNORDERED_MAP _element; }; -template struct ContainerUnorderedMap + +template +struct ContainerUnorderedMap { }; -template struct ContainerUnorderedMap< TypeList, KEY_TYPE > + +template +struct ContainerUnorderedMap< TypeList, KEY_TYPE > { ContainerUnorderedMap _elements; ContainerUnorderedMap _TailElements; @@ -48,24 +53,33 @@ template class TypeUnorderedMapContainer { public: - template bool insert(KEY_TYPE handle, SPECIFIC_TYPE* obj) + + template + bool insert(KEY_TYPE handle, SPECIFIC_TYPE* obj) { return TypeUnorderedMapContainer::insert(i_elements, handle, obj); } - template bool erase(KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/) + + template + bool erase(KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/) { return TypeUnorderedMapContainer::erase(i_elements, handle, (SPECIFIC_TYPE*)NULL); } - template SPECIFIC_TYPE* find(KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/) + + template + SPECIFIC_TYPE* find(KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/) { return TypeUnorderedMapContainer::find(i_elements, hdl, (SPECIFIC_TYPE*)NULL); } + private: + ContainerUnorderedMap i_elements; // Helpers // Insert helpers - template static bool insert(ContainerUnorderedMap& elements, KEY_TYPE handle, SPECIFIC_TYPE* obj) + template + static bool insert(ContainerUnorderedMap& elements, KEY_TYPE handle, SPECIFIC_TYPE* obj) { typename UNORDERED_MAP::iterator i = elements._element.find(handle); if (i == elements._element.end()) @@ -75,25 +89,33 @@ class TypeUnorderedMapContainer } else { - assert (i->second == obj && "Object with certain key already in but objects are different!"); + ASSERT(i->second == obj && "Object with certain key already in but objects are different!"); return false; } } - template static bool insert(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) + + template + static bool insert(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) { return false; } - template static bool insert(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) + + template + static bool insert(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) { return false; } - template static bool insert(ContainerUnorderedMap< TypeList, KEY_TYPE >& elements, KEY_TYPE handle, SPECIFIC_TYPE* obj) + + template + static bool insert(ContainerUnorderedMap< TypeList, KEY_TYPE >& elements, KEY_TYPE handle, SPECIFIC_TYPE* obj) { bool ret = TypeUnorderedMapContainer::insert(elements._elements, handle, obj); return ret ? ret : TypeUnorderedMapContainer::insert(elements._TailElements, handle, obj); } + // Find helpers - template static SPECIFIC_TYPE* find(ContainerUnorderedMap& elements, KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/) + template + static SPECIFIC_TYPE* find(ContainerUnorderedMap& elements, KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/) { typename UNORDERED_MAP::iterator i = elements._element.find(hdl); if (i == elements._element.end()) @@ -101,35 +123,49 @@ class TypeUnorderedMapContainer else return i->second; } - template static SPECIFIC_TYPE* find(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*hdl*/, SPECIFIC_TYPE* /*obj*/) + + template + static SPECIFIC_TYPE* find(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*hdl*/, SPECIFIC_TYPE* /*obj*/) { return NULL; } - template static SPECIFIC_TYPE* find(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*hdl*/, SPECIFIC_TYPE* /*obj*/) + + template + static SPECIFIC_TYPE* find(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*hdl*/, SPECIFIC_TYPE* /*obj*/) { return NULL; } - template static SPECIFIC_TYPE* find(ContainerUnorderedMap< TypeList, KEY_TYPE >& elements, KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/) + + template + static SPECIFIC_TYPE* find(ContainerUnorderedMap< TypeList, KEY_TYPE >& elements, KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/) { SPECIFIC_TYPE* ret = TypeUnorderedMapContainer::find(elements._elements, hdl, (SPECIFIC_TYPE*)NULL); return ret ? ret : TypeUnorderedMapContainer::find(elements._TailElements, hdl, (SPECIFIC_TYPE*)NULL); } + // Erase helpers - template static bool erase(ContainerUnorderedMap& elements, KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/) + template + static bool erase(ContainerUnorderedMap& elements, KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/) { elements._element.erase(handle); return true; } - template static bool erase(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) + + template + static bool erase(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) { return false; } - template static bool erase(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) + + template + static bool erase(ContainerUnorderedMap& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/) { return false; } - template static bool erase(ContainerUnorderedMap< TypeList, KEY_TYPE >& elements, KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/) + + template + static bool erase(ContainerUnorderedMap< TypeList, KEY_TYPE >& elements, KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/) { bool ret = TypeUnorderedMapContainer::erase(elements._elements, handle, (SPECIFIC_TYPE*)NULL); return ret ? ret : TypeUnorderedMapContainer::erase(elements._TailElements, handle, (SPECIFIC_TYPE*)NULL); @@ -141,21 +177,24 @@ class TypeUnorderedMapContainer * By itself its meaningless but collaborate along with TypeContainers, * it become the most powerfully container in the whole system. */ -template struct ContainerMapList +template +struct ContainerMapList { GridRefManager _element; }; -template<> struct ContainerMapList /* nothing is in type null */ +template<> +struct ContainerMapList /* nothing is in type null */ { }; -template struct ContainerMapList > + +template +struct ContainerMapList > { ContainerMapList _elements; ContainerMapList _TailElements; }; - #include "TypeContainerFunctions.h" /* @@ -169,26 +208,32 @@ template class MANGOS_DLL_DECL TypeMapContainer { public: - template size_t Count() const { return MaNGOS::Count(i_elements, (SPECIFIC_TYPE*)NULL); } + + template + size_t Count() const { return MaNGOS::Count(i_elements, (SPECIFIC_TYPE*)NULL); } /// inserts a specific object into the container - template bool insert(SPECIFIC_TYPE *obj) + template + bool insert(SPECIFIC_TYPE *obj) { SPECIFIC_TYPE* t = MaNGOS::Insert(i_elements, obj); return (t != NULL); } /// Removes the object from the container, and returns the removed object - template bool remove(SPECIFIC_TYPE* obj) + template + bool remove(SPECIFIC_TYPE* obj) { SPECIFIC_TYPE* t = MaNGOS::Remove(i_elements, obj); return (t != NULL); } - ContainerMapList & GetElements(void) { return i_elements; } - const ContainerMapList & GetElements(void) const { return i_elements;} + ContainerMapList & GetElements() { return i_elements; } + const ContainerMapList & GetElements() const { return i_elements;} private: + ContainerMapList i_elements; }; + #endif diff --git a/src/framework/GameSystem/TypeContainerFunctions.h b/src/framework/GameSystem/TypeContainerFunctions.h index 35a9170ec..3d61dd25e 100644 --- a/src/framework/GameSystem/TypeContainerFunctions.h +++ b/src/framework/GameSystem/TypeContainerFunctions.h @@ -33,81 +33,94 @@ namespace MaNGOS { /* ContainerMapList Helpers */ // count functions - template size_t Count(const ContainerMapList &elements, SPECIFIC_TYPE* /*fake*/) + template + size_t Count(const ContainerMapList &elements, SPECIFIC_TYPE* /*fake*/) { return elements._element.getSize(); - }; + } - template size_t Count(const ContainerMapList &/*elements*/, SPECIFIC_TYPE* /*fake*/) + template + size_t Count(const ContainerMapList &/*elements*/, SPECIFIC_TYPE* /*fake*/) { return 0; } - template size_t Count(const ContainerMapList &/*elements*/, SPECIFIC_TYPE* /*fake*/) + template + size_t Count(const ContainerMapList &/*elements*/, SPECIFIC_TYPE* /*fake*/) { return 0; } - template size_t Count(const ContainerMapList >&elements, SPECIFIC_TYPE* fake) + template + size_t Count(const ContainerMapList >&elements, SPECIFIC_TYPE* fake) { return Count(elements._elements,fake); } - template size_t Count(const ContainerMapList >&elements, SPECIFIC_TYPE* fake) + template + size_t Count(const ContainerMapList >&elements, SPECIFIC_TYPE* fake) { return Count(elements._TailElements, fake); } // non-const insert functions - template SPECIFIC_TYPE* Insert(ContainerMapList &elements, SPECIFIC_TYPE *obj) + template + SPECIFIC_TYPE* Insert(ContainerMapList &elements, SPECIFIC_TYPE *obj) { //elements._element[hdl] = obj; obj->GetGridRef().link(&elements._element, obj); return obj; - }; + } - template SPECIFIC_TYPE* Insert(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) + template + SPECIFIC_TYPE* Insert(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) { return NULL; } // this is a missed - template SPECIFIC_TYPE* Insert(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) + template + SPECIFIC_TYPE* Insert(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) { return NULL; // a missed } // Recursion - template SPECIFIC_TYPE* Insert(ContainerMapList >&elements, SPECIFIC_TYPE *obj) + template + SPECIFIC_TYPE* Insert(ContainerMapList >&elements, SPECIFIC_TYPE *obj) { SPECIFIC_TYPE* t= Insert(elements._elements, obj); return (t != NULL ? t : Insert(elements._TailElements, obj)); } // non-const remove method - template SPECIFIC_TYPE* Remove(ContainerMapList & /*elements*/, SPECIFIC_TYPE *obj) + template + SPECIFIC_TYPE* Remove(ContainerMapList & /*elements*/, SPECIFIC_TYPE *obj) { obj->GetGridRef().unlink(); return obj; } - template SPECIFIC_TYPE* Remove(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) + template + SPECIFIC_TYPE* Remove(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) { return NULL; } // this is a missed - template SPECIFIC_TYPE* Remove(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) + template + SPECIFIC_TYPE* Remove(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) { return NULL; // a missed } - template SPECIFIC_TYPE* Remove(ContainerMapList > &elements, SPECIFIC_TYPE *obj) + template + SPECIFIC_TYPE* Remove(ContainerMapList > &elements, SPECIFIC_TYPE *obj) { // The head element is bad SPECIFIC_TYPE* t = Remove(elements._elements, obj); return ( t != NULL ? t : Remove(elements._TailElements, obj) ); } - } + #endif diff --git a/src/framework/GameSystem/TypeContainerVisitor.h b/src/framework/GameSystem/TypeContainerVisitor.h index 346eb393e..4722e13f5 100644 --- a/src/framework/GameSystem/TypeContainerVisitor.h +++ b/src/framework/GameSystem/TypeContainerVisitor.h @@ -32,30 +32,35 @@ template class TypeContainerVisitor; // visitor helper -template void VisitorHelper(VISITOR &v, TYPE_CONTAINER &c) +template +void VisitorHelper(VISITOR &v, TYPE_CONTAINER &c) { v.Visit(c); -}; +} // terminate condition container map list -template void VisitorHelper(VISITOR &/*v*/, ContainerMapList &/*c*/) +template +void VisitorHelper(VISITOR &/*v*/, ContainerMapList &/*c*/) { } -template void VisitorHelper(VISITOR &v, ContainerMapList &c) +template +void VisitorHelper(VISITOR &v, ContainerMapList &c) { v.Visit(c._element); } // recursion container map list -template void VisitorHelper(VISITOR &v, ContainerMapList > &c) +template +void VisitorHelper(VISITOR &v, ContainerMapList > &c) { VisitorHelper(v, c._elements); VisitorHelper(v, c._TailElements); } // for TypeMapContainer -template void VisitorHelper(VISITOR &v, TypeMapContainer &c) +template +void VisitorHelper(VISITOR &v, TypeMapContainer &c) { VisitorHelper(v, c.GetElements()); } @@ -64,7 +69,11 @@ template class MANGOS_DLL_DECL TypeContainerVisitor { public: - TypeContainerVisitor(VISITOR &v) : i_visitor(v) {} + + TypeContainerVisitor(VISITOR &v) + : i_visitor(v) + { + } void Visit(TYPE_CONTAINER &c) { @@ -77,6 +86,8 @@ class MANGOS_DLL_DECL TypeContainerVisitor } private: + VISITOR &i_visitor; }; + #endif diff --git a/src/framework/Policies/CreationPolicy.h b/src/framework/Policies/CreationPolicy.h index d4dc410ca..943faba1c 100644 --- a/src/framework/Policies/CreationPolicy.h +++ b/src/framework/Policies/CreationPolicy.h @@ -27,20 +27,28 @@ namespace MaNGOS /** * OperatorNew policy creates an object on the heap using new. */ - template - class MANGOS_DLL_DECL OperatorNew + template + class MANGOS_DLL_DECL OperatorNew { public: - static T* Create(void) { return (new T); } - static void Destroy(T *obj) { delete obj; } + + static T* Create() + { + return (new T); + } + + static void Destroy(T *obj) + { + delete obj; + } }; /** * LocalStaticCreation policy creates an object on the stack * the first time call Create. */ - template - class MANGOS_DLL_DECL LocalStaticCreation + template + class MANGOS_DLL_DECL LocalStaticCreation { union MaxAlign { @@ -55,34 +63,43 @@ namespace MaNGOS int Test::* pMember_; int (Test::*pMemberFn_)(int); }; + public: - static T* Create(void) + + static T* Create() { static MaxAlign si_localStatic; return new(&si_localStatic) T; } - static void Destroy(T *obj) { obj->~T(); } + static void Destroy(T *obj) + { + obj->~T(); + } }; /** * CreateUsingMalloc by pass the memory manger. */ template - class MANGOS_DLL_DECL CreateUsingMalloc + class MANGOS_DLL_DECL CreateUsingMalloc { public: + static T* Create() { - void* p = ::malloc(sizeof(T)); - if (!p) return 0; + void* p = malloc(sizeof(T)); + + if (!p) + return NULL; + return new(p) T; } static void Destroy(T* p) { p->~T(); - ::free(p); + free(p); } }; @@ -90,7 +107,7 @@ namespace MaNGOS * CreateOnCallBack creates the object base on the call back. */ template - class MANGOS_DLL_DECL CreateOnCallBack + class MANGOS_DLL_DECL CreateOnCallBack { public: static T* Create() @@ -104,4 +121,5 @@ namespace MaNGOS } }; } + #endif diff --git a/src/framework/Policies/MemoryManagement.cpp b/src/framework/Policies/MemoryManagement.cpp index 2b37af3a8..fcf41a8f6 100644 --- a/src/framework/Policies/MemoryManagement.cpp +++ b/src/framework/Policies/MemoryManagement.cpp @@ -22,17 +22,23 @@ #include "../../dep/tbb/include/tbb/scalable_allocator.h" -void * operator new(size_t sz) +void* operator new(size_t sz) { void *res = scalable_malloc(sz); - if (NULL == res) throw std::bad_alloc(); + + if (res == NULL) + throw std::bad_alloc(); + return res; } void* operator new[](size_t sz) { void *res = scalable_malloc(sz); - if (NULL == res) throw std::bad_alloc(); + + if (res == NULL) + throw std::bad_alloc(); + return res; } diff --git a/src/framework/Policies/ObjectLifeTime.cpp b/src/framework/Policies/ObjectLifeTime.cpp index 61afe646a..89db6a1d4 100644 --- a/src/framework/Policies/ObjectLifeTime.cpp +++ b/src/framework/Policies/ObjectLifeTime.cpp @@ -23,10 +23,10 @@ namespace MaNGOS { extern "C" void external_wrapper(void *p) { - std::atexit( (void (*)())p ); + std::atexit((void (*)())p); } - void MANGOS_DLL_SPEC at_exit( void (*func)() ) + void MANGOS_DLL_SPEC at_exit(void (*func)()) { external_wrapper((void*)func); } diff --git a/src/framework/Policies/ObjectLifeTime.h b/src/framework/Policies/ObjectLifeTime.h index 00d7add85..d171a70ed 100644 --- a/src/framework/Policies/ObjectLifeTime.h +++ b/src/framework/Policies/ObjectLifeTime.h @@ -26,25 +26,26 @@ typedef void (* Destroyer)(void); namespace MaNGOS { - void MANGOS_DLL_SPEC at_exit( void (*func)() ); + void MANGOS_DLL_SPEC at_exit(void (*func)()); - template - class MANGOS_DLL_DECL ObjectLifeTime + template + class MANGOS_DLL_DECL ObjectLifeTime { public: - static void ScheduleCall(void (*destroyer)() ) + + static void ScheduleCall(void (*destroyer)()) { - at_exit( destroyer ); + at_exit(destroyer); } - DECLSPEC_NORETURN static void OnDeadReference(void) ATTR_NORETURN; - + DECLSPEC_NORETURN static void OnDeadReference() ATTR_NORETURN; }; template - void ObjectLifeTime::OnDeadReference(void) // We don't handle Dead Reference for now + void ObjectLifeTime::OnDeadReference() // We don't handle Dead Reference for now { throw std::runtime_error("Dead Reference"); } } + #endif diff --git a/src/framework/Policies/Singleton.h b/src/framework/Policies/Singleton.h index 02cb92be4..c4e10c076 100644 --- a/src/framework/Policies/Singleton.h +++ b/src/framework/Policies/Singleton.h @@ -30,25 +30,29 @@ namespace MaNGOS { template - < - typename T, - class ThreadingModel = MaNGOS::SingleThreaded, - class CreatePolicy = MaNGOS::OperatorNew, - class LifeTimePolicy = MaNGOS::ObjectLifeTime - > - class MANGOS_DLL_DECL Singleton + < + typename T, + class ThreadingModel = MaNGOS::SingleThreaded, + class CreatePolicy = MaNGOS::OperatorNew, + class LifeTimePolicy = MaNGOS::ObjectLifeTime + > + class MANGOS_DLL_DECL Singleton { public: + static T& Instance(); protected: - Singleton() {}; + + Singleton() + { + } private: // Prohibited actions...this does not prevent hijacking. - Singleton(const Singleton &); - Singleton& operator=(const Singleton &); + Singleton(const Singleton&); + Singleton& operator=(const Singleton&); // Singleton Helpers static void DestroySingleton(); @@ -59,4 +63,5 @@ namespace MaNGOS static bool si_destroyed; }; } + #endif diff --git a/src/framework/Policies/SingletonImp.h b/src/framework/Policies/SingletonImp.h index 85a7c4830..ba0d05616 100644 --- a/src/framework/Policies/SingletonImp.h +++ b/src/framework/Policies/SingletonImp.h @@ -31,20 +31,21 @@ class ThreadingModel, class CreatePolicy, class LifeTimePolicy > -T& -MaNGOS::Singleton::Instance() +T& MaNGOS::Singleton::Instance() { - if( !si_instance ) + if (!si_instance) { // double-checked Locking pattern Guard(); - if( !si_instance ) + + if (!si_instance) { - if( si_destroyed ) + if (si_destroyed) { si_destroyed = false; LifeTimePolicy::OnDeadReference(); } + si_instance = CreatePolicy::Create(); LifeTimePolicy::ScheduleCall(&DestroySingleton); } @@ -60,8 +61,7 @@ class ThreadingModel, class CreatePolicy, class LifeTimePolicy > -void -MaNGOS::Singleton::DestroySingleton() +void MaNGOS::Singleton::DestroySingleton() { CreatePolicy::Destroy(si_instance); si_instance = NULL; @@ -87,4 +87,5 @@ MaNGOS::Singleton::DestroySingl template class MANGOS_DLL_DECL MaNGOS::Singleton; \ template<> TYPE* MaNGOS::Singleton::si_instance = 0; \ template<> bool MaNGOS::Singleton::si_destroyed = false + #endif diff --git a/src/framework/Policies/ThreadingModel.h b/src/framework/Policies/ThreadingModel.h index 0345def50..dfb38247b 100644 --- a/src/framework/Policies/ThreadingModel.h +++ b/src/framework/Policies/ThreadingModel.h @@ -28,12 +28,13 @@ namespace MaNGOS { - inline void Guard(void *) {} - - template class MANGOS_DLL_DECL GeneralLock + template + class MANGOS_DLL_DECL GeneralLock { public: - GeneralLock(MUTEX &m) : i_mutex(m) + + GeneralLock(MUTEX &m) + : i_mutex(m) { i_mutex.acquire(); } @@ -42,79 +43,107 @@ namespace MaNGOS { i_mutex.release(); } + private: + GeneralLock(const GeneralLock &); GeneralLock& operator=(const GeneralLock &); MUTEX &i_mutex; }; - template - class MANGOS_DLL_DECL SingleThreaded + template + class MANGOS_DLL_DECL SingleThreaded { public: struct Lock // empty object { - Lock() {} - Lock(const T &) {} - Lock(const SingleThreaded &) // for single threaded we ignore this + Lock() + { + } + Lock(const T&) + { + } + + Lock(const SingleThreaded&) // for single threaded we ignore this { } }; - - typedef T VolatileType; }; - // object level lockable template - class MANGOS_DLL_DECL ObjectLevelLockable + class MANGOS_DLL_DECL ObjectLevelLockable { public: - ObjectLevelLockable() : i_mtx() {} + + ObjectLevelLockable() + : i_mtx() + { + } friend class Lock; class Lock { public: - Lock(ObjectLevelLockable &host) : i_lock(host.i_mtx) + + Lock(ObjectLevelLockable &host) + : i_lock(host.i_mtx) { } private: + GeneralLock i_lock; }; - typedef volatile T VolatileType; - private: + // prevent the compiler creating a copy construct - ObjectLevelLockable(const ObjectLevelLockable &); - ObjectLevelLockable& operator=(const ObjectLevelLockable &); + ObjectLevelLockable(const ObjectLevelLockable&); + ObjectLevelLockable& operator=(const ObjectLevelLockable&); MUTEX i_mtx; }; template - class MANGOS_DLL_DECL ClassLevelLockable + class MANGOS_DLL_DECL ClassLevelLockable { public: - class Lock; - friend class Lock; - typedef volatile T VolatileType; - ClassLevelLockable() {} + ClassLevelLockable() + { + } + + friend class Lock; class Lock { public: - Lock(T& /*host*/) { ClassLevelLockable::si_mtx.acquire(); } - Lock(ClassLevelLockable &) { ClassLevelLockable::si_mtx.acquire(); } - Lock() { ClassLevelLockable::si_mtx.acquire(); } - ~Lock() { ClassLevelLockable::si_mtx.release(); } + + Lock(T& /*host*/) + { + ClassLevelLockable::si_mtx.acquire(); + } + + Lock(ClassLevelLockable &) + { + ClassLevelLockable::si_mtx.acquire(); + } + + Lock() + { + ClassLevelLockable::si_mtx.acquire(); + } + + ~Lock() + { + ClassLevelLockable::si_mtx.release(); + } }; private: + static MUTEX si_mtx; }; @@ -122,6 +151,7 @@ namespace MaNGOS template MUTEX MaNGOS::ClassLevelLockable::si_mtx; -#define INSTANTIATE_CLASS_MUTEX(CTYPE,MUTEX) \ - template class MANGOS_DLL_DECL MaNGOS::ClassLevelLockable +#define INSTANTIATE_CLASS_MUTEX(CTYPE, MUTEX) \ + template class MANGOS_DLL_DECL MaNGOS::ClassLevelLockable + #endif diff --git a/src/framework/Utilities/ByteConverter.h b/src/framework/Utilities/ByteConverter.h index 13f3fac0b..9932404e3 100644 --- a/src/framework/Utilities/ByteConverter.h +++ b/src/framework/Utilities/ByteConverter.h @@ -23,13 +23,13 @@ for cross platform where they have different endians. */ -#include -#include +#include +#include namespace ByteConverter { template - inline void convert(char *val) + inline void convert(char *val) { std::swap(*val, *(val + T - 1)); convert(val + 1); @@ -38,7 +38,8 @@ namespace ByteConverter template<> inline void convert<0>(char *) {} template<> inline void convert<1>(char *) {} // ignore central byte - template inline void apply(T *val) + template + inline void apply(T *val) { convert((char *)(val)); } @@ -56,7 +57,7 @@ template void EndianConvert(T*); // will generate link error template void EndianConvertReverse(T*); // will generate link error inline void EndianConvert(uint8&) { } -inline void EndianConvert( int8&) { } +inline void EndianConvert(int8&) { } inline void EndianConvertReverse(uint8&) { } inline void EndianConvertReverse( int8&) { } diff --git a/src/framework/Utilities/Callback.h b/src/framework/Utilities/Callback.h index 49ef37f02..4007626fb 100644 --- a/src/framework/Utilities/Callback.h +++ b/src/framework/Utilities/Callback.h @@ -23,10 +23,11 @@ namespace MaNGOS { - template < class Class, typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void, typename ParamType4 = void > + template class _Callback { protected: + typedef void (Class::*Method)(ParamType1, ParamType2, ParamType3, ParamType4); Class *m_object; Method m_method; @@ -35,17 +36,27 @@ namespace MaNGOS ParamType3 m_param3; ParamType4 m_param4; void _Execute() { (m_object->*m_method)(m_param1, m_param2, m_param3, m_param4); } + public: + _Callback(Class *object, Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3, ParamType4 param4) - : m_object(object), m_method(method), m_param1(param1), m_param2(param2), m_param3(param3), m_param4(param4) {} - _Callback(_Callback < Class, ParamType1, ParamType2, ParamType3, ParamType4> const& cb) - : m_object(cb.object), m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3), m_param4(cb.m_param4) {} + : m_object(object), m_method(method), + m_param1(param1), m_param2(param2), m_param3(param3), m_param4(param4) + { + } + + _Callback(_Callback const& cb) + : m_object(cb.object), m_method(cb.m_method), + m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3), m_param4(cb.m_param4) + { + } }; - template < class Class, typename ParamType1, typename ParamType2, typename ParamType3 > - class _Callback < Class, ParamType1, ParamType2, ParamType3 > + template + class _Callback { protected: + typedef void (Class::*Method)(ParamType1, ParamType2, ParamType3); Class *m_object; Method m_method; @@ -53,67 +64,102 @@ namespace MaNGOS ParamType2 m_param2; ParamType3 m_param3; void _Execute() { (m_object->*m_method)(m_param1, m_param2, m_param3); } + public: _Callback(Class *object, Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3) - : m_object(object), m_method(method), m_param1(param1), m_param2(param2) {} - _Callback(_Callback < Class, ParamType1, ParamType2, ParamType3 > const& cb) - : m_object(cb.object), m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3) {} + : m_object(object), m_method(method), + m_param1(param1), m_param2(param2) + { + } + + _Callback(_Callback const& cb) + : m_object(cb.object), m_method(cb.m_method), + m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3) + { + } }; - template < class Class, typename ParamType1, typename ParamType2 > - class _Callback < Class, ParamType1, ParamType2 > + template + class _Callback { protected: + typedef void (Class::*Method)(ParamType1, ParamType2); Class *m_object; Method m_method; ParamType1 m_param1; ParamType2 m_param2; void _Execute() { (m_object->*m_method)(m_param1, m_param2); } + public: + _Callback(Class *object, Method method, ParamType1 param1, ParamType2 param2) - : m_object(object), m_method(method), m_param1(param1), m_param2(param2) {} - _Callback(_Callback < Class, ParamType1, ParamType2 > const& cb) - : m_object(cb.m_object), m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2) {} + : m_object(object), m_method(method), + m_param1(param1), m_param2(param2) + { + } + + _Callback(_Callback const& cb) + : m_object(cb.m_object), m_method(cb.m_method), + m_param1(cb.m_param1), m_param2(cb.m_param2) + { + } }; - template < class Class, typename ParamType1 > - class _Callback < Class, ParamType1 > + template + class _Callback { protected: + typedef void (Class::*Method)(ParamType1); Class *m_object; Method m_method; ParamType1 m_param1; void _Execute() { (m_object->*m_method)(m_param1); } + public: + _Callback(Class *object, Method method, ParamType1 param1) - : m_object(object), m_method(method), m_param1(param1) {} - _Callback(_Callback < Class, ParamType1 > const& cb) - : m_object(cb.m_object), m_method(cb.m_method), m_param1(cb.m_param1) {} + : m_object(object), m_method(method), + m_param1(param1) + { + } + + _Callback(_Callback const& cb) + : m_object(cb.m_object), m_method(cb.m_method), + m_param1(cb.m_param1) + { + } }; - template < class Class > - class _Callback < Class > + template + class _Callback { protected: + typedef void (Class::*Method)(); Class *m_object; Method m_method; void _Execute() { (m_object->*m_method)(); } + public: _Callback(Class *object, Method method) - : m_object(object), m_method(method) {} - _Callback(_Callback < Class > const& cb) - : m_object(cb.m_object), m_method(cb.m_method) {} + : m_object(object), m_method(method) + { + } + _Callback(_Callback const& cb) + : m_object(cb.m_object), m_method(cb.m_method) + { + } }; /// ---- Statics ---- - template < typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void, typename ParamType4 = void > + template class _SCallback { protected: + typedef void (*Method)(ParamType1, ParamType2, ParamType3, ParamType4); Method m_method; ParamType1 m_param1; @@ -121,73 +167,116 @@ namespace MaNGOS ParamType3 m_param3; ParamType4 m_param4; void _Execute() { (*m_method)(m_param1, m_param2, m_param3, m_param4); } + public: + _SCallback(Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3, ParamType4 param4) - : m_method(method), m_param1(param1), m_param2(param2), m_param3(param3), m_param4(param4) {} - _SCallback(_SCallback < ParamType1, ParamType2, ParamType3, ParamType4> const& cb) - : m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3), m_param4(cb.m_param4) {} + : m_method(method), + m_param1(param1), m_param2(param2), m_param3(param3), m_param4(param4) + { + } + + _SCallback(_SCallback const& cb) + : m_method(cb.m_method), + m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3), m_param4(cb.m_param4) + { + } }; - template < typename ParamType1, typename ParamType2, typename ParamType3 > - class _SCallback < ParamType1, ParamType2, ParamType3 > + template + class _SCallback { protected: + typedef void (*Method)(ParamType1, ParamType2, ParamType3); Method m_method; ParamType1 m_param1; ParamType2 m_param2; ParamType3 m_param3; void _Execute() { (*m_method)(m_param1, m_param2, m_param3); } + public: _SCallback(Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3) - : m_method(method), m_param1(param1), m_param2(param2), m_param3(param3) {} - _SCallback(_SCallback < ParamType1, ParamType2, ParamType3 > const& cb) - : m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3) {} + : m_method(method), + m_param1(param1), m_param2(param2), m_param3(param3) + { + } + _SCallback(_SCallback const& cb) + : m_method(cb.m_method), + m_param1(cb.m_param1), m_param2(cb.m_param2), m_param3(cb.m_param3) + { + } }; - template < typename ParamType1, typename ParamType2 > - class _SCallback < ParamType1, ParamType2 > + template + class _SCallback { protected: + typedef void (*Method)(ParamType1, ParamType2); Method m_method; ParamType1 m_param1; ParamType2 m_param2; void _Execute() { (*m_method)(m_param1, m_param2); } + public: _SCallback(Method method, ParamType1 param1, ParamType2 param2) - : m_method(method), m_param1(param1), m_param2(param2) {} - _SCallback(_SCallback < ParamType1, ParamType2 > const& cb) - : m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2) {} + : m_method(method), + m_param1(param1), m_param2(param2) + { + } + + _SCallback(_SCallback const& cb) + : m_method(cb.m_method), + m_param1(cb.m_param1), m_param2(cb.m_param2) + { + } }; - template < typename ParamType1 > - class _SCallback < ParamType1 > + template + class _SCallback { protected: + typedef void (*Method)(ParamType1); Method m_method; ParamType1 m_param1; void _Execute() { (*m_method)(m_param1); } + public: _SCallback(Method method, ParamType1 param1) - : m_method(method), m_param1(param1) {} - _SCallback(_SCallback < ParamType1 > const& cb) - : m_method(cb.m_method), m_param1(cb.m_param1) {} + : m_method(method), + m_param1(param1) + { + } + + _SCallback(_SCallback const& cb) + : m_method(cb.m_method), + m_param1(cb.m_param1) + { + } }; - template < > - class _SCallback < > + template<> + class _SCallback<> { protected: + typedef void (*Method)(); Method m_method; void _Execute() { (*m_method)(); } + public: + _SCallback(Method method) - : m_method(method) {} - _SCallback(_SCallback <> const& cb) - : m_method(cb.m_method) {} + : m_method(method) + { + } + + _SCallback(_SCallback<> const& cb) + : m_method(cb.m_method) + { + } }; } @@ -198,70 +287,93 @@ namespace MaNGOS class ICallback { public: + virtual void Execute() = 0; virtual ~ICallback() {} }; - template < class CB > + template class _ICallback : public CB, public ICallback { public: - _ICallback(CB const& cb) : CB(cb) {} + + _ICallback(CB const& cb) : CB(cb) + { + } + void Execute() { CB::_Execute(); } }; - template < class Class, typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void, typename ParamType4 = void > - class Callback : - public _ICallback< _Callback < Class, ParamType1, ParamType2, ParamType3, ParamType4 > > + template + class Callback : public _ICallback<_Callback > { private: - typedef _Callback < Class, ParamType1, ParamType2, ParamType3, ParamType4 > C4; + + typedef _Callback C4; public: + Callback(Class *object, typename C4::Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3, ParamType4 param4) - : _ICallback< C4 >(C4(object, method, param1, param2, param3, param4)) {} + : _ICallback(C4(object, method, param1, param2, param3, param4)) + { + } }; - template < class Class, typename ParamType1, typename ParamType2, typename ParamType3 > - class Callback < Class, ParamType1, ParamType2, ParamType3 > : - public _ICallback< _Callback < Class, ParamType1, ParamType2, ParamType3 > > + template + class Callback : public _ICallback<_Callback > { private: - typedef _Callback < Class, ParamType1, ParamType2, ParamType3 > C3; + + typedef _Callback C3; public: + Callback(Class *object, typename C3::Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3) - : _ICallback< C3 >(C3(object, method, param1, param2, param3)) {} + : _ICallback(C3(object, method, param1, param2, param3)) + { + } }; - template < class Class, typename ParamType1, typename ParamType2 > - class Callback < Class, ParamType1, ParamType2 > : - public _ICallback< _Callback < Class, ParamType1, ParamType2 > > + template + class Callback : public _ICallback<_Callback > { private: - typedef _Callback < Class, ParamType1, ParamType2 > C2; + + typedef _Callback C2; + public: Callback(Class *object, typename C2::Method method, ParamType1 param1, ParamType2 param2) - : _ICallback< C2 >(C2(object, method, param1, param2)) {} + : _ICallback(C2(object, method, param1, param2)) + { + } }; - template < class Class, typename ParamType1 > - class Callback < Class, ParamType1 > : - public _ICallback< _Callback < Class, ParamType1 > > + template + class Callback : public _ICallback<_Callback > { private: - typedef _Callback < Class, ParamType1 > C1; + + typedef _Callback C1; + public: + Callback(Class *object, typename C1::Method method, ParamType1 param1) - : _ICallback< C1 >(C1(object, method, param1)) {} + : _ICallback(C1(object, method, param1)) + { + } }; - template < class Class > - class Callback < Class > : public _ICallback< _Callback < Class > > + template + class Callback : public _ICallback<_Callback > { private: - typedef _Callback < Class > C0; + + typedef _Callback C0; + public: + Callback(Class *object, typename C0::Method method) - : _ICallback< C0 >(C0(object, method)) {} + : _ICallback(C0(object, method)) + { + } }; } @@ -274,108 +386,146 @@ namespace MaNGOS class IQueryCallback { public: + virtual void Execute() = 0; virtual ~IQueryCallback() {} virtual void SetResult(QueryResult* result) = 0; virtual QueryResult* GetResult() = 0; }; - template < class CB > + template class _IQueryCallback : public CB, public IQueryCallback { public: - _IQueryCallback(CB const& cb) : CB(cb) {} + + _IQueryCallback(CB const& cb) : CB(cb) + { + } + void Execute() { CB::_Execute(); } void SetResult(QueryResult* result) { CB::m_param1 = result; } QueryResult* GetResult() { return CB::m_param1; } }; - template < class Class, typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void > - class QueryCallback : - public _IQueryCallback< _Callback < Class, QueryResult*, ParamType1, ParamType2, ParamType3 > > + template + class QueryCallback : public _IQueryCallback<_Callback > { private: - typedef _Callback < Class, QueryResult*, ParamType1, ParamType2, ParamType3 > QC3; + + typedef _Callback QC3; + public: + QueryCallback(Class *object, typename QC3::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2, ParamType3 param3) - : _IQueryCallback< QC3 >(QC3(object, method, result, param1, param2, param3)) {} + : _IQueryCallback(QC3(object, method, result, param1, param2, param3)) + { + } }; - template < class Class, typename ParamType1, typename ParamType2 > - class QueryCallback < Class, ParamType1, ParamType2 > : - public _IQueryCallback< _Callback < Class, QueryResult*, ParamType1, ParamType2 > > + template + class QueryCallback : public _IQueryCallback<_Callback > { private: - typedef _Callback < Class, QueryResult*, ParamType1, ParamType2 > QC2; + + typedef _Callback QC2; + public: + QueryCallback(Class *object, typename QC2::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2) - : _IQueryCallback< QC2 >(QC2(object, method, result, param1, param2)) {} + : _IQueryCallback(QC2(object, method, result, param1, param2)) + { + } }; - template < class Class, typename ParamType1 > - class QueryCallback < Class, ParamType1 > : - public _IQueryCallback< _Callback < Class, QueryResult*, ParamType1 > > + template + class QueryCallback : public _IQueryCallback<_Callback > { private: - typedef _Callback < Class, QueryResult*, ParamType1 > QC1; + + typedef _Callback QC1; + public: + QueryCallback(Class *object, typename QC1::Method method, QueryResult* result, ParamType1 param1) - : _IQueryCallback< QC1 >(QC1(object, method, result, param1)) {} + : _IQueryCallback(QC1(object, method, result, param1)) + { + } }; - template < class Class > - class QueryCallback < Class > : public _IQueryCallback< _Callback < Class, QueryResult* > > + template + class QueryCallback : public _IQueryCallback<_Callback > { private: - typedef _Callback < Class, QueryResult* > QC0; + + typedef _Callback QC0; + public: QueryCallback(Class *object, typename QC0::Method method, QueryResult* result) - : _IQueryCallback< QC0 >(QC0(object, method, result)) {} + : _IQueryCallback(QC0(object, method, result)) + { + } }; /// ---- Statics ---- - template < typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void > - class SQueryCallback : - public _IQueryCallback< _SCallback < QueryResult*, ParamType1, ParamType2, ParamType3 > > + template + class SQueryCallback : public _IQueryCallback<_SCallback > { private: - typedef _SCallback < QueryResult*, ParamType1, ParamType2, ParamType3 > QC3; + + typedef _SCallback QC3; + public: + SQueryCallback(typename QC3::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2, ParamType3 param3) - : _IQueryCallback< QC3 >(QC3(method, result, param1, param2, param3)) {} + : _IQueryCallback(QC3(method, result, param1, param2, param3)) + { + } }; - template < typename ParamType1, typename ParamType2 > - class SQueryCallback < ParamType1, ParamType2 > : - public _IQueryCallback< _SCallback < QueryResult*, ParamType1, ParamType2 > > + template + class SQueryCallback < ParamType1, ParamType2 > : public _IQueryCallback<_SCallback > { private: - typedef _SCallback < QueryResult*, ParamType1, ParamType2 > QC2; + + typedef _SCallback QC2; + public: + SQueryCallback(typename QC2::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2) - : _IQueryCallback< QC2 >(QC2(method, result, param1, param2)) {} + : _IQueryCallback(QC2(method, result, param1, param2)) + { + } }; - template < typename ParamType1 > - class SQueryCallback < ParamType1 > : - public _IQueryCallback< _SCallback < QueryResult*, ParamType1 > > + template + class SQueryCallback : public _IQueryCallback<_SCallback > { private: - typedef _SCallback < QueryResult*, ParamType1 > QC1; + + typedef _SCallback QC1; + public: + SQueryCallback(typename QC1::Method method, QueryResult* result, ParamType1 param1) - : _IQueryCallback< QC1 >(QC1(method, result, param1)) {} + : _IQueryCallback(QC1(method, result, param1)) + { + } }; - template < > - class SQueryCallback < > : public _IQueryCallback< _SCallback < QueryResult* > > + template<> + class SQueryCallback<> : public _IQueryCallback<_SCallback > { private: - typedef _SCallback < QueryResult* > QC0; + + typedef _SCallback QC0; + public: + SQueryCallback(QC0::Method method, QueryResult* result) - : _IQueryCallback< QC0 >(QC0(method, result)) {} + : _IQueryCallback(QC0(method, result)) + { + } }; } diff --git a/src/framework/Utilities/EventProcessor.cpp b/src/framework/Utilities/EventProcessor.cpp index 060e6f678..6671e7520 100644 --- a/src/framework/Utilities/EventProcessor.cpp +++ b/src/framework/Utilities/EventProcessor.cpp @@ -71,28 +71,30 @@ void EventProcessor::KillAllEvents(bool force) i_old->second->to_Abort = true; i_old->second->Abort(m_time); - if(force || i_old->second->IsDeletable()) + if (force || i_old->second->IsDeletable()) { delete i_old->second; - if(!force) // need per-element cleanup + if (!force) // need per-element cleanup m_events.erase (i_old); } } // fast clear event list (in force case) - if(force) + if (force) m_events.clear(); } void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime) { - if (set_addtime) Event->m_addTime = m_time; + if (set_addtime) + Event->m_addTime = m_time; + Event->m_execTime = e_time; m_events.insert(std::pair(e_time, Event)); } uint64 EventProcessor::CalculateTime(uint64 t_offset) { - return(m_time + t_offset); + return m_time + t_offset; } diff --git a/src/framework/Utilities/EventProcessor.h b/src/framework/Utilities/EventProcessor.h index dca521b01..483fcff9c 100644 --- a/src/framework/Utilities/EventProcessor.h +++ b/src/framework/Utilities/EventProcessor.h @@ -21,14 +21,19 @@ #include "Platform/Define.h" -#include +#include // Note. All times are in milliseconds here. class BasicEvent { public: - BasicEvent() { to_Abort = false; } + + BasicEvent() + : to_Abort(false) + { + } + virtual ~BasicEvent() // override destructor to perform some actions on event removal { }; @@ -55,6 +60,7 @@ typedef std::multimap EventList; class EventProcessor { public: + EventProcessor(); ~EventProcessor(); @@ -62,9 +68,12 @@ class EventProcessor void KillAllEvents(bool force); void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true); uint64 CalculateTime(uint64 t_offset); + protected: + uint64 m_time; EventList m_events; bool m_aborting; }; + #endif diff --git a/src/framework/Utilities/LinkedList.h b/src/framework/Utilities/LinkedList.h index 0ab71ad9f..9481d9dad 100644 --- a/src/framework/Utilities/LinkedList.h +++ b/src/framework/Utilities/LinkedList.h @@ -27,17 +27,20 @@ class LinkedListHead; class LinkedListElement { private: + friend class LinkedListHead; LinkedListElement* iNext; LinkedListElement* iPrev; + public: - LinkedListElement() { iNext = NULL; iPrev = NULL; } + + LinkedListElement() { iNext = NULL; iPrev = NULL; } ~LinkedListElement() { delink(); } - bool hasNext() const { return(iNext->iNext != NULL); } - bool hasPrev() const { return(iPrev->iPrev != NULL); } - bool isInList() const { return(iNext != NULL && iPrev != NULL); } + bool hasNext() const { return (iNext->iNext != NULL); } + bool hasPrev() const { return (iPrev->iPrev != NULL); } + bool isInList() const { return (iNext != NULL && iPrev != NULL); } LinkedListElement * next() { return hasNext() ? iNext : NULL; } LinkedListElement const* next() const { return hasNext() ? iNext : NULL; } @@ -51,9 +54,12 @@ class LinkedListElement void delink() { - if(isInList()) + if (isInList()) { - iNext->iPrev = iPrev; iPrev->iNext = iNext; iNext = NULL; iPrev = NULL; + iNext->iPrev = iPrev; + iPrev->iNext = iNext; + iNext = NULL; + iPrev = NULL; } } @@ -79,10 +85,13 @@ class LinkedListElement class LinkedListHead { private: + LinkedListElement iFirst; LinkedListElement iLast; uint32 iSize; + public: + LinkedListHead() { // create empty list @@ -92,13 +101,13 @@ class LinkedListHead iSize = 0; } - bool isEmpty() const { return(!iFirst.iNext->isInList()); } + bool isEmpty() const { return (!iFirst.iNext->isInList()); } - LinkedListElement * getFirst() { return(isEmpty() ? NULL : iFirst.iNext); } - LinkedListElement const* getFirst() const { return(isEmpty() ? NULL : iFirst.iNext); } + LinkedListElement * getFirst() { return (isEmpty() ? NULL : iFirst.iNext); } + LinkedListElement const* getFirst() const { return (isEmpty() ? NULL : iFirst.iNext); } - LinkedListElement * getLast() { return(isEmpty() ? NULL : iLast.iPrev); } - LinkedListElement const* getLast() const { return(isEmpty() ? NULL : iLast.iPrev); } + LinkedListElement * getLast() { return (isEmpty() ? NULL : iLast.iPrev); } + LinkedListElement const* getLast() const { return (isEmpty() ? NULL : iLast.iPrev); } void insertFirst(LinkedListElement* pElem) { @@ -112,15 +121,17 @@ class LinkedListHead uint32 getSize() const { - if(!iSize) + if (!iSize) { uint32 result = 0; LinkedListElement const* e = getFirst(); + while(e) { ++result; e = e->next(); } + return result; } else @@ -131,24 +142,27 @@ class LinkedListHead void decSize() { --iSize; } template - class Iterator + class Iterator { public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef _Ty value_type; - typedef ptrdiff_t difference_type; - typedef ptrdiff_t distance_type; - typedef _Ty* pointer; - typedef _Ty const* const_pointer; - typedef _Ty& reference; - typedef _Ty const & const_reference; + + typedef std::bidirectional_iterator_tag iterator_category; + typedef _Ty value_type; + typedef ptrdiff_t difference_type; + typedef ptrdiff_t distance_type; + typedef _Ty* pointer; + typedef _Ty const* const_pointer; + typedef _Ty& reference; + typedef _Ty const& const_reference; - Iterator() : _Ptr(0) + Iterator() + : _Ptr(0) { // construct with null node pointer } - Iterator(pointer _Pnode) : _Ptr(_Pnode) + Iterator(pointer _Pnode) + : _Ptr(_Pnode) { // construct with node pointer _Pnode } @@ -229,13 +243,13 @@ class LinkedListHead return (_Ptr != &_Right); } - pointer _Mynode() { // return node pointer return (_Ptr); } protected: + pointer _Ptr; // pointer to node }; @@ -243,4 +257,5 @@ class LinkedListHead }; //============================================ + #endif diff --git a/src/framework/Utilities/LinkedReference/RefManager.h b/src/framework/Utilities/LinkedReference/RefManager.h index 795718e29..0a74ebc6e 100644 --- a/src/framework/Utilities/LinkedReference/RefManager.h +++ b/src/framework/Utilities/LinkedReference/RefManager.h @@ -18,21 +18,24 @@ #ifndef _REFMANAGER_H #define _REFMANAGER_H + //===================================================== #include "Utilities/LinkedList.h" #include "Utilities/LinkedReference/Reference.h" -template class RefManager : public LinkedListHead +template +class RefManager : public LinkedListHead { public: - typedef LinkedListHead::Iterator< Reference > iterator; - RefManager() { } + + typedef LinkedListHead::Iterator > iterator; + RefManager() {} virtual ~RefManager() { clearReferences(); } - Reference* getFirst() { return ((Reference*) LinkedListHead::getFirst()); } + Reference* getFirst() { return ((Reference *) LinkedListHead::getFirst()); } Reference const* getFirst() const { return ((Reference const*) LinkedListHead::getFirst()); } - Reference* getLast() { return ((Reference*) LinkedListHead::getLast()); } + Reference* getLast() { return ((Reference *) LinkedListHead::getLast()); } Reference const* getLast() const { return ((Reference const*) LinkedListHead::getLast()); } iterator begin() { return iterator(getFirst()); } @@ -43,7 +46,7 @@ template class RefManager : public LinkedListHead void clearReferences() { LinkedListElement* ref; - while((ref = getFirst()) != NULL) + while ((ref = getFirst()) != NULL) { ((Reference*) ref)->invalidate(); ref->delink(); // the delink might be already done by invalidate(), but doing it here again does not hurt and insures an empty list @@ -52,4 +55,5 @@ template class RefManager : public LinkedListHead }; //===================================================== + #endif diff --git a/src/framework/Utilities/LinkedReference/Reference.h b/src/framework/Utilities/LinkedReference/Reference.h index 8ba2b7435..047924f93 100644 --- a/src/framework/Utilities/LinkedReference/Reference.h +++ b/src/framework/Utilities/LinkedReference/Reference.h @@ -23,12 +23,16 @@ //===================================================== -template class Reference : public LinkedListElement +template +class Reference : public LinkedListElement { private: + TO* iRefTo; FROM* iRefFrom; + protected: + // Tell our refTo (target) object that we have a link virtual void targetObjectBuildLink() = 0; @@ -37,17 +41,24 @@ template class Reference : public LinkedListElement // Tell our refFrom (source) object, that the link is cut (Target destroyed) virtual void sourceObjectDestroyLink() = 0; + public: - Reference() { iRefTo = NULL; iRefFrom = NULL; } + + Reference() + : iRefTo(NULL), iRefFrom(NULL) + { + } + virtual ~Reference() {} // Create new link void link(TO* toObj, FROM* fromObj) { - assert(fromObj); // fromObj MUST not be NULL - if(isValid()) + ASSERT(fromObj); // fromObj MUST not be NULL + if (isValid()) unlink(); - if(toObj != NULL) + + if (toObj != NULL) { iRefTo = toObj; iRefFrom = fromObj; @@ -57,13 +68,21 @@ template class Reference : public LinkedListElement // We don't need the reference anymore. Call comes from the refFrom object // Tell our refTo object, that the link is cut - void unlink() { targetObjectDestroyLink(); delink(); iRefTo = NULL; iRefFrom = NULL; } + void unlink() + { + targetObjectDestroyLink(); + delink(); + iRefTo = NULL; + iRefFrom = NULL; + } // Link is invalid due to destruction of referenced target object. Call comes from the refTo object // Tell our refFrom object, that the link is cut void invalidate() // the iRefFrom MUST remain!! { - sourceObjectDestroyLink(); delink(); iRefTo = NULL; + sourceObjectDestroyLink(); + delink(); + iRefTo = NULL; } bool isValid() const // Only check the iRefTo @@ -71,21 +90,22 @@ template class Reference : public LinkedListElement return iRefTo != NULL; } - Reference * next() { return((Reference *) LinkedListElement::next()); } - Reference const * next() const { return((Reference const *) LinkedListElement::next()); } - Reference * prev() { return((Reference *) LinkedListElement::prev()); } - Reference const * prev() const { return((Reference const *) LinkedListElement::prev()); } + Reference * next() { return((Reference *) LinkedListElement::next()); } + Reference const* next() const { return((Reference const*) LinkedListElement::next()); } + Reference * prev() { return((Reference *) LinkedListElement::prev()); } + Reference const* prev() const { return((Reference const*) LinkedListElement::prev()); } - Reference * nocheck_next() { return((Reference *) LinkedListElement::nocheck_next()); } - Reference const * nocheck_next() const { return((Reference const *) LinkedListElement::nocheck_next()); } - Reference * nocheck_prev() { return((Reference *) LinkedListElement::nocheck_prev()); } - Reference const * nocheck_prev() const { return((Reference const *) LinkedListElement::nocheck_prev()); } + Reference * nocheck_next() { return((Reference *) LinkedListElement::nocheck_next()); } + Reference const* nocheck_next() const { return((Reference const*) LinkedListElement::nocheck_next()); } + Reference * nocheck_prev() { return((Reference *) LinkedListElement::nocheck_prev()); } + Reference const* nocheck_prev() const { return((Reference const*) LinkedListElement::nocheck_prev()); } - TO* operator ->() const { return iRefTo; } + TO* operator->() const { return iRefTo; } TO* getTarget() const { return iRefTo; } FROM* getSource() const { return iRefFrom; } }; //===================================================== + #endif diff --git a/src/framework/Utilities/TypeList.h b/src/framework/Utilities/TypeList.h index 804dfd949..b37c2676b 100644 --- a/src/framework/Utilities/TypeList.h +++ b/src/framework/Utilities/TypeList.h @@ -35,9 +35,10 @@ struct TypeList }; // enough for now.. can be expand at any point in time as needed -#define TYPELIST_1(T1) TypeList -#define TYPELIST_2(T1, T2) TypeList -#define TYPELIST_3(T1, T2, T3) TypeList -#define TYPELIST_4(T1, T2, T3, T4) TypeList -#define TYPELIST_5(T1, T2, T3, T4, T5) TypeList +#define TYPELIST_1(T1) TypeList +#define TYPELIST_2(T1, T2) TypeList +#define TYPELIST_3(T1, T2, T3) TypeList +#define TYPELIST_4(T1, T2, T3, T4) TypeList +#define TYPELIST_5(T1, T2, T3, T4, T5) TypeList + #endif diff --git a/src/framework/Utilities/UnorderedMap.h b/src/framework/Utilities/UnorderedMap.h index 467b807d7..7155d37bf 100644 --- a/src/framework/Utilities/UnorderedMap.h +++ b/src/framework/Utilities/UnorderedMap.h @@ -52,11 +52,14 @@ using std::hash_map; namespace __gnu_cxx { - template<> struct hash + template<> + struct hash { size_t operator()(const unsigned long long &__x) const { return (size_t)__x; } }; - template struct hash + + template + struct hash { size_t operator()(T * const &__x) const { return (size_t)__x; } }; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 1c777550b..46e54c99c 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9774" + #define REVISION_NR "9775" #endif // __REVISION_NR_H__