mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-03-16 05:55:07 +00:00
refactor(Core/AI): factory functions cleanup (#11779)
This commit is contained in:
committed by
GitHub
parent
02fa20b638
commit
cc52712ac1
@@ -19,33 +19,29 @@
|
||||
#define ACORE_FACTORY_HOLDER
|
||||
|
||||
#include "Define.h"
|
||||
#include "Dynamic/TypeList.h"
|
||||
#include "ObjectRegistry.h"
|
||||
#include "TypeList.h"
|
||||
|
||||
/*
|
||||
* FactoryHolder holds a factory object of a specific type
|
||||
/** FactoryHolder holds a factory object of a specific type
|
||||
*/
|
||||
template<class T, class Key = std::string>
|
||||
template<class T, class O, class Key = std::string>
|
||||
class FactoryHolder
|
||||
{
|
||||
public:
|
||||
typedef ObjectRegistry<FactoryHolder<T, Key >, Key > FactoryHolderRegistry;
|
||||
typedef ObjectRegistry<FactoryHolder<T, O, Key>, Key> FactoryHolderRegistry;
|
||||
|
||||
FactoryHolder(Key k) : i_key(k) { }
|
||||
explicit FactoryHolder(Key const& k) : _key(k) { }
|
||||
virtual ~FactoryHolder() { }
|
||||
inline Key key() const { return i_key; }
|
||||
|
||||
void RegisterSelf(void) { FactoryHolderRegistry::instance()->InsertItem(this, i_key); }
|
||||
void DeregisterSelf(void) { FactoryHolderRegistry::instance()->RemoveItem(this, false); }
|
||||
void RegisterSelf() { FactoryHolderRegistry::instance()->InsertItem(this, _key); }
|
||||
|
||||
/// Abstract Factory create method
|
||||
virtual T* Create(void* data = nullptr) const = 0;
|
||||
virtual T* Create(O* object = nullptr) const = 0;
|
||||
private:
|
||||
Key i_key;
|
||||
Key const _key;
|
||||
};
|
||||
|
||||
/*
|
||||
* Permissible is a classic way of letting the object decide
|
||||
/** Permissible is a classic way of letting the object decide
|
||||
* whether how good they handle things. This is not retricted
|
||||
* to factory selectors.
|
||||
*/
|
||||
@@ -54,7 +50,6 @@ class Permissible
|
||||
{
|
||||
public:
|
||||
virtual ~Permissible() { }
|
||||
virtual int Permit(const T*) const = 0;
|
||||
virtual int32 Permit(T const*) const = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user