*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
This commit is contained in:
1 parent
f21f47005d
commit
26b5e033ff
2257 files changed
+750
-103852
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user