mirror of
https://github.com/mangosfour/server.git
synced 2025-12-27 10:37:02 +00:00
[Sync] Some project sync
This commit is contained in:
parent
b25fa433fe
commit
bbf0020c1a
98 changed files with 5866 additions and 2121 deletions
|
|
@ -1,5 +1,4 @@
|
|||
#
|
||||
# This file is part of the MaNGOS Project. See AUTHORS file for Copyright information
|
||||
# This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -14,7 +13,6 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
set(LIBRARY_NAME framework)
|
||||
|
||||
|
|
@ -102,17 +100,14 @@ source_group("Utilities\\LinkedReference"
|
|||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${ACE_INCLUDE_DIR}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${ACE_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
add_library(${LIBRARY_NAME} STATIC
|
||||
${LIBRARY_SRCS}
|
||||
)
|
||||
|
||||
if(NOT TBB_USE_EXTERNAL)
|
||||
add_dependencies(${LIBRARY_NAME} TBB_Project)
|
||||
endif()
|
||||
if(NOT ACE_USE_EXTERNAL)
|
||||
add_dependencies(${LIBRARY_NAME} ACE_Project)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -30,37 +30,85 @@
|
|||
#include "ObjectRegistry.h"
|
||||
#include "Policies/Singleton.h"
|
||||
|
||||
/** FactoryHolder holds a factory object of a specific type
|
||||
*/
|
||||
template < class T, class Key = std::string >
|
||||
/**
|
||||
* @brief FactoryHolder holds a factory object of a specific type
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL FactoryHolder
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef ObjectRegistry<FactoryHolder<T, Key >, Key > FactoryHolderRegistry;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef MaNGOS::Singleton<FactoryHolderRegistry > FactoryHolderRepository;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param k
|
||||
*/
|
||||
FactoryHolder(Key k) : i_key(k) {}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
virtual ~FactoryHolder() {}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return Key
|
||||
*/
|
||||
inline Key key() const { return i_key; }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void RegisterSelf(void) { FactoryHolderRepository::Instance().InsertItem(this, i_key); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void DeregisterSelf(void) { FactoryHolderRepository::Instance().RemoveItem(this, false); }
|
||||
|
||||
/// Abstract Factory create method
|
||||
/**
|
||||
* @brief Abstract Factory create method
|
||||
*
|
||||
* @param data
|
||||
* @return T
|
||||
*/
|
||||
virtual T* Create(void* data = NULL) const = 0;
|
||||
private:
|
||||
Key i_key;
|
||||
Key i_key; /**< TODO */
|
||||
};
|
||||
|
||||
/** Permissible is a classic way of letting the object decide
|
||||
* whether how good they handle things. This is not retricted
|
||||
* to factory selectors.
|
||||
*/
|
||||
template<class T>
|
||||
/**
|
||||
* @brief Permissible is a classic way of letting the object decide whether how good they handle things.
|
||||
*
|
||||
* This is not retricted to factory selectors.
|
||||
*/
|
||||
class Permissible
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
virtual ~Permissible() {}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
* @return int
|
||||
*/
|
||||
virtual int Permit(const T*) const = 0;
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -33,29 +33,47 @@
|
|||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
/** ObjectRegistry holds all registry item of the same type
|
||||
*/
|
||||
template < class T, class Key = std::string >
|
||||
/**
|
||||
* @brief ObjectRegistry holds all registry item of the same type
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL ObjectRegistry
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef std::map<Key, T*> RegistryMapType;
|
||||
|
||||
/// Returns a registry item
|
||||
/**
|
||||
* @brief Returns a registry item
|
||||
*
|
||||
* @param key
|
||||
* @return const T
|
||||
*/
|
||||
const T* GetRegistryItem(Key key) const
|
||||
{
|
||||
typename RegistryMapType::const_iterator iter = i_registeredObjects.find(key);
|
||||
return (iter == i_registeredObjects.end() ? NULL : iter->second);
|
||||
return(iter == i_registeredObjects.end() ? NULL : iter->second);
|
||||
}
|
||||
|
||||
/// Inserts a registry item
|
||||
/**
|
||||
* @brief Inserts a registry item
|
||||
*
|
||||
* @param obj
|
||||
* @param key
|
||||
* @param replace
|
||||
* @return bool
|
||||
*/
|
||||
bool InsertItem(T* obj, Key key, bool replace = false)
|
||||
{
|
||||
typename RegistryMapType::iterator iter = i_registeredObjects.find(key);
|
||||
if (iter != i_registeredObjects.end())
|
||||
{
|
||||
if (!replace)
|
||||
return false;
|
||||
{ return false; }
|
||||
delete iter->second;
|
||||
i_registeredObjects.erase(iter);
|
||||
}
|
||||
|
|
@ -64,50 +82,76 @@ class MANGOS_DLL_DECL ObjectRegistry
|
|||
return true;
|
||||
}
|
||||
|
||||
/// Removes a registry item
|
||||
/**
|
||||
* @brief Removes a registry item
|
||||
*
|
||||
* @param key
|
||||
* @param delete_object
|
||||
*/
|
||||
void RemoveItem(Key key, bool delete_object = true)
|
||||
{
|
||||
typename RegistryMapType::iterator iter = i_registeredObjects.find(key);
|
||||
if (iter != i_registeredObjects.end())
|
||||
{
|
||||
if (delete_object)
|
||||
delete iter->second;
|
||||
{ delete iter->second; }
|
||||
i_registeredObjects.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if registry contains an item
|
||||
/**
|
||||
* @brief Returns true if registry contains an item
|
||||
*
|
||||
* @param key
|
||||
* @return bool
|
||||
*/
|
||||
bool HasItem(Key key) const
|
||||
{
|
||||
return (i_registeredObjects.find(key) != i_registeredObjects.end());
|
||||
}
|
||||
|
||||
/// Inefficiently return a vector of registered items
|
||||
/**
|
||||
* @brief Inefficiently return a vector of registered items
|
||||
*
|
||||
* @param l
|
||||
* @return unsigned int
|
||||
*/
|
||||
unsigned int GetRegisteredItems(std::vector<Key>& l) const
|
||||
{
|
||||
unsigned int sz = l.size();
|
||||
l.resize(sz + i_registeredObjects.size());
|
||||
for (typename RegistryMapType::const_iterator iter = i_registeredObjects.begin(); iter != i_registeredObjects.end(); ++iter)
|
||||
l[sz++] = iter->first;
|
||||
{ l[sz++] = iter->first; }
|
||||
return i_registeredObjects.size();
|
||||
}
|
||||
|
||||
/// Return the map of registered items
|
||||
/**
|
||||
* @brief Return the map of registered items
|
||||
*
|
||||
* @return const RegistryMapType
|
||||
*/
|
||||
RegistryMapType const& GetRegisteredItems() const
|
||||
{
|
||||
return i_registeredObjects;
|
||||
}
|
||||
|
||||
private:
|
||||
RegistryMapType i_registeredObjects;
|
||||
RegistryMapType i_registeredObjects; /**< TODO */
|
||||
friend class MaNGOS::OperatorNew<ObjectRegistry<T, Key> >;
|
||||
|
||||
// protected for friend use since it should be a singleton
|
||||
/**
|
||||
* @brief protected for friend use since it should be a singleton
|
||||
*
|
||||
*/
|
||||
ObjectRegistry() {}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
~ObjectRegistry()
|
||||
{
|
||||
for (typename RegistryMapType::iterator iter = i_registeredObjects.begin(); iter != i_registeredObjects.end(); ++iter)
|
||||
delete iter->second;
|
||||
{ delete iter->second; }
|
||||
i_registeredObjects.clear();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,17 +25,6 @@
|
|||
#ifndef MANGOS_GRID_H
|
||||
#define MANGOS_GRID_H
|
||||
|
||||
/*
|
||||
@class Grid
|
||||
Grid is a logical segment of the game world represented inside MaNGOS.
|
||||
Grid is bind at compile time to a particular type of object which
|
||||
we call it the object of interested. There are many types of loader,
|
||||
specially, dynamic loader, static loader, or on-demand loader. There's
|
||||
a subtle difference between dynamic loader and on-demand loader but
|
||||
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"
|
||||
|
|
@ -50,6 +39,16 @@ class ACTIVE_OBJECT,
|
|||
class WORLD_OBJECT_TYPES,
|
||||
class GRID_OBJECT_TYPES
|
||||
>
|
||||
/**
|
||||
* @brief Grid is a logical segment of the game world represented inside MaNGOS.
|
||||
*
|
||||
* Grid is bind at compile time to a particular type of object which
|
||||
* we call it the object of interested. There are many types of loader,
|
||||
* specially, dynamic loader, static loader, or on-demand loader. There's
|
||||
* a subtle difference between dynamic loader and on-demand loader but
|
||||
* this is implementation specific to the loader class. From the
|
||||
* Grid's perspective, the loader meets its API requirement is suffice.
|
||||
*/
|
||||
class MANGOS_DLL_DECL Grid
|
||||
{
|
||||
// allows the GridLoader to access its internals
|
||||
|
|
@ -57,78 +56,111 @@ class MANGOS_DLL_DECL Grid
|
|||
|
||||
public:
|
||||
|
||||
/** destructor to clean up its resources. This includes unloading the
|
||||
grid if it has not been unload.
|
||||
*/
|
||||
/**
|
||||
* @brief 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>
|
||||
/**
|
||||
* @brief an object of interested enters the grid
|
||||
*
|
||||
* @param obj
|
||||
* @return bool
|
||||
*/
|
||||
bool AddWorldObject(SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
return i_objects.template insert<SPECIFIC_OBJECT>(obj);
|
||||
}
|
||||
|
||||
/** an object of interested exits the grid
|
||||
*/
|
||||
template<class SPECIFIC_OBJECT>
|
||||
/**
|
||||
* @brief an object of interested exits the grid
|
||||
*
|
||||
* @param obj
|
||||
* @return bool
|
||||
*/
|
||||
bool RemoveWorldObject(SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
return i_objects.template remove<SPECIFIC_OBJECT>(obj);
|
||||
}
|
||||
|
||||
/** Grid visitor for grid objects
|
||||
*/
|
||||
template<class T>
|
||||
/**
|
||||
* @brief Grid visitor for grid objects
|
||||
*
|
||||
* @param TypeContainerVisitor<T
|
||||
* @param visitor
|
||||
*/
|
||||
void Visit(TypeContainerVisitor<T, TypeMapContainer<GRID_OBJECT_TYPES> >& visitor)
|
||||
{
|
||||
visitor.Visit(i_container);
|
||||
}
|
||||
|
||||
/** Grid visitor for world objects
|
||||
*/
|
||||
template<class T>
|
||||
/**
|
||||
* @brief Grid visitor for world objects
|
||||
*
|
||||
* @param TypeContainerVisitor<T
|
||||
* @param visitor
|
||||
*/
|
||||
void Visit(TypeContainerVisitor<T, TypeMapContainer<WORLD_OBJECT_TYPES> >& visitor)
|
||||
{
|
||||
visitor.Visit(i_objects);
|
||||
}
|
||||
|
||||
/** Returns the number of object within the grid.
|
||||
/**
|
||||
* @brief Returns the number of object within the grid.
|
||||
*
|
||||
* @return uint32
|
||||
*/
|
||||
uint32 ActiveObjectsInGrid() const
|
||||
{
|
||||
return m_activeGridObjects.size() + i_objects.template Count<ACTIVE_OBJECT>();
|
||||
}
|
||||
|
||||
/** Inserts a container type object into the grid.
|
||||
*/
|
||||
template<class SPECIFIC_OBJECT>
|
||||
/**
|
||||
* @brief Inserts a container type object into the grid.
|
||||
*
|
||||
* @param obj
|
||||
* @return bool
|
||||
*/
|
||||
bool AddGridObject(SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
if (obj->isActiveObject())
|
||||
m_activeGridObjects.insert(obj);
|
||||
{ m_activeGridObjects.insert(obj); }
|
||||
|
||||
return i_container.template insert<SPECIFIC_OBJECT>(obj);
|
||||
}
|
||||
|
||||
/** Removes a containter type object from the grid
|
||||
*/
|
||||
template<class SPECIFIC_OBJECT>
|
||||
/**
|
||||
* @brief Removes a container type object from the grid
|
||||
*
|
||||
* @param obj
|
||||
* @return bool
|
||||
*/
|
||||
bool RemoveGridObject(SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
if (obj->isActiveObject())
|
||||
m_activeGridObjects.erase(obj);
|
||||
{ m_activeGridObjects.erase(obj); }
|
||||
|
||||
return i_container.template remove<SPECIFIC_OBJECT>(obj);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
TypeMapContainer<GRID_OBJECT_TYPES> i_container;
|
||||
TypeMapContainer<WORLD_OBJECT_TYPES> i_objects;
|
||||
TypeMapContainer<GRID_OBJECT_TYPES> i_container; /**< TODO */
|
||||
TypeMapContainer<WORLD_OBJECT_TYPES> i_objects; /**< TODO */
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef std::set<void*> ActiveGridObjects;
|
||||
ActiveGridObjects m_activeGridObjects;
|
||||
ActiveGridObjects m_activeGridObjects; /**< TODO */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,17 +25,6 @@
|
|||
#ifndef MANGOS_GRIDLOADER_H
|
||||
#define MANGOS_GRIDLOADER_H
|
||||
|
||||
/**
|
||||
@class GridLoader
|
||||
The GridLoader is working in conjuction with the Grid and responsible
|
||||
for loading and unloading object-types (one or more) when objects
|
||||
enters a grid. Unloading is scheduled and might be canceled if
|
||||
an interested object re-enters. GridLoader does not do the actuall
|
||||
loading and unloading but implements as a template pattern that
|
||||
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"
|
||||
|
|
@ -46,29 +35,57 @@ class ACTIVE_OBJECT,
|
|||
class WORLD_OBJECT_TYPES,
|
||||
class GRID_OBJECT_TYPES
|
||||
>
|
||||
/**
|
||||
* @brief The GridLoader is working in conjuction with the Grid and responsible
|
||||
* for loading and unloading object-types (one or more) when objects
|
||||
* enters a grid.
|
||||
* Unloading is scheduled and might be canceled if an interested object re-enters.
|
||||
* GridLoader does not do the actual loading and unloading but implements as a
|
||||
* template pattern that delicate its loading and unloading for the actually
|
||||
* loader and unloader. GridLoader manages the grid (both local and remote).
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL GridLoader
|
||||
{
|
||||
public:
|
||||
|
||||
/** Loads the grid
|
||||
*/
|
||||
template<class LOADER>
|
||||
/**
|
||||
* @brief Loads the grid
|
||||
*
|
||||
* @param Grid<ACTIVE_OBJECT
|
||||
* @param WORLD_OBJECT_TYPES
|
||||
* @param grid
|
||||
* @param loader
|
||||
*/
|
||||
void Load(Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES>& grid, LOADER& loader)
|
||||
{
|
||||
loader.Load(grid);
|
||||
}
|
||||
|
||||
/** Stop the grid
|
||||
*/
|
||||
template<class STOPER>
|
||||
/**
|
||||
* @brief Stop the grid
|
||||
*
|
||||
* @param Grid<ACTIVE_OBJECT
|
||||
* @param WORLD_OBJECT_TYPES
|
||||
* @param grid
|
||||
* @param stoper
|
||||
*/
|
||||
void Stop(Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES>& grid, STOPER& stoper)
|
||||
{
|
||||
stoper.Stop(grid);
|
||||
}
|
||||
|
||||
/** Unloads the grid
|
||||
*/
|
||||
template<class UNLOADER>
|
||||
/**
|
||||
* @brief Unloads the grid
|
||||
*
|
||||
* @param Grid<ACTIVE_OBJECT
|
||||
* @param WORLD_OBJECT_TYPES
|
||||
* @param grid
|
||||
* @param unloader
|
||||
*/
|
||||
void Unload(Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES>& grid, UNLOADER& unloader)
|
||||
{
|
||||
unloader.Unload(grid);
|
||||
|
|
|
|||
|
|
@ -30,25 +30,63 @@
|
|||
template<class OBJECT> class GridReference;
|
||||
|
||||
template<class OBJECT>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class GridRefManager : public RefManager<GridRefManager<OBJECT>, OBJECT>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef LinkedListHead::Iterator< GridReference<OBJECT> > iterator;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return GridReference<OBJECT>
|
||||
*/
|
||||
GridReference<OBJECT>* getFirst()
|
||||
{
|
||||
return (GridReference<OBJECT>*)RefManager<GridRefManager<OBJECT>, OBJECT>::getFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return GridReference<OBJECT>
|
||||
*/
|
||||
GridReference<OBJECT>* getLast()
|
||||
{
|
||||
return (GridReference<OBJECT>*)RefManager<GridRefManager<OBJECT>, OBJECT>::getLast();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return iterator
|
||||
*/
|
||||
iterator begin() { return iterator(getFirst()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return iterator
|
||||
*/
|
||||
iterator end() { return iterator(NULL); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return iterator
|
||||
*/
|
||||
iterator rbegin() { return iterator(getLast()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return iterator
|
||||
*/
|
||||
iterator rend() { return iterator(NULL); }
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,18 +22,26 @@
|
|||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _GRIDREFERENCE_H
|
||||
#define _GRIDREFERENCE_H
|
||||
#ifndef MANGOS_H_GRIDREFERENCE
|
||||
#define MANGOS_H_GRIDREFERENCE
|
||||
|
||||
#include "Utilities/LinkedReference/Reference.h"
|
||||
|
||||
template<class OBJECT> class GridRefManager;
|
||||
|
||||
template<class OBJECT>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_SPEC GridReference : public Reference<GridRefManager<OBJECT>, OBJECT>
|
||||
{
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void targetObjectBuildLink() override
|
||||
{
|
||||
// called from link()
|
||||
|
|
@ -41,13 +49,21 @@ class MANGOS_DLL_SPEC GridReference : public Reference<GridRefManager<OBJECT>, O
|
|||
this->getTarget()->incSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void targetObjectDestroyLink() override
|
||||
{
|
||||
// called from unlink()
|
||||
if (this->isValid())
|
||||
this->getTarget()->decSize();
|
||||
{ this->getTarget()->decSize(); }
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void sourceObjectDestroyLink() override
|
||||
{
|
||||
// called from invalidate()
|
||||
|
|
@ -55,17 +71,29 @@ class MANGOS_DLL_SPEC GridReference : public Reference<GridRefManager<OBJECT>, O
|
|||
}
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
GridReference()
|
||||
: Reference<GridRefManager<OBJECT>, OBJECT>()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
~GridReference()
|
||||
{
|
||||
this->unlink();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return GridReference
|
||||
*/
|
||||
GridReference* next()
|
||||
{
|
||||
return (GridReference*)Reference<GridRefManager<OBJECT>, OBJECT>::next();
|
||||
|
|
|
|||
|
|
@ -25,51 +25,104 @@
|
|||
#ifndef MANGOS_NGRID_H
|
||||
#define MANGOS_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"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
/**
|
||||
* @brief NGrid is nothing more than a wrapper of the Grid with an NxN cells
|
||||
*
|
||||
*/
|
||||
class GridInfo
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
GridInfo()
|
||||
: i_timer(0), i_unloadActiveLockCount(0), i_unloadExplicitLock(false)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param expiry
|
||||
* @param unload
|
||||
*/
|
||||
GridInfo(time_t expiry, bool unload = true)
|
||||
: i_timer(expiry), i_unloadActiveLockCount(0), i_unloadExplicitLock(!unload)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const TimeTracker
|
||||
*/
|
||||
const TimeTracker& getTimeTracker() const { return i_timer; }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool getUnloadLock() const
|
||||
{
|
||||
return i_unloadActiveLockCount || i_unloadExplicitLock;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param on
|
||||
*/
|
||||
void setUnloadExplicitLock(bool on) { i_unloadExplicitLock = on; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void incUnloadActiveLock() { ++i_unloadActiveLockCount; }
|
||||
void decUnloadActiveLock() { if (i_unloadActiveLockCount) --i_unloadActiveLockCount; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void decUnloadActiveLock() { if (i_unloadActiveLockCount) { --i_unloadActiveLockCount; } }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param pTimer
|
||||
*/
|
||||
void setTimer(const TimeTracker& pTimer) { i_timer = pTimer; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param interval
|
||||
*/
|
||||
void ResetTimeTracker(time_t interval) { i_timer.Reset(interval); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param diff
|
||||
*/
|
||||
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
|
||||
TimeTracker i_timer; /**< TODO */
|
||||
uint16 i_unloadActiveLockCount : 16; /**< lock from active object spawn points (prevent clone loading) */
|
||||
bool i_unloadExplicitLock : 1; /**< explicit manual lock or config setting */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GRID_STATE_INVALID = 0,
|
||||
|
|
@ -86,18 +139,42 @@ uint32 N,
|
|||
class WORLD_OBJECT_TYPES,
|
||||
class GRID_OBJECT_TYPES
|
||||
>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL NGrid
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> GridType;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param id
|
||||
* @param x
|
||||
* @param y
|
||||
* @param expiry
|
||||
* @param unload
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return const GridType &operator
|
||||
*/
|
||||
const GridType& operator()(uint32 x, uint32 y) const
|
||||
{
|
||||
assert(x < N);
|
||||
|
|
@ -105,6 +182,13 @@ class MANGOS_DLL_DECL NGrid
|
|||
return i_cells[x][y];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return GridType &operator
|
||||
*/
|
||||
GridType& operator()(uint32 x, uint32 y)
|
||||
{
|
||||
assert(x < N);
|
||||
|
|
@ -112,73 +196,208 @@ class MANGOS_DLL_DECL NGrid
|
|||
return i_cells[x][y];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const uint32
|
||||
*/
|
||||
const uint32& GetGridId() const { return i_gridId; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void SetGridId(const uint32 id) { i_gridId = id; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return grid_state_t
|
||||
*/
|
||||
grid_state_t GetGridState() const { return i_cellstate; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param s
|
||||
*/
|
||||
void SetGridState(grid_state_t s) { i_cellstate = s; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return uint32
|
||||
*/
|
||||
uint32 getX() const { return i_x; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return uint32
|
||||
*/
|
||||
uint32 getY() const { return i_y; }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param GridRefManager<NGrid<N
|
||||
* @param ACTIVE_OBJECT
|
||||
* @param WORLD_OBJECT_TYPES
|
||||
* @param pTo
|
||||
*/
|
||||
void link(GridRefManager<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> >* pTo)
|
||||
{
|
||||
i_Reference.link(pTo, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool isGridObjectDataLoaded() const { return i_GridObjectDataLoaded; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param pLoaded
|
||||
*/
|
||||
void setGridObjectDataLoaded(bool pLoaded) { i_GridObjectDataLoaded = pLoaded; }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return GridInfo
|
||||
*/
|
||||
GridInfo* getGridInfoRef() { return &i_GridInfo; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const TimeTracker
|
||||
*/
|
||||
const TimeTracker& getTimeTracker() const { return i_GridInfo.getTimeTracker(); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool getUnloadLock() const { return i_GridInfo.getUnloadLock(); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param on
|
||||
*/
|
||||
void setUnloadExplicitLock(bool on) { i_GridInfo.setUnloadExplicitLock(on); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void incUnloadActiveLock() { i_GridInfo.incUnloadActiveLock(); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void decUnloadActiveLock() { i_GridInfo.decUnloadActiveLock(); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param interval
|
||||
*/
|
||||
void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param diff
|
||||
*/
|
||||
void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); }
|
||||
|
||||
template<class SPECIFIC_OBJECT>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param obj
|
||||
*/
|
||||
void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
getGridType(x, y).AddWorldObject(obj);
|
||||
}
|
||||
|
||||
template<class SPECIFIC_OBJECT>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param obj
|
||||
*/
|
||||
void RemoveWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
getGridType(x, y).RemoveWorldObject(obj);
|
||||
}
|
||||
|
||||
template<class T, class TT>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param TypeContainerVisitor<T
|
||||
* @param visitor
|
||||
*/
|
||||
void Visit(TypeContainerVisitor<T, TypeMapContainer<TT> >& visitor)
|
||||
{
|
||||
for (uint32 x = 0; x < N; ++x)
|
||||
for (uint32 y = 0; y < N; ++y)
|
||||
i_cells[x][y].Visit(visitor);
|
||||
{ i_cells[x][y].Visit(visitor); }
|
||||
}
|
||||
|
||||
template<class T, class TT>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param TypeContainerVisitor<T
|
||||
* @param visitor
|
||||
*/
|
||||
void Visit(const uint32& x, const uint32& y, TypeContainerVisitor<T, TypeMapContainer<TT> >& visitor)
|
||||
{
|
||||
getGridType(x, y).Visit(visitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return uint32
|
||||
*/
|
||||
uint32 ActiveObjectsInGrid() const
|
||||
{
|
||||
uint32 count = 0;
|
||||
for (uint32 x = 0; x < N; ++x)
|
||||
for (uint32 y = 0; y < N; ++y)
|
||||
count += i_cells[x][y].ActiveObjectsInGrid();
|
||||
{ count += i_cells[x][y].ActiveObjectsInGrid(); }
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_OBJECT>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param obj
|
||||
* @return bool
|
||||
*/
|
||||
bool AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
return getGridType(x, y).AddGridObject(obj);
|
||||
}
|
||||
|
||||
template<class SPECIFIC_OBJECT>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param obj
|
||||
* @return bool
|
||||
*/
|
||||
bool RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT* obj)
|
||||
{
|
||||
return getGridType(x, y).RemoveGridObject(obj);
|
||||
|
|
@ -186,6 +405,13 @@ class MANGOS_DLL_DECL NGrid
|
|||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @return GridType
|
||||
*/
|
||||
GridType& getGridType(const uint32& x, const uint32& y)
|
||||
{
|
||||
assert(x < N);
|
||||
|
|
@ -193,14 +419,14 @@ class MANGOS_DLL_DECL NGrid
|
|||
return i_cells[x][y];
|
||||
}
|
||||
|
||||
uint32 i_gridId;
|
||||
GridInfo i_GridInfo;
|
||||
GridReference<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> > i_Reference;
|
||||
uint32 i_x;
|
||||
uint32 i_y;
|
||||
grid_state_t i_cellstate;
|
||||
GridType i_cells[N][N];
|
||||
bool i_GridObjectDataLoaded;
|
||||
uint32 i_gridId; /**< TODO */
|
||||
GridInfo i_GridInfo; /**< TODO */
|
||||
GridReference<NGrid<N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> > i_Reference; /**< TODO */
|
||||
uint32 i_x; /**< TODO */
|
||||
uint32 i_y; /**< TODO */
|
||||
grid_state_t i_cellstate; /**< TODO */
|
||||
GridType i_cells[N][N]; /**< TODO */
|
||||
bool i_GridObjectDataLoaded; /**< TODO */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -39,41 +39,78 @@
|
|||
#include "GameSystem/GridRefManager.h"
|
||||
|
||||
template<class OBJECT, class KEY_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
struct ContainerUnorderedMap
|
||||
{
|
||||
UNORDERED_MAP<KEY_TYPE, OBJECT*> _element;
|
||||
UNORDERED_MAP<KEY_TYPE, OBJECT*> _element; /**< TODO */
|
||||
};
|
||||
|
||||
template<class KEY_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
struct ContainerUnorderedMap<TypeNull, KEY_TYPE>
|
||||
{
|
||||
};
|
||||
|
||||
template<class H, class T, class KEY_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
struct ContainerUnorderedMap< TypeList<H, T>, KEY_TYPE >
|
||||
{
|
||||
ContainerUnorderedMap<H, KEY_TYPE> _elements;
|
||||
ContainerUnorderedMap<T, KEY_TYPE> _TailElements;
|
||||
ContainerUnorderedMap<H, KEY_TYPE> _elements; /**< TODO */
|
||||
ContainerUnorderedMap<T, KEY_TYPE> _TailElements; /**< TODO */
|
||||
};
|
||||
|
||||
template < class OBJECT_TYPES, class KEY_TYPE = OBJECT_HANDLE >
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class TypeUnorderedMapContainer
|
||||
{
|
||||
public:
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param handle
|
||||
* @param obj
|
||||
* @return bool
|
||||
*/
|
||||
bool insert(KEY_TYPE handle, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
return TypeUnorderedMapContainer::insert(i_elements, handle, obj);
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param handle
|
||||
* @param
|
||||
* @return bool
|
||||
*/
|
||||
bool erase(KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return TypeUnorderedMapContainer::erase(i_elements, handle, (SPECIFIC_TYPE*)NULL);
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param hdl
|
||||
* @param
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
SPECIFIC_TYPE* find(KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return TypeUnorderedMapContainer::find(i_elements, hdl, (SPECIFIC_TYPE*)NULL);
|
||||
|
|
@ -81,11 +118,19 @@ class TypeUnorderedMapContainer
|
|||
|
||||
private:
|
||||
|
||||
ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE> i_elements;
|
||||
ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE> i_elements; /**< TODO */
|
||||
|
||||
// Helpers
|
||||
// Insert helpers
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief Insert helpers
|
||||
*
|
||||
* @param ContainerUnorderedMap<SPECIFIC_TYPE
|
||||
* @param elements
|
||||
* @param handle
|
||||
* @param obj
|
||||
* @return bool
|
||||
*/
|
||||
static bool insert(ContainerUnorderedMap<SPECIFIC_TYPE, KEY_TYPE>& elements, KEY_TYPE handle, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
typename UNORDERED_MAP<KEY_TYPE, SPECIFIC_TYPE*>::iterator i = elements._element.find(handle);
|
||||
|
|
@ -102,18 +147,46 @@ class TypeUnorderedMapContainer
|
|||
}
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerUnorderedMap<TypeNull
|
||||
* @param
|
||||
* @param KEY_TYPE
|
||||
* @param
|
||||
* @return bool
|
||||
*/
|
||||
static bool insert(ContainerUnorderedMap<TypeNull, KEY_TYPE>& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerUnorderedMap<T
|
||||
* @param
|
||||
* @param KEY_TYPE
|
||||
* @param
|
||||
* @return bool
|
||||
*/
|
||||
static bool insert(ContainerUnorderedMap<T, KEY_TYPE>& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class H, class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerUnorderedMap<TypeList<H
|
||||
* @param T>
|
||||
* @param elements
|
||||
* @param handle
|
||||
* @param obj
|
||||
* @return bool
|
||||
*/
|
||||
static bool insert(ContainerUnorderedMap< TypeList<H, T>, KEY_TYPE >& elements, KEY_TYPE handle, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
bool ret = TypeUnorderedMapContainer::insert(elements._elements, handle, obj);
|
||||
|
|
@ -122,28 +195,65 @@ class TypeUnorderedMapContainer
|
|||
|
||||
// Find helpers
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerUnorderedMap<SPECIFIC_TYPE
|
||||
* @param elements
|
||||
* @param hdl
|
||||
* @param
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
static SPECIFIC_TYPE* find(ContainerUnorderedMap<SPECIFIC_TYPE, KEY_TYPE>& elements, KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
typename UNORDERED_MAP<KEY_TYPE, SPECIFIC_TYPE*>::iterator i = elements._element.find(hdl);
|
||||
if (i == elements._element.end())
|
||||
return NULL;
|
||||
{ return NULL; }
|
||||
else
|
||||
return i->second;
|
||||
{ return i->second; }
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerUnorderedMap<TypeNull
|
||||
* @param
|
||||
* @param KEY_TYPE
|
||||
* @param
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
static SPECIFIC_TYPE* find(ContainerUnorderedMap<TypeNull, KEY_TYPE>& /*elements*/, KEY_TYPE /*hdl*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerUnorderedMap<T
|
||||
* @param
|
||||
* @param KEY_TYPE
|
||||
* @param
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
static SPECIFIC_TYPE* find(ContainerUnorderedMap<T, KEY_TYPE>& /*elements*/, KEY_TYPE /*hdl*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class H, class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerUnorderedMap<TypeList<H
|
||||
* @param T>
|
||||
* @param elements
|
||||
* @param hdl
|
||||
* @param
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
static SPECIFIC_TYPE* find(ContainerUnorderedMap< TypeList<H, T>, KEY_TYPE >& elements, KEY_TYPE hdl, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
SPECIFIC_TYPE* ret = TypeUnorderedMapContainer::find(elements._elements, hdl, (SPECIFIC_TYPE*)NULL);
|
||||
|
|
@ -152,6 +262,15 @@ class TypeUnorderedMapContainer
|
|||
|
||||
// Erase helpers
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerUnorderedMap<SPECIFIC_TYPE
|
||||
* @param elements
|
||||
* @param handle
|
||||
* @param
|
||||
* @return bool
|
||||
*/
|
||||
static bool erase(ContainerUnorderedMap<SPECIFIC_TYPE, KEY_TYPE>& elements, KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
elements._element.erase(handle);
|
||||
|
|
@ -160,18 +279,46 @@ class TypeUnorderedMapContainer
|
|||
}
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerUnorderedMap<TypeNull
|
||||
* @param
|
||||
* @param KEY_TYPE
|
||||
* @param
|
||||
* @return bool
|
||||
*/
|
||||
static bool erase(ContainerUnorderedMap<TypeNull, KEY_TYPE>& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerUnorderedMap<T
|
||||
* @param
|
||||
* @param KEY_TYPE
|
||||
* @param
|
||||
* @return bool
|
||||
*/
|
||||
static bool erase(ContainerUnorderedMap<T, KEY_TYPE>& /*elements*/, KEY_TYPE /*handle*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class H, class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerUnorderedMap<TypeList<H
|
||||
* @param T>
|
||||
* @param elements
|
||||
* @param handle
|
||||
* @param
|
||||
* @return bool
|
||||
*/
|
||||
static bool erase(ContainerUnorderedMap< TypeList<H, T>, KEY_TYPE >& elements, KEY_TYPE handle, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
bool ret = TypeUnorderedMapContainer::erase(elements._elements, handle, (SPECIFIC_TYPE*)NULL);
|
||||
|
|
@ -179,68 +326,103 @@ class TypeUnorderedMapContainer
|
|||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* @class ContainerMapList is a mulit-type container for map elements
|
||||
template<class OBJECT>
|
||||
/**
|
||||
* @brief ontainerMapList is a multi-type container for map elements
|
||||
*
|
||||
* By itself its meaningless but collaborate along with TypeContainers,
|
||||
* it become the most powerfully container in the whole system.
|
||||
*
|
||||
*/
|
||||
template<class OBJECT>
|
||||
struct ContainerMapList
|
||||
{
|
||||
GridRefManager<OBJECT> _element;
|
||||
GridRefManager<OBJECT> _element; /**< TODO */
|
||||
};
|
||||
|
||||
template<>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
struct ContainerMapList<TypeNull> /* nothing is in type null */
|
||||
{
|
||||
};
|
||||
|
||||
template<class H, class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
struct ContainerMapList<TypeList<H, T> >
|
||||
{
|
||||
ContainerMapList<H> _elements;
|
||||
ContainerMapList<T> _TailElements;
|
||||
ContainerMapList<H> _elements; /**< TODO */
|
||||
ContainerMapList<T> _TailElements; /**< TODO */
|
||||
};
|
||||
|
||||
#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>
|
||||
/**
|
||||
* @brief 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: holds
|
||||
* objects of different types.
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL TypeMapContainer
|
||||
{
|
||||
public:
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return size_t
|
||||
*/
|
||||
size_t Count() const { return MaNGOS::Count(i_elements, (SPECIFIC_TYPE*)NULL); }
|
||||
|
||||
/// inserts a specific object into the container
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief inserts a specific object into the container
|
||||
*
|
||||
* @param obj
|
||||
* @return bool
|
||||
*/
|
||||
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<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief Removes the object from the container, and returns the removed object
|
||||
*
|
||||
* @param obj
|
||||
* @return bool
|
||||
*/
|
||||
bool remove(SPECIFIC_TYPE* obj)
|
||||
{
|
||||
SPECIFIC_TYPE* t = MaNGOS::Remove(i_elements, obj);
|
||||
return (t != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return ContainerMapList<OBJECT_TYPES>
|
||||
*/
|
||||
ContainerMapList<OBJECT_TYPES>& GetElements() { return i_elements; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const ContainerMapList<OBJECT_TYPES>
|
||||
*/
|
||||
const ContainerMapList<OBJECT_TYPES>& GetElements() const { return i_elements;}
|
||||
|
||||
private:
|
||||
|
||||
ContainerMapList<OBJECT_TYPES> i_elements;
|
||||
ContainerMapList<OBJECT_TYPES> i_elements; /**< TODO */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -38,32 +38,68 @@
|
|||
namespace MaNGOS
|
||||
{
|
||||
/* ContainerMapList Helpers */
|
||||
// count functions
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief count functions
|
||||
*
|
||||
* @param elements
|
||||
* @param
|
||||
* @return size_t
|
||||
*/
|
||||
size_t Count(const ContainerMapList<SPECIFIC_TYPE>& elements, SPECIFIC_TYPE* /*fake*/)
|
||||
{
|
||||
return elements._element.getSize();
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
* @param
|
||||
* @return size_t
|
||||
*/
|
||||
size_t Count(const ContainerMapList<TypeNull>& /*elements*/, SPECIFIC_TYPE* /*fake*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
* @param
|
||||
* @return size_t
|
||||
*/
|
||||
size_t Count(const ContainerMapList<T>& /*elements*/, SPECIFIC_TYPE* /*fake*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerMapList<TypeList<SPECIFIC_TYPE
|
||||
* @param elements
|
||||
* @param fake
|
||||
* @return size_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>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerMapList<TypeList<H
|
||||
* @param elements
|
||||
* @param fake
|
||||
* @return size_t
|
||||
*/
|
||||
size_t Count(const ContainerMapList<TypeList<H, T> >& elements, SPECIFIC_TYPE* fake)
|
||||
{
|
||||
return Count(elements._TailElements, fake);
|
||||
|
|
@ -71,6 +107,13 @@ namespace MaNGOS
|
|||
|
||||
// non-const insert functions
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param elements
|
||||
* @param obj
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
SPECIFIC_TYPE* Insert(ContainerMapList<SPECIFIC_TYPE>& elements, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
// elements._element[hdl] = obj;
|
||||
|
|
@ -79,28 +122,54 @@ namespace MaNGOS
|
|||
}
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
* @param
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
SPECIFIC_TYPE* Insert(ContainerMapList<TypeNull>& /*elements*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// this is a missed
|
||||
template<class SPECIFIC_TYPE, class T>
|
||||
/**
|
||||
* @brief this is a missed
|
||||
*
|
||||
* @param
|
||||
* @param
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
SPECIFIC_TYPE* Insert(ContainerMapList<T>& /*elements*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return NULL; // a missed
|
||||
}
|
||||
|
||||
// Recursion
|
||||
template<class SPECIFIC_TYPE, class H, class T>
|
||||
/**
|
||||
* @brief Recursion
|
||||
*
|
||||
* @param ContainerMapList<TypeList<H
|
||||
* @param elements
|
||||
* @param obj
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
SPECIFIC_TYPE* Insert(ContainerMapList<TypeList<H, T> >& elements, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
SPECIFIC_TYPE* t = Insert(elements._elements, obj);
|
||||
return (t != NULL ? t : Insert(elements._TailElements, obj));
|
||||
}
|
||||
|
||||
// non-const remove method
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief non-const remove method
|
||||
*
|
||||
* @param
|
||||
* @param obj
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
SPECIFIC_TYPE* Remove(ContainerMapList<SPECIFIC_TYPE>& /*elements*/, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
obj->GetGridRef().unlink();
|
||||
|
|
@ -108,19 +177,40 @@ namespace MaNGOS
|
|||
}
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
* @param
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
SPECIFIC_TYPE* Remove(ContainerMapList<TypeNull>& /*elements*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// this is a missed
|
||||
template<class SPECIFIC_TYPE, class T>
|
||||
/**
|
||||
* @brief this is a missed
|
||||
*
|
||||
* @param
|
||||
* @param
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
SPECIFIC_TYPE* Remove(ContainerMapList<T>& /*elements*/, SPECIFIC_TYPE* /*obj*/)
|
||||
{
|
||||
return NULL; // a missed
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE, class T, class H>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ContainerMapList<TypeList<H
|
||||
* @param elements
|
||||
* @param obj
|
||||
* @return SPECIFIC_TYPE
|
||||
*/
|
||||
SPECIFIC_TYPE* Remove(ContainerMapList<TypeList<H, T> >& elements, SPECIFIC_TYPE* obj)
|
||||
{
|
||||
// The head element is bad
|
||||
|
|
|
|||
|
|
@ -37,55 +37,101 @@
|
|||
// forward declaration
|
||||
template<class T, class Y> class TypeContainerVisitor;
|
||||
|
||||
// visitor helper
|
||||
template<class VISITOR, class TYPE_CONTAINER>
|
||||
/**
|
||||
* @brief visitor helper
|
||||
*
|
||||
* @param v
|
||||
* @param c
|
||||
*/
|
||||
void VisitorHelper(VISITOR& v, TYPE_CONTAINER& c)
|
||||
{
|
||||
v.Visit(c);
|
||||
}
|
||||
|
||||
// terminate condition container map list
|
||||
template<class VISITOR>
|
||||
/**
|
||||
* @brief terminate condition container map list
|
||||
*
|
||||
* @param
|
||||
* @param
|
||||
*/
|
||||
void VisitorHelper(VISITOR& /*v*/, ContainerMapList<TypeNull>& /*c*/)
|
||||
{
|
||||
}
|
||||
|
||||
template<class VISITOR, class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param v
|
||||
* @param c
|
||||
*/
|
||||
void VisitorHelper(VISITOR& v, ContainerMapList<T>& c)
|
||||
{
|
||||
v.Visit(c._element);
|
||||
}
|
||||
|
||||
// recursion container map list
|
||||
template<class VISITOR, class H, class T>
|
||||
/**
|
||||
* @brief recursion container map list
|
||||
*
|
||||
* @param v
|
||||
* @param ContainerMapList<TypeList<H
|
||||
* @param c
|
||||
*/
|
||||
void VisitorHelper(VISITOR& v, ContainerMapList<TypeList<H, T> >& c)
|
||||
{
|
||||
VisitorHelper(v, c._elements);
|
||||
VisitorHelper(v, c._TailElements);
|
||||
}
|
||||
|
||||
// for TypeMapContainer
|
||||
template<class VISITOR, class OBJECT_TYPES>
|
||||
/**
|
||||
* @brief for TypeMapContainer
|
||||
*
|
||||
* @param v
|
||||
* @param c
|
||||
*/
|
||||
void VisitorHelper(VISITOR& v, TypeMapContainer<OBJECT_TYPES>& c)
|
||||
{
|
||||
VisitorHelper(v, c.GetElements());
|
||||
}
|
||||
|
||||
template<class VISITOR, class TYPE_CONTAINER>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL TypeContainerVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param v
|
||||
*/
|
||||
TypeContainerVisitor(VISITOR& v)
|
||||
: i_visitor(v)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
void Visit(TYPE_CONTAINER& c)
|
||||
{
|
||||
VisitorHelper(i_visitor, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
void Visit(const TYPE_CONTAINER& c) const
|
||||
{
|
||||
VisitorHelper(i_visitor, c);
|
||||
|
|
@ -93,7 +139,7 @@ class MANGOS_DLL_DECL TypeContainerVisitor
|
|||
|
||||
private:
|
||||
|
||||
VISITOR& i_visitor;
|
||||
VISITOR& i_visitor; /**< TODO */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -44,11 +44,11 @@
|
|||
# define PLATFORM PLATFORM_UNIX
|
||||
#endif
|
||||
|
||||
#define COMPILER_MICROSOFT 0
|
||||
#define COMPILER_GNU 1
|
||||
#define COMPILER_BORLAND 2
|
||||
#define COMPILER_INTEL 3
|
||||
#define COMPILER_CLANG 4
|
||||
#define COMPILER_MICROSOFT 0
|
||||
#define COMPILER_GNU 1
|
||||
#define COMPILER_BORLAND 2
|
||||
#define COMPILER_INTEL 3
|
||||
#define COMPILER_CLANG 4
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define COMPILER COMPILER_MICROSOFT
|
||||
|
|
@ -64,10 +64,10 @@
|
|||
# pragma error "FATAL ERROR: Unknown compiler."
|
||||
#endif
|
||||
|
||||
#if COMPILER == COMPILER_CLANG
|
||||
#define COMPILE_ASSERT(exp, name) _Static_assert((exp), #name)
|
||||
#if defined(__cplusplus) && __cplusplus == 201103L
|
||||
# define COMPILER_HAS_CPP11_SUPPORT 1
|
||||
#else
|
||||
#define COMPILE_ASSERT(exp, name) static_assert((exp), #name)
|
||||
# define COMPILER_HAS_CPP11_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@
|
|||
# endif // ACE_BYTE_ORDER
|
||||
#endif // MANGOS_ENDIAN
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef ACE_SHLIB_HANDLE MANGOS_LIBRARY_HANDLE;
|
||||
|
||||
#define MANGOS_SCRIPT_NAME "mangosscript"
|
||||
|
|
@ -105,23 +109,73 @@ typedef ACE_SHLIB_HANDLE MANGOS_LIBRARY_HANDLE;
|
|||
|
||||
#if COMPILER == COMPILER_GNU || COMPILER == COMPILER_CLANG
|
||||
# define ATTR_NORETURN __attribute__((noreturn))
|
||||
# define ATTR_PRINTF(F,V) __attribute__ ((format (printf, F, V)))
|
||||
#else // COMPILER != COMPILER_GNU
|
||||
# define ATTR_PRINTF(F, V) __attribute__ ((format (printf, F, V)))
|
||||
# define ATTR_DEPRECATED __attribute__((deprecated))
|
||||
#else //COMPILER != COMPILER_GNU
|
||||
# define ATTR_NORETURN
|
||||
# define ATTR_PRINTF(F,V)
|
||||
#endif // COMPILER == COMPILER_GNU
|
||||
# define ATTR_PRINTF(F, V)
|
||||
# define ATTR_DEPRECATED
|
||||
#endif //COMPILER == COMPILER_GNU
|
||||
|
||||
#if COMPILER_HAS_CPP11_SUPPORT
|
||||
# define OVERRIDE override
|
||||
# define FINAL final
|
||||
#else
|
||||
# define OVERRIDE
|
||||
# define FINAL
|
||||
#endif //COMPILER_HAS_CPP11_SUPPORT
|
||||
|
||||
/**
|
||||
* @brief A signed integer of 64 bits
|
||||
*
|
||||
*/
|
||||
typedef ACE_INT64 int64;
|
||||
/**
|
||||
* @brief A signed integer of 32 bits
|
||||
*
|
||||
*/
|
||||
typedef ACE_INT32 int32;
|
||||
/**
|
||||
* @brief A signed integer of 16 bits
|
||||
*
|
||||
*/
|
||||
typedef ACE_INT16 int16;
|
||||
/**
|
||||
* @brief A signed integer of 8 bits
|
||||
*
|
||||
*/
|
||||
typedef ACE_INT8 int8;
|
||||
/**
|
||||
* @brief An unsigned integer of 64 bits
|
||||
*
|
||||
*/
|
||||
typedef ACE_UINT64 uint64;
|
||||
/**
|
||||
* @brief An unsigned integer of 32 bits
|
||||
*
|
||||
*/
|
||||
typedef ACE_UINT32 uint32;
|
||||
/**
|
||||
* @brief An unsigned integer of 16 bits
|
||||
*
|
||||
*/
|
||||
typedef ACE_UINT16 uint16;
|
||||
/**
|
||||
* @brief An unsigned integer of 8 bits
|
||||
*
|
||||
*/
|
||||
typedef ACE_UINT8 uint8;
|
||||
|
||||
#if COMPILER != COMPILER_MICROSOFT
|
||||
/**
|
||||
* @brief An unsigned integer of 16 bits, only for Win
|
||||
*
|
||||
*/
|
||||
typedef uint16 WORD;
|
||||
/**
|
||||
* @brief An unsigned integer of 32 bits, only for Win
|
||||
*
|
||||
*/
|
||||
typedef uint32 DWORD;
|
||||
#endif // COMPILER
|
||||
|
||||
|
|
@ -134,12 +188,21 @@ typedef uint32 DWORD;
|
|||
# define override
|
||||
# define static_assert(a, b) STATIC_ASSERT_WORKAROUND(a, b)
|
||||
# endif
|
||||
#elif COMPILER == COMPILER_CLANG
|
||||
# ifndef __cxx_static_assert
|
||||
# define override
|
||||
# define static_assert(a, b) STATIC_ASSERT_WORKAROUND(a, b)
|
||||
# endif
|
||||
#elif COMPILER == COMPILER_MICROSOFT
|
||||
# if _MSC_VER < 1600
|
||||
# define static_assert(a, b) STATIC_ASSERT_WORKAROUND(a, b)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef uint64 OBJECT_HANDLE;
|
||||
|
||||
enum FieldFormat
|
||||
|
|
|
|||
|
|
@ -30,54 +30,85 @@
|
|||
|
||||
namespace MaNGOS
|
||||
{
|
||||
/**
|
||||
* OperatorNew policy creates an object on the heap using new.
|
||||
*/
|
||||
template<class T>
|
||||
/**
|
||||
* @brief OperatorNew policy creates an object on the heap using new.
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL OperatorNew
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return T
|
||||
*/
|
||||
static T* Create()
|
||||
{
|
||||
return (new T);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param obj
|
||||
*/
|
||||
static void Destroy(T* obj)
|
||||
{
|
||||
delete obj;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* LocalStaticCreation policy creates an object on the stack
|
||||
* the first time call Create.
|
||||
*/
|
||||
template<class T>
|
||||
/**
|
||||
* @brief LocalStaticCreation policy creates an object on the stack the first time call Create.
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL LocalStaticCreation
|
||||
{
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
union MaxAlign
|
||||
{
|
||||
char t_[sizeof(T)];
|
||||
short int shortInt_;
|
||||
int int_;
|
||||
long int longInt_;
|
||||
float float_;
|
||||
double double_;
|
||||
long double longDouble_;
|
||||
char t_[sizeof(T)]; /**< TODO */
|
||||
short int shortInt_; /**< TODO */
|
||||
int int_; /**< TODO */
|
||||
long int longInt_; /**< TODO */
|
||||
float float_; /**< TODO */
|
||||
double double_; /**< TODO */
|
||||
long double longDouble_; /**< TODO */
|
||||
struct Test;
|
||||
int Test::* pMember_;
|
||||
int Test::* pMember_; /**< TODO */
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param Test::pMemberFn_)(int
|
||||
* @return int
|
||||
*/
|
||||
int (Test::*pMemberFn_)(int);
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return T
|
||||
*/
|
||||
static T* Create()
|
||||
{
|
||||
static MaxAlign si_localStatic;
|
||||
return new(&si_localStatic) T;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param obj
|
||||
*/
|
||||
static void Destroy(T* obj)
|
||||
{
|
||||
obj->~T();
|
||||
|
|
@ -88,20 +119,34 @@ namespace MaNGOS
|
|||
* CreateUsingMalloc by pass the memory manger.
|
||||
*/
|
||||
template<class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL CreateUsingMalloc
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return T
|
||||
*/
|
||||
static T* Create()
|
||||
{
|
||||
void* p = malloc(sizeof(T));
|
||||
|
||||
if (!p)
|
||||
return NULL;
|
||||
{ return NULL; }
|
||||
|
||||
return new(p) T;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
static void Destroy(T* p)
|
||||
{
|
||||
p->~T();
|
||||
|
|
@ -109,18 +154,29 @@ namespace MaNGOS
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* CreateOnCallBack creates the object base on the call back.
|
||||
*/
|
||||
template<class T, class CALL_BACK>
|
||||
/**
|
||||
* @brief CreateOnCallBack creates the object base on the call back.
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL CreateOnCallBack
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return T
|
||||
*/
|
||||
static T* Create()
|
||||
{
|
||||
return CALL_BACK::createCallBack();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
static void Destroy(T* p)
|
||||
{
|
||||
CALL_BACK::destroyCallBack(p);
|
||||
|
|
|
|||
|
|
@ -28,26 +28,52 @@
|
|||
#include <stdexcept>
|
||||
#include "Platform/Define.h"
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef void (* Destroyer)(void);
|
||||
|
||||
namespace MaNGOS
|
||||
{
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param (func)()
|
||||
*/
|
||||
void MANGOS_DLL_SPEC at_exit(void (*func)());
|
||||
|
||||
template<class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL ObjectLifeTime
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param (destroyer)()
|
||||
*/
|
||||
static void ScheduleCall(void (*destroyer)())
|
||||
{
|
||||
at_exit(destroyer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
DECLSPEC_NORETURN static void OnDeadReference() ATTR_NORETURN;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
/**
|
||||
* @brief We don't handle Dead Reference for now
|
||||
*
|
||||
*/
|
||||
void ObjectLifeTime<T>::OnDeadReference() // We don't handle Dead Reference for now
|
||||
{
|
||||
throw std::runtime_error("Dead Reference");
|
||||
|
|
|
|||
|
|
@ -42,40 +42,74 @@ namespace MaNGOS
|
|||
class CreatePolicy = MaNGOS::OperatorNew<T>,
|
||||
class LifeTimePolicy = MaNGOS::ObjectLifeTime<T>
|
||||
>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL Singleton
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return T
|
||||
*/
|
||||
static T& Instance();
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
Singleton()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// Prohibited actions...this does not prevent hijacking.
|
||||
/**
|
||||
* @brief Prohibited actions...this does not prevent hijacking.
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
Singleton(const Singleton&);
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
* @return Singleton &operator
|
||||
*/
|
||||
Singleton& operator=(const Singleton&);
|
||||
|
||||
// Singleton Helpers
|
||||
/**
|
||||
* @brief Singleton Helpers
|
||||
*
|
||||
*/
|
||||
static void DestroySingleton();
|
||||
|
||||
// data structure
|
||||
/**
|
||||
* @brief data structure
|
||||
*
|
||||
*/
|
||||
typedef typename ThreadingModel::Lock Guard;
|
||||
static T* si_instance;
|
||||
static bool si_destroyed;
|
||||
static T* si_instance; /**< TODO */
|
||||
static bool si_destroyed; /**< TODO */
|
||||
};
|
||||
|
||||
template<typename T, class ThreadingModel, class CreatePolicy, class LifeTimePolicy>
|
||||
T* Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy>::si_instance = NULL;
|
||||
T* Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy>::si_instance = NULL; /**< TODO */
|
||||
|
||||
template<typename T, class ThreadingModel, class CreatePolicy, class LifeTimePolicy>
|
||||
bool Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy>::si_destroyed = false;
|
||||
bool Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy>::si_destroyed = false; /**< TODO */
|
||||
|
||||
template<typename T, class ThreadingModel, class CreatePolicy, class LifeTimePolicy>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return T &MaNGOS::Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy>
|
||||
*/
|
||||
T& MaNGOS::Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy>::Instance()
|
||||
{
|
||||
if (!si_instance)
|
||||
|
|
@ -100,6 +134,10 @@ namespace MaNGOS
|
|||
}
|
||||
|
||||
template<typename T, class ThreadingModel, class CreatePolicy, class LifeTimePolicy>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void MaNGOS::Singleton<T, ThreadingModel, CreatePolicy, LifeTimePolicy>::DestroySingleton()
|
||||
{
|
||||
CreatePolicy::Destroy(si_instance);
|
||||
|
|
|
|||
|
|
@ -35,16 +35,29 @@
|
|||
namespace MaNGOS
|
||||
{
|
||||
template<typename MUTEX>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL GeneralLock
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param m
|
||||
*/
|
||||
GeneralLock(MUTEX& m)
|
||||
: i_mutex(m)
|
||||
{
|
||||
i_mutex.acquire();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
~GeneralLock()
|
||||
{
|
||||
i_mutex.release();
|
||||
|
|
@ -52,36 +65,77 @@ namespace MaNGOS
|
|||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
GeneralLock(const GeneralLock&);
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
* @return GeneralLock &operator
|
||||
*/
|
||||
GeneralLock& operator=(const GeneralLock&);
|
||||
MUTEX& i_mutex;
|
||||
MUTEX& i_mutex; /**< TODO */
|
||||
};
|
||||
|
||||
template<class T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL SingleThreaded
|
||||
{
|
||||
public:
|
||||
|
||||
struct Lock // empty object
|
||||
/**
|
||||
* @brief empty object
|
||||
*
|
||||
*/
|
||||
struct Lock
|
||||
{
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
Lock()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
Lock(const T&)
|
||||
{
|
||||
}
|
||||
|
||||
Lock(const SingleThreaded<T>&) // for single threaded we ignore this
|
||||
/**
|
||||
* @brief for single threaded we ignore this
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
Lock(const SingleThreaded<T>&)
|
||||
{
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<class T, class MUTEX>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL ObjectLevelLockable
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
ObjectLevelLockable()
|
||||
: i_mtx()
|
||||
{
|
||||
|
|
@ -89,10 +143,20 @@ namespace MaNGOS
|
|||
|
||||
friend class Lock;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class Lock
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ObjectLevelLockable<T
|
||||
* @param host
|
||||
*/
|
||||
Lock(ObjectLevelLockable<T, MUTEX>& host)
|
||||
: i_lock(host.i_mtx)
|
||||
{
|
||||
|
|
@ -100,48 +164,91 @@ namespace MaNGOS
|
|||
|
||||
private:
|
||||
|
||||
GeneralLock<MUTEX> i_lock;
|
||||
GeneralLock<MUTEX> i_lock; /**< TODO */
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// prevent the compiler creating a copy construct
|
||||
/**
|
||||
* @brief prevent the compiler creating a copy construct
|
||||
*
|
||||
* @param ObjectLevelLockable<T
|
||||
* @param
|
||||
*/
|
||||
ObjectLevelLockable(const ObjectLevelLockable<T, MUTEX>&);
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ObjectLevelLockable<T
|
||||
* @param
|
||||
* @return ObjectLevelLockable<T, MUTEX>
|
||||
*/
|
||||
ObjectLevelLockable<T, MUTEX>& operator=(const ObjectLevelLockable<T, MUTEX>&);
|
||||
|
||||
MUTEX i_mtx;
|
||||
MUTEX i_mtx; /**< TODO */
|
||||
};
|
||||
|
||||
template<class T, class MUTEX>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class MANGOS_DLL_DECL ClassLevelLockable
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
ClassLevelLockable()
|
||||
{
|
||||
}
|
||||
|
||||
friend class Lock;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class Lock
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
Lock(const T& /*host*/)
|
||||
{
|
||||
ClassLevelLockable<T, MUTEX>::si_mtx.acquire();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param ClassLevelLockable<T
|
||||
* @param
|
||||
*/
|
||||
Lock(const ClassLevelLockable<T, MUTEX>&)
|
||||
{
|
||||
ClassLevelLockable<T, MUTEX>::si_mtx.acquire();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
Lock()
|
||||
{
|
||||
ClassLevelLockable<T, MUTEX>::si_mtx.acquire();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
~Lock()
|
||||
{
|
||||
ClassLevelLockable<T, MUTEX>::si_mtx.release();
|
||||
|
|
@ -150,12 +257,12 @@ namespace MaNGOS
|
|||
|
||||
private:
|
||||
|
||||
static MUTEX si_mtx;
|
||||
static MUTEX si_mtx; /**< TODO */
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<class T, class MUTEX> MUTEX MaNGOS::ClassLevelLockable<T, MUTEX>::si_mtx;
|
||||
template<class T, class MUTEX> MUTEX MaNGOS::ClassLevelLockable<T, MUTEX>::si_mtx; /**< TODO */
|
||||
|
||||
#define INSTANTIATE_CLASS_MUTEX(CTYPE, MUTEX) \
|
||||
template class MANGOS_DLL_DECL MaNGOS::ClassLevelLockable<CTYPE, MUTEX>
|
||||
|
|
|
|||
|
|
@ -25,26 +25,47 @@
|
|||
#ifndef MANGOS_BYTECONVERTER_H
|
||||
#define MANGOS_BYTECONVERTER_H
|
||||
|
||||
/** ByteConverter reverse your byte order. This is use
|
||||
for cross platform where they have different endians.
|
||||
/**
|
||||
* ByteConverter reverse your byte order. This is used for cross platform
|
||||
* where they have different endians.
|
||||
*/
|
||||
|
||||
#include <Platform/Define.h>
|
||||
#include "Platform/Define.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace ByteConverter
|
||||
{
|
||||
template<size_t T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param val
|
||||
*/
|
||||
inline void convert(char* val)
|
||||
{
|
||||
std::swap(*val, *(val + T - 1));
|
||||
convert < T - 2 > (val + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
template<> inline void convert<0>(char*) {}
|
||||
template<> inline void convert<1>(char*) {} // ignore central byte
|
||||
/**
|
||||
* @brief ignore central byte
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
template<> inline void convert<1>(char*) {}
|
||||
|
||||
template<typename T>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param val
|
||||
*/
|
||||
inline void apply(T* val)
|
||||
{
|
||||
convert<sizeof(T)>((char*)(val));
|
||||
|
|
@ -52,19 +73,59 @@ namespace ByteConverter
|
|||
}
|
||||
|
||||
#if MANGOS_ENDIAN == MANGOS_BIGENDIAN
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param val
|
||||
*/
|
||||
template<typename T> inline void EndianConvert(T& val) { ByteConverter::apply<T>(&val); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
template<typename T> inline void EndianConvertReverse(T&) { }
|
||||
#else
|
||||
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
|
||||
/**
|
||||
* @brief will generate link error
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
template<typename T> void EndianConvert(T*);
|
||||
/**
|
||||
* @brief will generate link error
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
template<typename T> void EndianConvertReverse(T*);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
inline void EndianConvert(uint8&) { }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
inline void EndianConvert(int8&) { }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
inline void EndianConvertReverse(uint8&) { }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
inline void EndianConvertReverse(int8&) { }
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -82,19 +82,19 @@ void EventProcessor::KillAllEvents(bool force)
|
|||
delete i_old->second;
|
||||
|
||||
if (!force) // need per-element cleanup
|
||||
m_events.erase(i_old);
|
||||
{ m_events.erase(i_old); }
|
||||
}
|
||||
}
|
||||
|
||||
// fast clear event list (in force case)
|
||||
if (force)
|
||||
m_events.clear();
|
||||
{ m_events.clear(); }
|
||||
}
|
||||
|
||||
void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime)
|
||||
{
|
||||
if (set_addtime)
|
||||
Event->m_addTime = m_time;
|
||||
{ Event->m_addTime = m_time; }
|
||||
|
||||
Event->m_execTime = e_time;
|
||||
m_events.insert(std::pair<uint64, BasicEvent*>(e_time, Event));
|
||||
|
|
|
|||
|
|
@ -22,64 +22,127 @@
|
|||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __EVENTPROCESSOR_H
|
||||
#define __EVENTPROCESSOR_H
|
||||
#ifndef MANGOS_H_EVENTPROCESSOR
|
||||
#define MANGOS_H_EVENTPROCESSOR
|
||||
|
||||
#include "Platform/Define.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
// Note. All times are in milliseconds here.
|
||||
|
||||
/**
|
||||
* @brief Note. All times are in milliseconds here.
|
||||
*
|
||||
*/
|
||||
class BasicEvent
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
BasicEvent()
|
||||
: to_Abort(false)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~BasicEvent() // override destructor to perform some actions on event removal
|
||||
/**
|
||||
* @brief override destructor to perform some actions on event removal
|
||||
*
|
||||
*/
|
||||
virtual ~BasicEvent()
|
||||
{
|
||||
};
|
||||
|
||||
// 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
|
||||
|
||||
/**
|
||||
* @brief this method executes when the event is triggered
|
||||
*
|
||||
* @param uint64 e_time is execution time
|
||||
* @param uint32 p_time is update interval
|
||||
* @return bool return false if event does not want to be deleted
|
||||
*/
|
||||
virtual bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { return true; }
|
||||
|
||||
virtual bool IsDeletable() const { return true; } // this event can be safely deleted
|
||||
/**
|
||||
* @brief this event can be safely deleted
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
virtual bool IsDeletable() const { return true; }
|
||||
|
||||
virtual void Abort(uint64 /*e_time*/) {} // this method executes when the event is aborted
|
||||
/**
|
||||
* @brief this method executes when the event is aborted
|
||||
*
|
||||
* @param uint64
|
||||
*/
|
||||
virtual void Abort(uint64 /*e_time*/) {}
|
||||
|
||||
bool to_Abort; // set by externals when the event is aborted, aborted events don't execute
|
||||
// and get Abort call when deleted
|
||||
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
|
||||
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 */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef std::multimap<uint64, BasicEvent*> EventList;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class EventProcessor
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
EventProcessor();
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
~EventProcessor();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param p_time
|
||||
*/
|
||||
void Update(uint32 p_time);
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param force
|
||||
*/
|
||||
void KillAllEvents(bool force);
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param Event
|
||||
* @param e_time
|
||||
* @param set_addtime
|
||||
*/
|
||||
void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true);
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param t_offset
|
||||
* @return uint64
|
||||
*/
|
||||
uint64 CalculateTime(uint64 t_offset);
|
||||
|
||||
protected:
|
||||
|
||||
uint64 m_time;
|
||||
EventList m_events;
|
||||
bool m_aborting;
|
||||
uint64 m_time; /**< TODO */
|
||||
EventList m_events; /**< TODO */
|
||||
bool m_aborting; /**< TODO */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,34 +30,105 @@
|
|||
//============================================
|
||||
class LinkedListHead;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class LinkedListElement
|
||||
{
|
||||
private:
|
||||
|
||||
friend class LinkedListHead;
|
||||
|
||||
LinkedListElement* iNext;
|
||||
LinkedListElement* iPrev;
|
||||
LinkedListElement* iNext; /**< TODO */
|
||||
LinkedListElement* iPrev; /**< TODO */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
LinkedListElement() { iNext = NULL; iPrev = NULL; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
~LinkedListElement() { delink(); }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool hasNext() const { return (iNext->iNext != NULL); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool hasPrev() const { return (iPrev->iPrev != NULL); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool isInList() const { return (iNext != NULL && iPrev != NULL); }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return LinkedListElement
|
||||
*/
|
||||
LinkedListElement* next() { return hasNext() ? iNext : NULL; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const LinkedListElement
|
||||
*/
|
||||
LinkedListElement const* next() const { return hasNext() ? iNext : NULL; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return LinkedListElement
|
||||
*/
|
||||
LinkedListElement* prev() { return hasPrev() ? iPrev : NULL; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const LinkedListElement
|
||||
*/
|
||||
LinkedListElement const* prev() const { return hasPrev() ? iPrev : NULL; }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return LinkedListElement
|
||||
*/
|
||||
LinkedListElement* nocheck_next() { return iNext; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const LinkedListElement
|
||||
*/
|
||||
LinkedListElement const* nocheck_next() const { return iNext; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return LinkedListElement
|
||||
*/
|
||||
LinkedListElement* nocheck_prev() { return iPrev; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const LinkedListElement
|
||||
*/
|
||||
LinkedListElement const* nocheck_prev() const { return iPrev; }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void delink()
|
||||
{
|
||||
if (isInList())
|
||||
|
|
@ -69,6 +140,11 @@ class LinkedListElement
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param pElem
|
||||
*/
|
||||
void insertBefore(LinkedListElement* pElem)
|
||||
{
|
||||
pElem->iNext = this;
|
||||
|
|
@ -77,6 +153,11 @@ class LinkedListElement
|
|||
iPrev = pElem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param pElem
|
||||
*/
|
||||
void insertAfter(LinkedListElement* pElem)
|
||||
{
|
||||
pElem->iPrev = this;
|
||||
|
|
@ -88,16 +169,24 @@ class LinkedListElement
|
|||
|
||||
//============================================
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class LinkedListHead
|
||||
{
|
||||
private:
|
||||
|
||||
LinkedListElement iFirst;
|
||||
LinkedListElement iLast;
|
||||
uint32 iSize;
|
||||
LinkedListElement iFirst; /**< TODO */
|
||||
LinkedListElement iLast; /**< TODO */
|
||||
uint32 iSize; /**< TODO */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
LinkedListHead()
|
||||
{
|
||||
// create empty list
|
||||
|
|
@ -107,24 +196,64 @@ class LinkedListHead
|
|||
iSize = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
bool isEmpty() const { return (!iFirst.iNext->isInList()); }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return LinkedListElement
|
||||
*/
|
||||
LinkedListElement* getFirst() { return (isEmpty() ? NULL : iFirst.iNext); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const LinkedListElement
|
||||
*/
|
||||
LinkedListElement const* getFirst() const { return (isEmpty() ? NULL : iFirst.iNext); }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return LinkedListElement
|
||||
*/
|
||||
LinkedListElement* getLast() { return (isEmpty() ? NULL : iLast.iPrev); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const LinkedListElement
|
||||
*/
|
||||
LinkedListElement const* getLast() const { return (isEmpty() ? NULL : iLast.iPrev); }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param pElem
|
||||
*/
|
||||
void insertFirst(LinkedListElement* pElem)
|
||||
{
|
||||
iFirst.insertAfter(pElem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param pElem
|
||||
*/
|
||||
void insertLast(LinkedListElement* pElem)
|
||||
{
|
||||
iLast.insertBefore(pElem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return uint32
|
||||
*/
|
||||
uint32 getSize() const
|
||||
{
|
||||
if (!iSize)
|
||||
|
|
@ -141,62 +270,141 @@ class LinkedListHead
|
|||
return result;
|
||||
}
|
||||
else
|
||||
return iSize;
|
||||
{ return iSize; }
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void incSize() { ++iSize; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void decSize() { --iSize; }
|
||||
|
||||
template<class _Ty>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class Iterator
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef _Ty value_type;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef ptrdiff_t difference_type;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef ptrdiff_t distance_type;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef _Ty* pointer;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef _Ty const* const_pointer;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef _Ty& reference;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef _Ty const& const_reference;
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
Iterator()
|
||||
: _Ptr(0)
|
||||
{
|
||||
// construct with null node pointer
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param _Pnode
|
||||
*/
|
||||
Iterator(pointer _Pnode)
|
||||
: _Ptr(_Pnode)
|
||||
{
|
||||
// construct with node pointer _Pnode
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param _Right
|
||||
* @return Iterator &operator
|
||||
*/
|
||||
Iterator& operator=(Iterator const& _Right)
|
||||
{
|
||||
return (*this) = _Right._Ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param _Right
|
||||
* @return Iterator &operator
|
||||
*/
|
||||
Iterator& operator=(const_pointer const& _Right)
|
||||
{
|
||||
_Ptr = (pointer)_Right;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return reference operator
|
||||
*/
|
||||
reference operator*()
|
||||
{
|
||||
// return designated value
|
||||
return *_Ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return pointer operator ->
|
||||
*/
|
||||
pointer operator->()
|
||||
{
|
||||
// return pointer to class object
|
||||
return _Ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return Iterator &operator
|
||||
*/
|
||||
Iterator& operator++()
|
||||
{
|
||||
// preincrement
|
||||
|
|
@ -204,6 +412,12 @@ class LinkedListHead
|
|||
return (*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param int
|
||||
* @return Iterator operator
|
||||
*/
|
||||
Iterator operator++(int)
|
||||
{
|
||||
// postincrement
|
||||
|
|
@ -212,6 +426,11 @@ class LinkedListHead
|
|||
return (_Tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return Iterator &operator
|
||||
*/
|
||||
Iterator& operator--()
|
||||
{
|
||||
// predecrement
|
||||
|
|
@ -219,6 +438,12 @@ class LinkedListHead
|
|||
return (*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param int
|
||||
* @return Iterator operator
|
||||
*/
|
||||
Iterator operator--(int)
|
||||
{
|
||||
// postdecrement
|
||||
|
|
@ -227,42 +452,83 @@ class LinkedListHead
|
|||
return (_Tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param _Right
|
||||
* @return bool operator
|
||||
*/
|
||||
bool operator==(Iterator const& _Right) const
|
||||
{
|
||||
// test for iterator equality
|
||||
return (_Ptr == _Right._Ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param _Right
|
||||
* @return bool operator
|
||||
*/
|
||||
bool operator!=(Iterator const& _Right) const
|
||||
{
|
||||
// test for iterator inequality
|
||||
return (!(*this == _Right));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param _Right
|
||||
* @return bool operator
|
||||
*/
|
||||
bool operator==(pointer const& _Right) const
|
||||
{
|
||||
// test for pointer equality
|
||||
return (_Ptr != _Right);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param _Right
|
||||
* @return bool operator
|
||||
*/
|
||||
bool operator!=(pointer const& _Right) const
|
||||
{
|
||||
// test for pointer equality
|
||||
return (!(*this == _Right));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param _Right
|
||||
* @return bool operator
|
||||
*/
|
||||
bool operator==(const_reference _Right) const
|
||||
{
|
||||
// test for reference equality
|
||||
return (_Ptr == &_Right);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param _Right
|
||||
* @return bool operator
|
||||
*/
|
||||
bool operator!=(const_reference _Right) const
|
||||
{
|
||||
// test for reference equality
|
||||
return (_Ptr != &_Right);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return pointer
|
||||
*/
|
||||
pointer _Mynode()
|
||||
{
|
||||
// return node pointer
|
||||
|
|
@ -271,9 +537,13 @@ class LinkedListHead
|
|||
|
||||
protected:
|
||||
|
||||
pointer _Ptr; // pointer to node
|
||||
pointer _Ptr; /**< pointer to node */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef Iterator<LinkedListElement> iterator;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _REFMANAGER_H
|
||||
#define _REFMANAGER_H
|
||||
#ifndef MANGOS_H_REFMANAGER
|
||||
#define MANGOS_H_REFMANAGER
|
||||
|
||||
//=====================================================
|
||||
|
||||
|
|
@ -31,24 +31,84 @@
|
|||
#include "Utilities/LinkedReference/Reference.h"
|
||||
|
||||
template <class TO, class FROM>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class RefManager : public LinkedListHead
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef LinkedListHead::Iterator<Reference<TO, FROM> > iterator;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
RefManager() {}
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
virtual ~RefManager() { clearReferences(); }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return Reference<TO, FROM>
|
||||
*/
|
||||
Reference<TO, FROM>* getFirst() { return ((Reference<TO, FROM>*) LinkedListHead::getFirst()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const Reference<TO, FROM>
|
||||
*/
|
||||
Reference<TO, FROM> const* getFirst() const { return ((Reference<TO, FROM> const*) LinkedListHead::getFirst()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return Reference<TO, FROM>
|
||||
*/
|
||||
Reference<TO, FROM>* getLast() { return ((Reference<TO, FROM>*) LinkedListHead::getLast()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const Reference<TO, FROM>
|
||||
*/
|
||||
Reference<TO, FROM> const* getLast() const { return ((Reference<TO, FROM> const*) LinkedListHead::getLast()); }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return iterator
|
||||
*/
|
||||
iterator begin() { return iterator(getFirst()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return iterator
|
||||
*/
|
||||
iterator end() { return iterator(NULL); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return iterator
|
||||
*/
|
||||
iterator rbegin() { return iterator(getLast()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return iterator
|
||||
*/
|
||||
iterator rend() { return iterator(NULL); }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void clearReferences()
|
||||
{
|
||||
LinkedListElement* ref;
|
||||
|
|
|
|||
|
|
@ -22,47 +22,73 @@
|
|||
* and lore are copyrighted by Blizzard Entertainment, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _REFERENCE_H
|
||||
#define _REFERENCE_H
|
||||
#ifndef MANGOS_H_REFERENCE
|
||||
#define MANGOS_H_REFERENCE
|
||||
|
||||
#include "Utilities/LinkedList.h"
|
||||
|
||||
//=====================================================
|
||||
|
||||
template<class TO, class FROM>
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
class Reference : public LinkedListElement
|
||||
{
|
||||
private:
|
||||
|
||||
TO* iRefTo;
|
||||
FROM* iRefFrom;
|
||||
TO* iRefTo; /**< TODO */
|
||||
FROM* iRefFrom; /**< TODO */
|
||||
|
||||
protected:
|
||||
|
||||
// Tell our refTo (target) object that we have a link
|
||||
/**
|
||||
* @brief Tell our refTo (target) object that we have a link
|
||||
*
|
||||
*/
|
||||
virtual void targetObjectBuildLink() = 0;
|
||||
|
||||
// Tell our refTo (taget) object, that the link is cut
|
||||
/**
|
||||
* @brief 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)
|
||||
/**
|
||||
* @brief Tell our refFrom (source) object, that the link is cut (Target destroyed)
|
||||
*
|
||||
*/
|
||||
virtual void sourceObjectDestroyLink() = 0;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
Reference()
|
||||
: iRefTo(NULL), iRefFrom(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
virtual ~Reference() {}
|
||||
|
||||
// Create new link
|
||||
/**
|
||||
* @brief Create new link
|
||||
*
|
||||
* @param toObj
|
||||
* @param fromObj
|
||||
*/
|
||||
void link(TO* toObj, FROM* fromObj)
|
||||
{
|
||||
assert(fromObj); // fromObj MUST not be NULL
|
||||
if (isValid())
|
||||
unlink();
|
||||
{ unlink(); }
|
||||
|
||||
if (toObj != NULL)
|
||||
{
|
||||
|
|
@ -72,8 +98,13 @@ 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
|
||||
/**
|
||||
* @brief 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();
|
||||
|
|
@ -82,8 +113,13 @@ class Reference : public LinkedListElement
|
|||
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
|
||||
/**
|
||||
* @brief 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();
|
||||
|
|
@ -91,24 +127,84 @@ class Reference : public LinkedListElement
|
|||
iRefTo = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return Reference<TO, FROM>
|
||||
*/
|
||||
Reference<TO, FROM>* next() { return((Reference<TO, FROM>*) LinkedListElement::next()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const Reference<TO, FROM>
|
||||
*/
|
||||
Reference<TO, FROM> const* next() const { return((Reference<TO, FROM> const*) LinkedListElement::next()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return Reference<TO, FROM>
|
||||
*/
|
||||
Reference<TO, FROM>* prev() { return((Reference<TO, FROM>*) LinkedListElement::prev()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const Reference<TO, FROM>
|
||||
*/
|
||||
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()); }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return Reference<TO, FROM>
|
||||
*/
|
||||
Reference<TO, FROM>* nocheck_next() { return((Reference<TO, FROM>*) LinkedListElement::nocheck_next()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const Reference<TO, FROM>
|
||||
*/
|
||||
Reference<TO, FROM> const* nocheck_next() const { return((Reference<TO, FROM> const*) LinkedListElement::nocheck_next()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return Reference<TO, FROM>
|
||||
*/
|
||||
Reference<TO, FROM>* nocheck_prev() { return((Reference<TO, FROM>*) LinkedListElement::nocheck_prev()); }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return const Reference<TO, FROM>
|
||||
*/
|
||||
Reference<TO, FROM> const* nocheck_prev() const { return((Reference<TO, FROM> const*) LinkedListElement::nocheck_prev()); }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return TO *operator ->
|
||||
*/
|
||||
TO* operator->() const { return iRefTo; }
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return TO
|
||||
*/
|
||||
TO* getTarget() const { return iRefTo; }
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @return FROM
|
||||
*/
|
||||
FROM* getSource() const { return iRefFrom; }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -25,18 +25,26 @@
|
|||
#ifndef MANGOS_TYPELIST_H
|
||||
#define MANGOS_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>
|
||||
/**
|
||||
* @brief 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.
|
||||
*
|
||||
*/
|
||||
struct TypeList
|
||||
{
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef HEAD Head;
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef TAIL Tail;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -96,9 +96,14 @@ HASH_NAMESPACE_END
|
|||
# define HASH_NAMESPACE_END }
|
||||
using std::hash_map;
|
||||
using std::hash_set;
|
||||
#elif COMPILER == COMPILER_CLANG
|
||||
#elif COMPILER == COMPILER_CLANG && defined(__FreeBSD__)
|
||||
# define UNORDERED_MAP std::unordered_map
|
||||
# define UNORDERED_SET std::unordered_set
|
||||
# define HASH_NAMESPACE_START namespace std { namespace __1 {
|
||||
# define HASH_NAMESPACE_END } }
|
||||
#elif COMPILER == COMPILER_CLANG
|
||||
# define UNORDERED_MAP std::tr1::unordered_map
|
||||
# define UNORDERED_SET std::tr1::unordered_set
|
||||
# define HASH_NAMESPACE_START namespace std { namespace tr1 {
|
||||
# define HASH_NAMESPACE_END } }
|
||||
#elif COMPILER == COMPILER_GNU && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue