mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-25 10:48:20 +02:00
Make sure Registry<> types are unique.
This commit is contained in:
parent
1b0977a512
commit
494fb90547
@ -96,7 +96,7 @@ private:
|
|||||||
*
|
*
|
||||||
* @ingroup base
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class DynamicTypeRegistry : public Registry<DynamicType::Ptr>
|
class DynamicTypeRegistry : public Registry<DynamicTypeRegistry, DynamicType::Ptr>
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,15 +37,15 @@ namespace icinga
|
|||||||
*
|
*
|
||||||
* @ingroup base
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename U, typename T>
|
||||||
class Registry
|
class Registry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::map<String, T, string_iless> ItemMap;
|
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)
|
void Register(const String& name, const T& item)
|
||||||
@ -82,7 +82,7 @@ public:
|
|||||||
|
|
||||||
void Clear(void)
|
void Clear(void)
|
||||||
{
|
{
|
||||||
typename Registry<T>::ItemMap items;
|
typename Registry<U, T>::ItemMap items;
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_Mutex);
|
boost::mutex::scoped_lock lock(m_Mutex);
|
||||||
@ -125,7 +125,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
mutable boost::mutex m_Mutex;
|
mutable boost::mutex m_Mutex;
|
||||||
typename Registry<T>::ItemMap m_Items;
|
typename Registry<U, T>::ItemMap m_Items;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ private:
|
|||||||
*
|
*
|
||||||
* @ingroup base
|
* @ingroup base
|
||||||
*/
|
*/
|
||||||
class I2_BASE_API ScriptFunctionRegistry : public Registry<ScriptFunction::Ptr>
|
class I2_BASE_API ScriptFunctionRegistry : public Registry<ScriptFunctionRegistry, ScriptFunction::Ptr>
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
Registry<Value> ScriptVariable::m_Registry;
|
Registry<ScriptVariable, Value> ScriptVariable::m_Registry;
|
||||||
|
|
||||||
Value ScriptVariable::Get(const String& name)
|
Value ScriptVariable::Get(const String& name)
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
static void Set(const String& name, const Value& value);
|
static void Set(const String& name, const Value& value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Registry<Value> m_Registry;
|
static Registry<ScriptVariable, Value> m_Registry;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ private:
|
|||||||
void DestroyScanner(void);
|
void DestroyScanner(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
class I2_CONFIG_API ConfigFragmentRegistry : public Registry<String>
|
class I2_CONFIG_API ConfigFragmentRegistry : public Registry<ConfigFragmentRegistry, String>
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -282,20 +282,20 @@ void ConfigType::ValidateArray(const Array::Ptr& array,
|
|||||||
|
|
||||||
void ConfigType::Register(void)
|
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)
|
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)
|
void ConfigType::DiscardTypes(void)
|
||||||
{
|
{
|
||||||
Registry<ConfigType::Ptr>::GetInstance()->Clear();
|
Registry<ConfigType, ConfigType::Ptr>::GetInstance()->Clear();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
void Register(void);
|
void Register(void);
|
||||||
static ConfigType::Ptr GetByName(const String& name);
|
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);
|
static void DiscardTypes(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -75,7 +75,7 @@ private:
|
|||||||
*
|
*
|
||||||
* @ingroup ido
|
* @ingroup ido
|
||||||
*/
|
*/
|
||||||
class DbTypeRegistry : public Registry<DbType::Ptr>
|
class DbTypeRegistry : public Registry<DbTypeRegistry, DbType::Ptr>
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user