Make sure Registry<> types are unique.

This commit is contained in:
Gunnar Beutner 2013-10-10 23:07:05 +02:00
parent 1b0977a512
commit 494fb90547
9 changed files with 17 additions and 17 deletions

View File

@ -96,7 +96,7 @@ private:
*
* @ingroup base
*/
class DynamicTypeRegistry : public Registry<DynamicType::Ptr>
class DynamicTypeRegistry : public Registry<DynamicTypeRegistry, DynamicType::Ptr>
{ };
/**

View File

@ -37,15 +37,15 @@ namespace icinga
*
* @ingroup base
*/
template<typename T>
template<typename U, typename T>
class Registry
{
public:
typedef std::map<String, T, string_iless> ItemMap;
static Registry<T> *GetInstance(void)
static Registry<U, T> *GetInstance(void)
{
return Singleton<Registry<T> >::GetInstance();
return Singleton<Registry<U, T> >::GetInstance();
}
void Register(const String& name, const T& item)
@ -82,7 +82,7 @@ public:
void Clear(void)
{
typename Registry<T>::ItemMap items;
typename Registry<U, T>::ItemMap items;
{
boost::mutex::scoped_lock lock(m_Mutex);
@ -125,7 +125,7 @@ public:
private:
mutable boost::mutex m_Mutex;
typename Registry<T>::ItemMap m_Items;
typename Registry<U, T>::ItemMap m_Items;
};
}

View File

@ -55,7 +55,7 @@ private:
*
* @ingroup base
*/
class I2_BASE_API ScriptFunctionRegistry : public Registry<ScriptFunction::Ptr>
class I2_BASE_API ScriptFunctionRegistry : public Registry<ScriptFunctionRegistry, ScriptFunction::Ptr>
{ };
/**

View File

@ -22,7 +22,7 @@
using namespace icinga;
Registry<Value> ScriptVariable::m_Registry;
Registry<ScriptVariable, Value> ScriptVariable::m_Registry;
Value ScriptVariable::Get(const String& name)
{

View File

@ -39,7 +39,7 @@ public:
static void Set(const String& name, const Value& value);
private:
static Registry<Value> m_Registry;
static Registry<ScriptVariable, Value> m_Registry;
};
}

View File

@ -78,7 +78,7 @@ private:
void DestroyScanner(void);
};
class I2_CONFIG_API ConfigFragmentRegistry : public Registry<String>
class I2_CONFIG_API ConfigFragmentRegistry : public Registry<ConfigFragmentRegistry, String>
{ };
/**

View File

@ -282,20 +282,20 @@ void ConfigType::ValidateArray(const Array::Ptr& array,
void ConfigType::Register(void)
{
Registry<ConfigType::Ptr>::GetInstance()->Register(GetName(), GetSelf());
Registry<ConfigType, ConfigType::Ptr>::GetInstance()->Register(GetName(), GetSelf());
}
ConfigType::Ptr ConfigType::GetByName(const String& name)
{
return Registry<ConfigType::Ptr>::GetInstance()->GetItem(name);
return Registry<ConfigType, ConfigType::Ptr>::GetInstance()->GetItem(name);
}
Registry<ConfigType::Ptr>::ItemMap ConfigType::GetTypes(void)
Registry<ConfigType, ConfigType::Ptr>::ItemMap ConfigType::GetTypes(void)
{
return Registry<ConfigType::Ptr>::GetInstance()->GetItems();
return Registry<ConfigType, ConfigType::Ptr>::GetInstance()->GetItems();
}
void ConfigType::DiscardTypes(void)
{
Registry<ConfigType::Ptr>::GetInstance()->Clear();
Registry<ConfigType, ConfigType::Ptr>::GetInstance()->Clear();
}

View File

@ -54,7 +54,7 @@ public:
void Register(void);
static ConfigType::Ptr GetByName(const String& name);
static Registry<ConfigType::Ptr>::ItemMap GetTypes(void);
static Registry<ConfigType, ConfigType::Ptr>::ItemMap GetTypes(void);
static void DiscardTypes(void);
private:

View File

@ -75,7 +75,7 @@ private:
*
* @ingroup ido
*/
class DbTypeRegistry : public Registry<DbType::Ptr>
class DbTypeRegistry : public Registry<DbTypeRegistry, DbType::Ptr>
{ };
/**