2012-03-31 15:18:09 +02:00
|
|
|
#include "i2-base.h"
|
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2012-04-04 10:04:38 +02:00
|
|
|
ConfigObject::ConfigObject(const string& type, const string& name)
|
|
|
|
{
|
|
|
|
m_Type = type;
|
|
|
|
m_Name = name;
|
2012-04-20 14:20:25 +02:00
|
|
|
m_Replicated = false;
|
2012-04-04 10:04:38 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 20:50:35 +02:00
|
|
|
void ConfigObject::SetHive(const ConfigHive::WeakPtr& hive)
|
2012-03-31 15:18:09 +02:00
|
|
|
{
|
2012-04-20 13:49:04 +02:00
|
|
|
if (m_Hive.lock())
|
|
|
|
throw InvalidArgumentException();
|
|
|
|
|
2012-03-31 15:18:09 +02:00
|
|
|
m_Hive = hive;
|
2012-04-20 13:49:04 +02:00
|
|
|
OnPropertyChanged += bind_weak(&ConfigObject::PropertyChangedHandler, shared_from_this());
|
2012-03-31 15:18:09 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 20:50:35 +02:00
|
|
|
ConfigHive::WeakPtr ConfigObject::GetHive(void) const
|
2012-03-31 15:18:09 +02:00
|
|
|
{
|
|
|
|
return m_Hive;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigObject::SetName(const string& name)
|
|
|
|
{
|
|
|
|
m_Name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
string ConfigObject::GetName(void) const
|
|
|
|
{
|
|
|
|
return m_Name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigObject::SetType(const string& type)
|
|
|
|
{
|
|
|
|
m_Type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
string ConfigObject::GetType(void) const
|
|
|
|
{
|
|
|
|
return m_Type;
|
|
|
|
}
|
|
|
|
|
2012-04-20 14:20:25 +02:00
|
|
|
void ConfigObject::SetReplicated(bool replicated)
|
|
|
|
{
|
|
|
|
m_Replicated = replicated;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ConfigObject::GetReplicated(void) const
|
|
|
|
{
|
|
|
|
return m_Replicated;
|
|
|
|
}
|
|
|
|
|
2012-04-20 13:49:04 +02:00
|
|
|
int ConfigObject::PropertyChangedHandler(const DictionaryPropertyChangedEventArgs dpcea)
|
2012-03-31 15:18:09 +02:00
|
|
|
{
|
2012-04-02 20:50:35 +02:00
|
|
|
ConfigHive::Ptr hive = m_Hive.lock();
|
2012-04-04 10:04:38 +02:00
|
|
|
if (hive) {
|
2012-04-20 13:49:04 +02:00
|
|
|
hive->GetCollection(m_Type)->OnPropertyChanged(dpcea);
|
|
|
|
hive->OnPropertyChanged(dpcea);
|
2012-03-31 15:18:09 +02:00
|
|
|
}
|
|
|
|
|
2012-04-20 13:49:04 +02:00
|
|
|
return 0;
|
2012-03-31 15:18:09 +02:00
|
|
|
}
|