aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
authormaximius <none@none>2009-10-17 15:35:07 -0700
committermaximius <none@none>2009-10-17 15:35:07 -0700
commit26b5e033ffde3d161382fc9addbfa99738379641 (patch)
treea344f369ca32945f787a02dee35c3dbe342bed7e /src/framework
parentf21f47005dcb6b76e1abc9f35fbcd03eed191bff (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')
-rw-r--r--src/framework/Dynamic/FactoryHolder.h7
-rw-r--r--src/framework/Dynamic/ObjectRegistry.h13
-rw-r--r--src/framework/GameSystem/Grid.h22
-rw-r--r--src/framework/GameSystem/GridLoader.h6
-rw-r--r--src/framework/GameSystem/GridRefManager.h6
-rw-r--r--src/framework/GameSystem/GridReference.h4
-rw-r--r--src/framework/GameSystem/NGrid.h26
-rw-r--r--src/framework/GameSystem/TypeContainer.h18
-rw-r--r--src/framework/GameSystem/TypeContainerFunctions.h26
-rw-r--r--src/framework/GameSystem/TypeContainerVisitor.h19
-rw-r--r--src/framework/Network/SocketDefines.h7
-rw-r--r--src/framework/Platform/CompilerDefs.h6
-rw-r--r--src/framework/Platform/Define.h20
-rw-r--r--src/framework/Policies/CreationPolicy.h9
-rw-r--r--src/framework/Policies/ObjectLifeTime.cpp3
-rw-r--r--src/framework/Policies/ObjectLifeTime.h8
-rw-r--r--src/framework/Policies/Singleton.h9
-rw-r--r--src/framework/Policies/SingletonImp.h10
-rw-r--r--src/framework/Policies/ThreadingModel.h23
-rw-r--r--src/framework/Utilities/ByteConverter.h10
-rw-r--r--src/framework/Utilities/Callback.h35
-rw-r--r--src/framework/Utilities/CountedReference/Reference.h17
-rw-r--r--src/framework/Utilities/CountedReference/ReferenceHolder.h3
-rw-r--r--src/framework/Utilities/CountedReference/ReferenceImpl.h13
-rw-r--r--src/framework/Utilities/EventProcessor.cpp13
-rw-r--r--src/framework/Utilities/EventProcessor.h13
-rw-r--r--src/framework/Utilities/LinkedList.h42
-rw-r--r--src/framework/Utilities/LinkedReference/RefManager.h7
-rw-r--r--src/framework/Utilities/LinkedReference/Reference.h15
-rw-r--r--src/framework/Utilities/TypeList.h5
-rw-r--r--src/framework/Utilities/UnorderedMap.h7
31 files changed, 0 insertions, 422 deletions
diff --git a/src/framework/Dynamic/FactoryHolder.h b/src/framework/Dynamic/FactoryHolder.h
index 858b8c1e1d3..ab3671fc2c3 100644
--- a/src/framework/Dynamic/FactoryHolder.h
+++ b/src/framework/Dynamic/FactoryHolder.h
@@ -17,15 +17,12 @@
* 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_FACTORY_HOLDER
#define TRINITY_FACTORY_HOLDER
-
#include "Platform/Define.h"
#include "Utilities/TypeList.h"
#include "ObjectRegistry.h"
#include "Policies/SingletonImp.h"
-
/** FactoryHolder holds a factory object of a specific type
*/
template<class T, class Key = std::string>
@@ -34,20 +31,16 @@ class TRINITY_DLL_DECL FactoryHolder
public:
typedef ObjectRegistry<FactoryHolder<T, Key >, Key > FactoryHolderRegistry;
typedef Trinity::Singleton<FactoryHolderRegistry > FactoryHolderRepository;
-
FactoryHolder(Key k) : i_key(k) {}
virtual ~FactoryHolder() {}
inline Key key() const { return i_key; }
-
void RegisterSelf(void) { FactoryHolderRepository::Instance().InsertItem(this, i_key); }
void DeregisterSelf(void) { FactoryHolderRepository::Instance().RemoveItem(this, false); }
-
/// Abstract Factory create method
virtual T* Create(void *data = NULL) const = 0;
private:
Key i_key;
};
-
/** Permissible is a classic way of letting the object decide
* whether how good they handle things. This is not retricted
* to factory selectors.
diff --git a/src/framework/Dynamic/ObjectRegistry.h b/src/framework/Dynamic/ObjectRegistry.h
index 8c2659e8f53..d266c280eb5 100644
--- a/src/framework/Dynamic/ObjectRegistry.h
+++ b/src/framework/Dynamic/ObjectRegistry.h
@@ -17,18 +17,14 @@
* 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_OBJECTREGISTRY_H
#define TRINITY_OBJECTREGISTRY_H
-
#include "Platform/Define.h"
#include "Utilities/UnorderedMap.h"
#include "Policies/Singleton.h"
-
#include <string>
#include <vector>
#include <map>
-
/** ObjectRegistry holds all registry item of the same type
*/
template<class T, class Key = std::string>
@@ -36,14 +32,12 @@ class TRINITY_DLL_DECL ObjectRegistry
{
public:
typedef std::map<Key, T *> RegistryMapType;
-
/// Returns a registry item
const T* GetRegistryItem(Key key) const
{
typename RegistryMapType::const_iterator iter = i_registeredObjects.find(key);
return( iter == i_registeredObjects.end() ? NULL : iter->second );
}
-
/// Inserts a registry item
bool InsertItem(T *obj, Key key, bool override = false)
{
@@ -55,11 +49,9 @@ class TRINITY_DLL_DECL ObjectRegistry
delete iter->second;
i_registeredObjects.erase(iter);
}
-
i_registeredObjects[key] = obj;
return true;
}
-
/// Removes a registry item
void RemoveItem(Key key, bool delete_object = true)
{
@@ -71,13 +63,11 @@ class TRINITY_DLL_DECL ObjectRegistry
i_registeredObjects.erase(iter);
}
}
-
/// Returns true if registry contains an item
bool HasItem(Key key) const
{
return (i_registeredObjects.find(key) != i_registeredObjects.end());
}
-
/// Inefficiently return a vector of registered items
unsigned int GetRegisteredItems(std::vector<Key> &l) const
{
@@ -87,17 +77,14 @@ class TRINITY_DLL_DECL ObjectRegistry
l[sz++] = iter->first;
return i_registeredObjects.size();
}
-
/// Return the map of registered items
RegistryMapType const &GetRegisteredItems() const
{
return i_registeredObjects;
}
-
private:
RegistryMapType i_registeredObjects;
friend class Trinity::OperatorNew<ObjectRegistry<T, Key> >;
-
// protected for friend use since it should be a singleton
ObjectRegistry() {}
~ObjectRegistry()
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;
};
diff --git a/src/framework/Network/SocketDefines.h b/src/framework/Network/SocketDefines.h
index e69f2fb41e0..713562f0376 100644
--- a/src/framework/Network/SocketDefines.h
+++ b/src/framework/Network/SocketDefines.h
@@ -17,23 +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_SOCKETDEFINES_H
#define TRINITY_SOCKETDEFINES_H
-
#ifdef WIN32
-
/* Windows socket definitions
*/
#define FD_SETSIZE 1024
#include <winsock2.h>
#include <Ws2tcpip.h>
-
typedef SOCKET SocketHandle;
typedef fd_set SelectSet;
-
#else
-
/* The unix socket definitions
*/
#include <sys/socket.h>
@@ -41,7 +35,6 @@ typedef fd_set SelectSet;
#ifdef __APPLE_CC__
#include <sys/select.h>
#endif
-
typedef int SocketHandle;
typedef fd_set SelectSet;
#endif
diff --git a/src/framework/Platform/CompilerDefs.h b/src/framework/Platform/CompilerDefs.h
index 691acb2e6d7..863d8bdc2ce 100644
--- a/src/framework/Platform/CompilerDefs.h
+++ b/src/framework/Platform/CompilerDefs.h
@@ -17,15 +17,12 @@
* 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_COMPILERDEFS_H
#define TRINITY_COMPILERDEFS_H
-
#define PLATFORM_WINDOWS 0
#define PLATFORM_UNIX 1
#define PLATFORM_APPLE 2
#define PLATFORM_INTEL 3
-
// must be first (win 64 also define WIN32)
#if defined( _WIN64 )
# define PLATFORM PLATFORM_WINDOWS
@@ -38,12 +35,10 @@
#else
# define PLATFORM PLATFORM_UNIX
#endif
-
#define COMPILER_MICROSOFT 0
#define COMPILER_GNU 1
#define COMPILER_BORLAND 2
#define COMPILER_INTEL 3
-
#ifdef _MSC_VER
# define COMPILER COMPILER_MICROSOFT
#elif defined( __BORLANDC__ )
@@ -55,7 +50,6 @@
#else
# pragma error "FATAL ERROR: Unknown compiler."
#endif
-
#if COMPILER == COMPILER_MICROSOFT
# pragma warning( disable : 4267 ) // conversion from 'size_t' to 'int', possible loss of data
# pragma warning( disable : 4786 ) // identifier was truncated to '255' characters in the debug information
diff --git a/src/framework/Platform/Define.h b/src/framework/Platform/Define.h
index d29a53dbf31..df4d7deaf7d 100644
--- a/src/framework/Platform/Define.h
+++ b/src/framework/Platform/Define.h
@@ -17,20 +17,14 @@
* 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_DEFINE_H
#define TRINITY_DEFINE_H
-
#include <sys/types.h>
-
#include <ace/Basic_Types.h>
#include <ace/ACE_export.h>
-
#include "Platform/CompilerDefs.h"
-
#define TRINITY_LITTLEENDIAN 0
#define TRINITY_BIGENDIAN 1
-
#if !defined(TRINITY_ENDIAN)
# if defined (ACE_BIG_ENDIAN)
# define TRINITY_ENDIAN TRINITY_BIGENDIAN
@@ -38,7 +32,6 @@
# define TRINITY_ENDIAN TRINITY_LITTLEENDIAN
# endif //ACE_BYTE_ORDER
#endif //TRINITY_ENDIAN
-
#if PLATFORM == PLATFORM_WINDOWS
# define TRINITY_EXPORT __declspec(dllexport)
# define TRINITY_LIBRARY_HANDLE HMODULE
@@ -79,7 +72,6 @@
# endif //__APPLE_CC__
# define TRINITY_PATH_MAX PATH_MAX
#endif //PLATFORM
-
#if PLATFORM == PLATFORM_WINDOWS
# ifdef TRINITY_WIN32_DLL_IMPORT
# define TRINITY_DLL_DECL __declspec(dllimport)
@@ -93,7 +85,6 @@
#else //PLATFORM != PLATFORM_WINDOWS
# define TRINITY_DLL_DECL
#endif //PLATFORM
-
#if PLATFORM == PLATFORM_WINDOWS
# define TRINITY_DLL_SPEC __declspec(dllexport)
# ifndef DECLSPEC_NORETURN
@@ -103,7 +94,6 @@
# define TRINITY_DLL_SPEC
# define DECLSPEC_NORETURN
#endif //PLATFORM
-
#if !defined(DEBUG)
# define TRINITY_INLINE inline
#else //DEBUG
@@ -112,7 +102,6 @@
# endif //TRINITY_DEBUG
# define TRINITY_INLINE
#endif //!DEBUG
-
#if COMPILER == COMPILER_GNU
# define ATTR_NORETURN __attribute__((noreturn))
# define ATTR_PRINTF(F,V) __attribute__ ((format (printf, F, V)))
@@ -120,7 +109,6 @@
# define ATTR_NORETURN
# define ATTR_PRINTF(F,V)
#endif //COMPILER == COMPILER_GNU
-
typedef ACE_INT64 int64;
typedef ACE_INT32 int32;
typedef ACE_INT16 int16;
@@ -129,19 +117,15 @@ typedef ACE_UINT64 uint64;
typedef ACE_UINT32 uint32;
typedef ACE_UINT16 uint16;
typedef ACE_UINT8 uint8;
-
#if COMPILER != COMPILER_MICROSOFT
typedef uint16 WORD;
typedef uint32 DWORD;
#endif //COMPILER
-
typedef uint64 OBJECT_HANDLE;
-
#define MaNGOS Trinity
#define MANGOS_DLL_DECL TRINITY_DLL_DECL
#define MANGOS_DLL_SPEC TRINITY_DLL_SPEC
#define GetMangosString GetTrinityString
-
#if defined(MANGOS_DEBUG) || defined(TRINITY_DEBUG)
# ifndef TRINITY_DEBUG
# define TRINITY_DEBUG
@@ -150,19 +134,15 @@ typedef uint64 OBJECT_HANDLE;
# define MANGOS_DEBUG
# endif
#endif
-
#if !defined(DEBUG) && !defined(MANGOS_DEBUG) && !defined(TRINITY_DEBUG)
#define MULTI_THREAD_MAP
#endif
-
#ifdef MULTI_THREAD_MAP
#define MAP_BASED_RAND_GEN
#endif
-
#ifndef CLIENT_VER
#define CLIENT_VER 313
#endif
-
#endif //TRINITY_DEFINE_H
diff --git a/src/framework/Policies/CreationPolicy.h b/src/framework/Policies/CreationPolicy.h
index 91bec9eab37..9bca121b632 100644
--- a/src/framework/Policies/CreationPolicy.h
+++ b/src/framework/Policies/CreationPolicy.h
@@ -17,13 +17,10 @@
* 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_CREATIONPOLICY_H
#define TRINITY_CREATIONPOLICY_H
-
#include <stdlib.h>
#include "Platform/Define.h"
-
namespace Trinity
{
/**
@@ -36,7 +33,6 @@ namespace Trinity
static T* Create(void) { return (new T); }
static void Destroy(T *obj) { delete obj; }
};
-
/**
* LocalStaticCreation policy creates an object on the stack
* the first time call Create.
@@ -63,10 +59,8 @@ namespace Trinity
static MaxAlign si_localStatic;
return new(&si_localStatic) T;
}
-
static void Destroy(T *obj) { obj->~T(); }
};
-
/**
* CreateUsingMalloc by pass the memory manger.
*/
@@ -80,14 +74,12 @@ namespace Trinity
if (!p) return 0;
return new(p) T;
}
-
static void Destroy(T* p)
{
p->~T();
::free(p);
}
};
-
/**
* CreateOnCallBack creates the object base on the call back.
*/
@@ -99,7 +91,6 @@ namespace Trinity
{
return CALL_BACK::createCallBack();
}
-
static void Destroy(T *p)
{
CALL_BACK::destroyCallBack(p);
diff --git a/src/framework/Policies/ObjectLifeTime.cpp b/src/framework/Policies/ObjectLifeTime.cpp
index 852e382a0e9..d86e96a8e87 100644
--- a/src/framework/Policies/ObjectLifeTime.cpp
+++ b/src/framework/Policies/ObjectLifeTime.cpp
@@ -17,17 +17,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
#include <cstdlib>
#include "ObjectLifeTime.h"
-
namespace Trinity
{
extern "C" void external_wrapper(void *p)
{
std::atexit( (void (*)())p );
}
-
void TRINITY_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 86303f889fb..51765d4d4b4 100644
--- a/src/framework/Policies/ObjectLifeTime.h
+++ b/src/framework/Policies/ObjectLifeTime.h
@@ -17,19 +17,14 @@
* 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_OBJECTLIFETIME_H
#define TRINITY_OBJECTLIFETIME_H
-
#include <stdexcept>
#include "Platform/Define.h"
-
typedef void (* Destroyer)(void);
-
namespace Trinity
{
void TRINITY_DLL_SPEC at_exit( void (*func)() );
-
template <class T>
class TRINITY_DLL_DECL ObjectLifeTime
{
@@ -38,11 +33,8 @@ namespace Trinity
{
at_exit( destroyer );
}
-
DECLSPEC_NORETURN static void OnDeadReference(void) ATTR_NORETURN;
-
};
-
template <class T>
void ObjectLifeTime<T>::OnDeadReference(void) // We don't handle Dead Reference for now
{
diff --git a/src/framework/Policies/Singleton.h b/src/framework/Policies/Singleton.h
index 66daaba5a9a..d8d4fd4df20 100644
--- a/src/framework/Policies/Singleton.h
+++ b/src/framework/Policies/Singleton.h
@@ -17,18 +17,14 @@
* 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_SINGLETON_H
#define TRINITY_SINGLETON_H
-
/**
* @brief class Singleton
*/
-
#include "CreationPolicy.h"
#include "ThreadingModel.h"
#include "ObjectLifeTime.h"
-
namespace Trinity
{
template
@@ -42,19 +38,14 @@ namespace Trinity
{
public:
static T& Instance();
-
protected:
Singleton() {};
-
private:
-
// Prohibited actions...this does not prevent hijacking.
Singleton(const Singleton &);
Singleton& operator=(const Singleton &);
-
// Singleton Helpers
static void DestroySingleton();
-
// data structure
typedef typename ThreadingModel::Lock Guard;
static T *si_instance;
diff --git a/src/framework/Policies/SingletonImp.h b/src/framework/Policies/SingletonImp.h
index 89a4738ae22..44f2d184410 100644
--- a/src/framework/Policies/SingletonImp.h
+++ b/src/framework/Policies/SingletonImp.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 TRINITY_SINGLETONIMPL_H
#define TRINITY_SINGLETONIMPL_H
-
#include "Singleton.h"
-
// avoid the using namespace here cuz
// its a .h file afterall
-
template
<
typename T,
@@ -51,10 +47,8 @@ Trinity::Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy >::Instance()
LifeTimePolicy::ScheduleCall(&DestroySingleton);
}
}
-
return *si_instance;
}
-
template
<
typename T,
@@ -69,22 +63,18 @@ Trinity::Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy>::DestroySing
si_instance = NULL;
si_destroyed = true;
}
-
#define INSTANTIATE_SINGLETON_1(TYPE) \
template class TRINITY_DLL_DECL Trinity::Singleton<TYPE, Trinity::SingleThreaded<TYPE>, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >; \
template<> TYPE* Trinity::Singleton<TYPE, Trinity::SingleThreaded<TYPE>, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >::si_instance = 0; \
template<> bool Trinity::Singleton<TYPE, Trinity::SingleThreaded<TYPE>, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >::si_destroyed = false
-
#define INSTANTIATE_SINGLETON_2(TYPE, THREADINGMODEL) \
template class TRINITY_DLL_DECL Trinity::Singleton<TYPE, THREADINGMODEL, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >; \
template<> TYPE* Trinity::Singleton<TYPE, THREADINGMODEL, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >::si_instance = 0; \
template<> bool Trinity::Singleton<TYPE, THREADINGMODEL, Trinity::OperatorNew<TYPE>, Trinity::ObjectLifeTime<TYPE> >::si_destroyed = false
-
#define INSTANTIATE_SINGLETON_3(TYPE, THREADINGMODEL, CREATIONPOLICY ) \
template class TRINITY_DLL_DECL Trinity::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, Trinity::ObjectLifeTime<TYPE> >; \
template<> TYPE* Trinity::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, Trinity::ObjectLifeTime<TYPE> >::si_instance = 0; \
template<> bool Trinity::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, Trinity::ObjectLifeType<TYPE> >::si_destroyed = false
-
#define INSTANTIATE_SINGLETON_4(TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME) \
template class TRINITY_DLL_DECL Trinity::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME >; \
template<> TYPE* Trinity::Singleton<TYPE, THREADINGMODEL, CREATIONPOLICY, OBJECTLIFETIME >::si_instance = 0; \
diff --git a/src/framework/Policies/ThreadingModel.h b/src/framework/Policies/ThreadingModel.h
index a380fe78323..3e0593789b5 100644
--- a/src/framework/Policies/ThreadingModel.h
+++ b/src/framework/Policies/ThreadingModel.h
@@ -17,21 +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 TRINITY_THREADINGMODEL_H
#define TRINITY_THREADINGMODEL_H
-
/**
* @class ThreadingModel<T>
*
*/
-
#include "Platform/Define.h"
-
namespace Trinity
{
inline void Guard(void *) {}
-
template<typename MUTEX> class TRINITY_DLL_DECL GeneralLock
{
public:
@@ -39,7 +34,6 @@ namespace Trinity
{
i_mutex.acquire();
}
-
~GeneralLock()
{
i_mutex.release();
@@ -49,12 +43,10 @@ namespace Trinity
GeneralLock& operator=(const GeneralLock &);
MUTEX &i_mutex;
};
-
template <class T>
class TRINITY_DLL_DECL SingleThreaded
{
public:
-
struct Lock // empty object
{
Lock() {}
@@ -63,40 +55,31 @@ namespace Trinity
{
}
};
-
typedef T VolatileType;
};
-
// object level lockable
template<class T, class MUTEX>
class TRINITY_DLL_DECL ObjectLevelLockable
{
public:
ObjectLevelLockable() : i_mtx() {}
-
friend class Lock;
-
class Lock
{
public:
Lock(ObjectLevelLockable<T, MUTEX> &host) : i_lock(host.i_mtx)
{
}
-
private:
GeneralLock<MUTEX> i_lock;
};
-
typedef volatile T VolatileType;
-
private:
// prevent the compiler creating a copy construct
ObjectLevelLockable(const ObjectLevelLockable<T, MUTEX> &);
ObjectLevelLockable<T, MUTEX>& operator=(const ObjectLevelLockable<T, MUTEX> &);
-
MUTEX i_mtx;
};
-
template<class T, class MUTEX>
class TRINITY_DLL_DECL ClassLevelLockable
{
@@ -104,9 +87,7 @@ namespace Trinity
class Lock;
friend class Lock;
typedef volatile T VolatileType;
-
ClassLevelLockable() {}
-
class Lock
{
public:
@@ -115,15 +96,11 @@ namespace Trinity
Lock() { ClassLevelLockable<T, MUTEX>::si_mtx.acquire(); }
~Lock() { ClassLevelLockable<T, MUTEX>::si_mtx.release(); }
};
-
private:
static MUTEX si_mtx;
};
-
}
-
template<class T, class MUTEX> MUTEX Trinity::ClassLevelLockable<T, MUTEX>::si_mtx;
-
#define INSTANTIATE_CLASS_MUTEX(CTYPE,MUTEX) \
template class TRINITY_DLL_DECL Trinity::ClassLevelLockable<CTYPE, MUTEX >
#endif
diff --git a/src/framework/Utilities/ByteConverter.h b/src/framework/Utilities/ByteConverter.h
index d9282c1787d..38910abfe4d 100644
--- a/src/framework/Utilities/ByteConverter.h
+++ b/src/framework/Utilities/ByteConverter.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_BYTECONVERTER_H
#define TRINITY_BYTECONVERTER_H
-
/** ByteConverter reverse your byte order. This is use
for cross platform where they have different endians.
*/
-
#include<Platform/Define.h>
#include<algorithm>
-
namespace ByteConverter
{
template<size_t T>
@@ -36,16 +32,13 @@ namespace ByteConverter
std::swap(*val, *(val + T - 1));
convert<T - 2>(val + 1);
}
-
template<> inline void convert<0>(char *) {}
template<> inline void convert<1>(char *) {} // ignore central byte
-
template<typename T> inline void apply(T *val)
{
convert<sizeof(T)>((char *)(val));
}
}
-
#if TRINITY_ENDIAN == TRINITY_BIGENDIAN
template<typename T> inline void EndianConvert(T& val) { ByteConverter::apply<T>(&val); }
template<typename T> inline void EndianConvertReverse(T&) { }
@@ -53,14 +46,11 @@ template<typename T> inline void EndianConvertReverse(T&) { }
template<typename T> inline void EndianConvert(T&) { }
template<typename T> inline void EndianConvertReverse(T& val) { ByteConverter::apply<T>(&val); }
#endif
-
template<typename T> void EndianConvert(T*); // will generate link error
template<typename T> void EndianConvertReverse(T*); // will generate link error
-
inline void EndianConvert(uint8&) { }
inline void EndianConvert( int8&) { }
inline void EndianConvertReverse(uint8&) { }
inline void EndianConvertReverse( int8&) { }
-
#endif
diff --git a/src/framework/Utilities/Callback.h b/src/framework/Utilities/Callback.h
index 28c0931e6e7..959a493944f 100644
--- a/src/framework/Utilities/Callback.h
+++ b/src/framework/Utilities/Callback.h
@@ -17,12 +17,9 @@
* 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_CALLBACK_H
#define TRINITY_CALLBACK_H
-
/// ------------ BASE CLASSES ------------
-
namespace Trinity
{
template < class Class, typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void, typename ParamType4 = void >
@@ -43,7 +40,6 @@ namespace Trinity
_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) {}
};
-
template < class Class, typename ParamType1, typename ParamType2, typename ParamType3 >
class _Callback < Class, ParamType1, ParamType2, ParamType3 >
{
@@ -61,7 +57,6 @@ namespace Trinity
_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) {}
};
-
template < class Class, typename ParamType1, typename ParamType2 >
class _Callback < Class, ParamType1, ParamType2 >
{
@@ -78,7 +73,6 @@ namespace Trinity
_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) {}
};
-
template < class Class, typename ParamType1 >
class _Callback < Class, ParamType1 >
{
@@ -94,7 +88,6 @@ namespace Trinity
_Callback(_Callback < Class, ParamType1 > const& cb)
: m_object(cb.m_object), m_method(cb.m_method), m_param1(cb.m_param1) {}
};
-
template < class Class >
class _Callback < Class >
{
@@ -109,9 +102,7 @@ namespace Trinity
_Callback(_Callback < Class > 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 >
class _SCallback
{
@@ -129,7 +120,6 @@ namespace Trinity
_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) {}
};
-
template < typename ParamType1, typename ParamType2, typename ParamType3 >
class _SCallback < ParamType1, ParamType2, ParamType3 >
{
@@ -146,7 +136,6 @@ namespace Trinity
_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) {}
};
-
template < typename ParamType1, typename ParamType2 >
class _SCallback < ParamType1, ParamType2 >
{
@@ -162,7 +151,6 @@ namespace Trinity
_SCallback(_SCallback < ParamType1, ParamType2 > const& cb)
: m_method(cb.m_method), m_param1(cb.m_param1), m_param2(cb.m_param2) {}
};
-
template < typename ParamType1 >
class _SCallback < ParamType1 >
{
@@ -177,7 +165,6 @@ namespace Trinity
_SCallback(_SCallback < ParamType1 > const& cb)
: m_method(cb.m_method), m_param1(cb.m_param1) {}
};
-
template < >
class _SCallback < >
{
@@ -192,9 +179,7 @@ namespace Trinity
: m_method(cb.m_method) {}
};
}
-
/// --------- GENERIC CALLBACKS ----------
-
namespace Trinity
{
class ICallback
@@ -203,7 +188,6 @@ namespace Trinity
virtual void Execute() = 0;
virtual ~ICallback() {}
};
-
template < class CB >
class _ICallback : public CB, public ICallback
{
@@ -211,7 +195,6 @@ namespace Trinity
_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 > >
@@ -222,7 +205,6 @@ namespace Trinity
Callback(Class *object, typename C4::Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3, ParamType4 param4)
: _ICallback< C4 >(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 > >
@@ -233,7 +215,6 @@ namespace Trinity
Callback(Class *object, typename C3::Method method, ParamType1 param1, ParamType2 param2, ParamType3 param3)
: _ICallback< C3 >(C3(object, method, param1, param2, param3)) {}
};
-
template < class Class, typename ParamType1, typename ParamType2 >
class Callback < Class, ParamType1, ParamType2 > :
public _ICallback< _Callback < Class, ParamType1, ParamType2 > >
@@ -244,7 +225,6 @@ namespace Trinity
Callback(Class *object, typename C2::Method method, ParamType1 param1, ParamType2 param2)
: _ICallback< C2 >(C2(object, method, param1, param2)) {}
};
-
template < class Class, typename ParamType1 >
class Callback < Class, ParamType1 > :
public _ICallback< _Callback < Class, ParamType1 > >
@@ -255,7 +235,6 @@ namespace Trinity
Callback(Class *object, typename C1::Method method, ParamType1 param1)
: _ICallback< C1 >(C1(object, method, param1)) {}
};
-
template < class Class >
class Callback < Class > : public _ICallback< _Callback < Class > >
{
@@ -266,11 +245,8 @@ namespace Trinity
: _ICallback< C0 >(C0(object, method)) {}
};
}
-
/// ---------- QUERY CALLBACKS -----------
-
class QueryResult;
-
namespace Trinity
{
class IQueryCallback
@@ -281,7 +257,6 @@ namespace Trinity
virtual void SetResult(QueryResult* result) = 0;
virtual QueryResult* GetResult() = 0;
};
-
template < class CB >
class _IQueryCallback : public CB, public IQueryCallback
{
@@ -291,7 +266,6 @@ namespace Trinity
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 > >
@@ -302,7 +276,6 @@ namespace Trinity
QueryCallback(Class *object, typename QC3::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2, ParamType3 param3)
: _IQueryCallback< QC3 >(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 > >
@@ -313,7 +286,6 @@ namespace Trinity
QueryCallback(Class *object, typename QC2::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2)
: _IQueryCallback< QC2 >(QC2(object, method, result, param1, param2)) {}
};
-
template < class Class, typename ParamType1 >
class QueryCallback < Class, ParamType1 > :
public _IQueryCallback< _Callback < Class, QueryResult*, ParamType1 > >
@@ -324,7 +296,6 @@ namespace Trinity
QueryCallback(Class *object, typename QC1::Method method, QueryResult* result, ParamType1 param1)
: _IQueryCallback< QC1 >(QC1(object, method, result, param1)) {}
};
-
template < class Class >
class QueryCallback < Class > : public _IQueryCallback< _Callback < Class, QueryResult* > >
{
@@ -334,9 +305,7 @@ namespace Trinity
QueryCallback(Class *object, typename QC0::Method method, QueryResult* result)
: _IQueryCallback< QC0 >(QC0(object, method, result)) {}
};
-
/// ---- Statics ----
-
template < typename ParamType1 = void, typename ParamType2 = void, typename ParamType3 = void >
class SQueryCallback :
public _IQueryCallback< _SCallback < QueryResult*, ParamType1, ParamType2, ParamType3 > >
@@ -347,7 +316,6 @@ namespace Trinity
SQueryCallback(typename QC3::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2, ParamType3 param3)
: _IQueryCallback< QC3 >(QC3(method, result, param1, param2, param3)) {}
};
-
template < typename ParamType1, typename ParamType2 >
class SQueryCallback < ParamType1, ParamType2 > :
public _IQueryCallback< _SCallback < QueryResult*, ParamType1, ParamType2 > >
@@ -358,7 +326,6 @@ namespace Trinity
SQueryCallback(typename QC2::Method method, QueryResult* result, ParamType1 param1, ParamType2 param2)
: _IQueryCallback< QC2 >(QC2(method, result, param1, param2)) {}
};
-
template < typename ParamType1 >
class SQueryCallback < ParamType1 > :
public _IQueryCallback< _SCallback < QueryResult*, ParamType1 > >
@@ -369,7 +336,6 @@ namespace Trinity
SQueryCallback(typename QC1::Method method, QueryResult* result, ParamType1 param1)
: _IQueryCallback< QC1 >(QC1(method, result, param1)) {}
};
-
template < >
class SQueryCallback < > : public _IQueryCallback< _SCallback < QueryResult* > >
{
@@ -380,6 +346,5 @@ namespace Trinity
: _IQueryCallback< QC0 >(QC0(method, result)) {}
};
}
-
#endif
diff --git a/src/framework/Utilities/CountedReference/Reference.h b/src/framework/Utilities/CountedReference/Reference.h
index 1e1083e1a66..49156178258 100644
--- a/src/framework/Utilities/CountedReference/Reference.h
+++ b/src/framework/Utilities/CountedReference/Reference.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_REFERENCE_H
#define TRINITY_REFERENCE_H
-
/**
* Referencer<T>
* Referencer is an object that holds a reference holder that hold a reference
@@ -31,12 +29,10 @@
* reference around. Objects can be reference counted in both single threaded
* model and multi-threaded model
*/
-
#include <stdexcept>
#include "Platform/Define.h"
#include "Policies/ThreadingModel.h"
#include "ReferenceHolder.h"
-
template
<
typename T,
@@ -47,52 +43,39 @@ class TRINITY_DLL_DECL Referencer
typedef typename THREADING_MODEL::Lock Lock;
typedef ReferenceHolder<T, THREADING_MODEL> ReferenceeHolder;
public:
-
/// Constructs a referencer.
Referencer(T *ref = NULL);
-
/// Copy constructor
Referencer(const Referencer &obj) : i_holder(NULL) { *this = obj; }
-
/// Destructor
~Referencer();
-
/// Referencee accessor
T* referencee(void) { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
const T* referencee(void) const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
-
//T& referencee(void){ return _referencee(); }
//const T& referencee(void) const { return const_cast<Referencer *>(this)->_referencee(); }
operator T&(void) { return _referencee(); }
operator const T&(void) const { return *const_cast<Referencer *>(this)->_referencee(); }
-
/// cast operators
T* operator*() { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
T const * operator*() const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
-
/// overload operators
T* operator->() { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
const T * operator->() const { return (i_holder == NULL ? NULL : i_holder->i_referencee); }
-
/// operator =
Referencer& operator=(const Referencer &obj);
Referencer& operator=(T *);
-
/// returns true if i_referencee is null
bool isNull(void) const { return i_holder == NULL; }
-
private:
-
T& _referencee(void)
{
if( i_holder == NULL )
throw std::runtime_error("Invalid access to null pointer");
return *i_holder->i_referencee;
}
-
void deReference(ReferenceeHolder *);
void addReference(ReferenceeHolder *);
-
// private data
ReferenceeHolder *i_holder;
};
diff --git a/src/framework/Utilities/CountedReference/ReferenceHolder.h b/src/framework/Utilities/CountedReference/ReferenceHolder.h
index 4cfb7d16ded..80576a8700d 100644
--- a/src/framework/Utilities/CountedReference/ReferenceHolder.h
+++ b/src/framework/Utilities/CountedReference/ReferenceHolder.h
@@ -17,15 +17,12 @@
* 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_REFERENCEHOLDER_H
#define TRINITY_REFERENCEHOLDER_H
-
/** ReferenceHolder holds the actualy referenced obejct as well the refence
count. The ReferenecHolder implements as a policy base object and
will decided by the Reference class to be consnsitent.
*/
-
template
<
typename T,
diff --git a/src/framework/Utilities/CountedReference/ReferenceImpl.h b/src/framework/Utilities/CountedReference/ReferenceImpl.h
index c3116a21cf4..22c31021bd8 100644
--- a/src/framework/Utilities/CountedReference/ReferenceImpl.h
+++ b/src/framework/Utilities/CountedReference/ReferenceImpl.h
@@ -17,12 +17,9 @@
* 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_REFERENCEIMPL_H
#define TRINITY_REFERENCEIMPL_H
-
#include "Reference.h"
-
template
<
typename T,
@@ -37,7 +34,6 @@ Referencer<T, THREADING_MODEL>::Referencer(T *ref)
++i_holder->i_referenceCount;
}
}
-
template
<
typename T,
@@ -49,7 +45,6 @@ Referencer<T, THREADING_MODEL>::~Referencer()
deReference(i_holder);
i_holder = NULL;
}
-
template
<
typename T,
@@ -65,7 +60,6 @@ Referencer<T, THREADING_MODEL>::operator=(const Referencer<T, THREADING_MODEL> &
i_holder = obj.i_holder;
return *this;
}
-
template
<
typename T,
@@ -82,10 +76,8 @@ Referencer<T, THREADING_MODEL>::operator=(T *ref)
i_holder = new ReferenceeHolder(ref);
++i_holder->i_referenceCount;
}
-
return *this;
}
-
template
<
typename T,
@@ -96,25 +88,21 @@ Referencer<T, THREADING_MODEL>::deReference(ReferenceHolder<T, THREADING_MODEL>
{
assert( holder != NULL && holder->i_referenceCount > 0);
bool delete_object = false;
-
{
// The guard is within the scope due to the guard
// must release earlier than expected.
Lock guard(*holder);
Guard(&guard);
-
--holder->i_referenceCount;
if( holder->i_referenceCount == 0 )
delete_object = true;
}
-
if( delete_object )
{
delete holder->i_referencee;
delete holder;
}
}
-
template
<
typename T,
@@ -126,7 +114,6 @@ Referencer<T, THREADING_MODEL>::addReference(ReferenceHolder<T, THREADING_MODEL>
assert( i_holder != NULL );
Lock guard(*holder);
Guard(&guard);
-
++holder->i_referenceCount;
}
#endif
diff --git a/src/framework/Utilities/EventProcessor.cpp b/src/framework/Utilities/EventProcessor.cpp
index 852f84bc4e2..75cc5776602 100644
--- a/src/framework/Utilities/EventProcessor.cpp
+++ b/src/framework/Utilities/EventProcessor.cpp
@@ -17,25 +17,20 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
#include "EventProcessor.h"
-
EventProcessor::EventProcessor()
{
m_time = 0;
m_aborting = false;
}
-
EventProcessor::~EventProcessor()
{
KillAllEvents(true);
}
-
void EventProcessor::Update(uint32 p_time)
{
// update time
m_time += p_time;
-
// main event loop
EventList::iterator i;
while (((i = m_events.begin()) != m_events.end()) && i->first <= m_time)
@@ -43,7 +38,6 @@ void EventProcessor::Update(uint32 p_time)
// get and remove event from queue
BasicEvent* Event = i->second;
m_events.erase(i);
-
if (!Event->to_Abort)
{
if (Event->Execute(m_time, p_time))
@@ -59,41 +53,34 @@ void EventProcessor::Update(uint32 p_time)
}
}
}
-
void EventProcessor::KillAllEvents(bool force)
{
// prevent event insertions
m_aborting = true;
-
// first, abort all existing events
for (EventList::iterator i = m_events.begin(); i != m_events.end();)
{
EventList::iterator i_old = i;
++i;
-
i_old->second->to_Abort = true;
i_old->second->Abort(m_time);
if(force || i_old->second->IsDeletable())
{
delete i_old->second;
-
if(!force) // need per-element cleanup
m_events.erase (i_old);
}
}
-
// fast clear event list (in force case)
if(force)
m_events.clear();
}
-
void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime)
{
if (set_addtime) Event->m_addTime = m_time;
Event->m_execTime = e_time;
m_events.insert(std::pair<uint64, BasicEvent*>(e_time, Event));
}
-
uint64 EventProcessor::CalculateTime(uint64 t_offset)
{
return(m_time + t_offset);
diff --git a/src/framework/Utilities/EventProcessor.h b/src/framework/Utilities/EventProcessor.h
index d0a98c80e30..ef33fb1ce9a 100644
--- a/src/framework/Utilities/EventProcessor.h
+++ b/src/framework/Utilities/EventProcessor.h
@@ -17,16 +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 __EVENTPROCESSOR_H
#define __EVENTPROCESSOR_H
-
#include "Platform/Define.h"
-
#include<map>
-
// Note. All times are in milliseconds here.
-
class BasicEvent
{
public:
@@ -34,32 +29,24 @@ class BasicEvent
virtual ~BasicEvent() // override destructor to perform some actions on event removal
{
};
-
// this method executes when the event is triggered
// return false if event does not want to be deleted
// e_time is execution time, p_time is update interval
virtual bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { return true; }
-
virtual bool IsDeletable() const { return true; } // this event can be safely deleted
-
virtual void Abort(uint64 /*e_time*/) {} // this method executes when the event is aborted
-
bool to_Abort; // set by externals when the event is aborted, aborted events don't execute
// and get Abort call when deleted
-
// these can be used for time offset control
uint64 m_addTime; // time when the event was added to queue, filled by event handler
uint64 m_execTime; // planned time of next execution, filled by event handler
};
-
typedef std::multimap<uint64, BasicEvent*> EventList;
-
class EventProcessor
{
public:
EventProcessor();
~EventProcessor();
-
void Update(uint32 p_time);
void KillAllEvents(bool force);
void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true);
diff --git a/src/framework/Utilities/LinkedList.h b/src/framework/Utilities/LinkedList.h
index 171ff3601e3..0d10d6a0121 100644
--- a/src/framework/Utilities/LinkedList.h
+++ b/src/framework/Utilities/LinkedList.h
@@ -17,40 +17,31 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
#ifndef _LINKEDLIST
#define _LINKEDLIST
-
#include "Common.h"
-
//============================================
class LinkedListHead;
-
class LinkedListElement
{
private:
friend class LinkedListHead;
-
LinkedListElement* iNext;
LinkedListElement* iPrev;
public:
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); }
-
LinkedListElement * next() { return hasNext() ? iNext : NULL; }
LinkedListElement const* next() const { return hasNext() ? iNext : NULL; }
LinkedListElement * prev() { return hasPrev() ? iPrev : NULL; }
LinkedListElement const* prev() const { return hasPrev() ? iPrev : NULL; }
-
LinkedListElement * nocheck_next() { return iNext; }
LinkedListElement const* nocheck_next() const { return iNext; }
LinkedListElement * nocheck_prev() { return iPrev; }
LinkedListElement const* nocheck_prev() const { return iPrev; }
-
void delink()
{
if(isInList())
@@ -58,7 +49,6 @@ class LinkedListElement
iNext->iPrev = iPrev; iPrev->iNext = iNext; iNext = NULL; iPrev = NULL;
}
}
-
void insertBefore(LinkedListElement* pElem)
{
pElem->iNext = this;
@@ -66,7 +56,6 @@ class LinkedListElement
iPrev->iNext = pElem;
iPrev = pElem;
}
-
void insertAfter(LinkedListElement* pElem)
{
pElem->iPrev = this;
@@ -75,9 +64,7 @@ class LinkedListElement
iNext = pElem;
}
};
-
//============================================
-
class LinkedListHead
{
private:
@@ -88,30 +75,23 @@ class LinkedListHead
LinkedListHead()
{
// create empty list
-
iFirst.iNext = &iLast;
iLast.iPrev = &iFirst;
iSize = 0;
}
-
bool isEmpty() const { return(!iFirst.iNext->isInList()); }
-
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); }
-
void insertFirst(LinkedListElement* pElem)
{
iFirst.insertAfter(pElem);
}
-
void insertLast(LinkedListElement* pElem)
{
iLast.insertBefore(pElem);
}
-
uint32 getSize() const
{
if(!iSize)
@@ -128,10 +108,8 @@ class LinkedListHead
else
return iSize;
}
-
void incSize() { ++iSize; }
void decSize() { --iSize; }
-
template<class _Ty>
class Iterator
{
@@ -145,105 +123,85 @@ class LinkedListHead
typedef _Ty& reference;
typedef _Ty const & const_reference;
-
Iterator() : _Ptr(0)
{ // construct with null node pointer
}
-
Iterator(pointer _Pnode) : _Ptr(_Pnode)
{ // construct with node pointer _Pnode
}
-
Iterator& operator=(Iterator const &_Right)
{
return (*this) = _Right._Ptr;
}
-
Iterator& operator=(const_pointer const &_Right)
{
_Ptr = (pointer)_Right;
return (*this);
}
-
reference operator*()
{ // return designated value
return *_Ptr;
}
-
pointer operator->()
{ // return pointer to class object
return _Ptr;
}
-
Iterator& operator++()
{ // preincrement
_Ptr = _Ptr->next();
return (*this);
}
-
Iterator operator++(int)
{ // postincrement
iterator _Tmp = *this;
++*this;
return (_Tmp);
}
-
Iterator& operator--()
{ // predecrement
_Ptr = _Ptr->prev();
return (*this);
}
-
Iterator operator--(int)
{ // postdecrement
iterator _Tmp = *this;
--*this;
return (_Tmp);
}
-
bool operator==(Iterator const &_Right) const
{ // test for iterator equality
return (_Ptr == _Right._Ptr);
}
-
bool operator!=(Iterator const &_Right) const
{ // test for iterator inequality
return (!(*this == _Right));
}
-
bool operator==(pointer const &_Right) const
{ // test for pointer equality
return (_Ptr != _Right);
}
-
bool operator!=(pointer const &_Right) const
{ // test for pointer equality
return (!(*this == _Right));
}
-
bool operator==(const_reference _Right) const
{ // test for reference equality
return (_Ptr == &_Right);
}
-
bool operator!=(const_reference _Right) const
{ // test for reference equality
return (_Ptr != &_Right);
}
-
pointer _Mynode()
{ // return node pointer
return (_Ptr);
}
-
protected:
pointer _Ptr; // pointer to node
};
-
typedef Iterator<LinkedListElement> iterator;
};
-
//============================================
#endif
diff --git a/src/framework/Utilities/LinkedReference/RefManager.h b/src/framework/Utilities/LinkedReference/RefManager.h
index ed580f49ec2..819e7775bf6 100644
--- a/src/framework/Utilities/LinkedReference/RefManager.h
+++ b/src/framework/Utilities/LinkedReference/RefManager.h
@@ -17,31 +17,25 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
#ifndef _REFMANAGER_H
#define _REFMANAGER_H
//=====================================================
-
#include "Utilities/LinkedList.h"
#include "Utilities/LinkedReference/Reference.h"
-
template <class TO, class FROM> class RefManager : public LinkedListHead
{
public:
typedef LinkedListHead::Iterator< Reference<TO, FROM> > iterator;
RefManager() { }
virtual ~RefManager() { clearReferences(); }
-
Reference<TO, FROM>* getFirst() { return ((Reference<TO, FROM>*) LinkedListHead::getFirst()); }
Reference<TO, FROM> const* getFirst() const { return ((Reference<TO, FROM> const*) LinkedListHead::getFirst()); }
Reference<TO, FROM>* getLast() { return ((Reference<TO, FROM>*) LinkedListHead::getLast()); }
Reference<TO, FROM> const* getLast() const { return ((Reference<TO, FROM> const*) LinkedListHead::getLast()); }
-
iterator begin() { return iterator(getFirst()); }
iterator end() { return iterator(NULL); }
iterator rbegin() { return iterator(getLast()); }
iterator rend() { return iterator(NULL); }
-
void clearReferences()
{
LinkedListElement* ref;
@@ -52,7 +46,6 @@ template <class TO, class FROM> class RefManager : public LinkedListHead
}
}
};
-
//=====================================================
#endif
diff --git a/src/framework/Utilities/LinkedReference/Reference.h b/src/framework/Utilities/LinkedReference/Reference.h
index c77d3a2cbdb..7ac5bd4ef3d 100644
--- a/src/framework/Utilities/LinkedReference/Reference.h
+++ b/src/framework/Utilities/LinkedReference/Reference.h
@@ -17,14 +17,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
#ifndef _REFERENCE_H
#define _REFERENCE_H
-
#include "Utilities/LinkedList.h"
-
//=====================================================
-
template <class TO, class FROM> class Reference : public LinkedListElement
{
private:
@@ -33,16 +29,13 @@ template <class TO, class FROM> class Reference : public LinkedListElement
protected:
// Tell our refTo (target) object that we have a link
virtual void targetObjectBuildLink() = 0;
-
// Tell our refTo (taget) object, that the link is cut
virtual void targetObjectDestroyLink() = 0;
-
// Tell our refFrom (source) object, that the link is cut (Target destroyed)
virtual void sourceObjectDestroyLink() = 0;
public:
Reference() { iRefTo = NULL; iRefFrom = NULL; }
virtual ~Reference() {}
-
// Create new link
void link(TO* toObj, FROM* fromObj)
{
@@ -56,39 +49,31 @@ template <class TO, class FROM> class Reference : public LinkedListElement
targetObjectBuildLink();
}
}
-
// 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; }
-
// 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;
}
-
bool isValid() const // Only check the iRefTo
{
return iRefTo != NULL;
}
-
Reference<TO,FROM> * next() { return((Reference<TO,FROM> *) LinkedListElement::next()); }
Reference<TO,FROM> const * next() const { return((Reference<TO,FROM> const *) LinkedListElement::next()); }
Reference<TO,FROM> * prev() { return((Reference<TO,FROM> *) LinkedListElement::prev()); }
Reference<TO,FROM> const * prev() const { return((Reference<TO,FROM> const *) LinkedListElement::prev()); }
-
Reference<TO,FROM> * nocheck_next() { return((Reference<TO,FROM> *) LinkedListElement::nocheck_next()); }
Reference<TO,FROM> const * nocheck_next() const { return((Reference<TO,FROM> const *) LinkedListElement::nocheck_next()); }
Reference<TO,FROM> * nocheck_prev() { return((Reference<TO,FROM> *) LinkedListElement::nocheck_prev()); }
Reference<TO,FROM> const * nocheck_prev() const { return((Reference<TO,FROM> const *) LinkedListElement::nocheck_prev()); }
-
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 07b1ebad3e6..e1f888e1afe 100644
--- a/src/framework/Utilities/TypeList.h
+++ b/src/framework/Utilities/TypeList.h
@@ -17,25 +17,20 @@
* 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_TYPELIST_H
#define TRINITY_TYPELIST_H
-
/*
@struct TypeList
TypeList is the most simple but yet the most powerfull class of all. It holds
at compile time the different type of objects in a linked list.
*/
-
class TypeNull;
-
template<typename HEAD, typename TAIL>
struct TypeList
{
typedef HEAD Head;
typedef TAIL Tail;
};
-
// enough for now.. can be expand at any point in time as needed
#define TYPELIST_1(T1) TypeList<T1,TypeNull>
#define TYPELIST_2(T1, T2) TypeList<T1, TYPELIST_1(T2) >
diff --git a/src/framework/Utilities/UnorderedMap.h b/src/framework/Utilities/UnorderedMap.h
index dd539cc0bda..a93300b197e 100644
--- a/src/framework/Utilities/UnorderedMap.h
+++ b/src/framework/Utilities/UnorderedMap.h
@@ -17,13 +17,10 @@
* 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_UNORDERED_MAP_H
#define TRINITY_UNORDERED_MAP_H
-
#include "Platform/CompilerDefs.h"
#include "Platform/Define.h"
-
#if COMPILER == COMPILER_INTEL
#include <ext/hash_map>
#elif COMPILER == COMPILER_GNU && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3)
@@ -35,7 +32,6 @@
#else
#include <hash_map>
#endif
-
#ifdef _STLPORT_VERSION
#define UNORDERED_MAP std::hash_map
using std::hash_map;
@@ -51,7 +47,6 @@ using std::hash_map;
#define UNORDERED_MAP std::tr1::unordered_map
#elif COMPILER == COMPILER_GNU && __GNUC__ >= 3
#define UNORDERED_MAP __gnu_cxx::hash_map
-
namespace __gnu_cxx
{
template<> struct hash<unsigned long long>
@@ -62,9 +57,7 @@ namespace __gnu_cxx
{
size_t operator()(T * const &__x) const { return (size_t)__x; }
};
-
};
-
#else
#define UNORDERED_MAP std::hash_map
using std::hash_map;