Merge branch 'master' of git.icinga.org:icinga2

This commit is contained in:
Michael Friedrich 2012-09-28 10:37:58 +02:00
commit eaf74cad8f
4 changed files with 23 additions and 4 deletions

View File

@ -94,8 +94,6 @@ Component::Component(const Dictionary::Ptr& properties)
throw;
}
impl->m_Config = this;
impl->Start();
m_Impl = impl;
}
@ -108,6 +106,16 @@ Component::~Component(void)
m_Impl->Stop();
}
/**
* Starts the component. Called when the DynamicObject is fully
* constructed/registered.
*/
void Component::Start(void)
{
m_Impl->m_Config = GetSelf();
m_Impl->Start();
}
/**
* Adds a directory to the component search path.
*
@ -129,7 +137,7 @@ void Component::AddSearchDir(const String& componentDirectory)
*/
DynamicObject::Ptr IComponent::GetConfig(void) const
{
return m_Config->GetSelf();
return m_Config.lock();
}
/**

View File

@ -41,7 +41,7 @@ protected:
DynamicObject::Ptr GetConfig(void) const;
private:
DynamicObject *m_Config; /**< The configuration object for this
DynamicObject::WeakPtr m_Config; /**< The configuration object for this
component. */
friend class Component;
@ -62,6 +62,8 @@ public:
Component(const Dictionary::Ptr& properties);
~Component(void);
virtual void Start(void);
static void AddSearchDir(const String& componentDirectory);
private:

View File

@ -272,6 +272,13 @@ void DynamicObject::Register(void)
ti.first->second.insert(make_pair(GetName(), GetSelf()));
OnRegistered(GetSelf());
Start();
}
void DynamicObject::Start(void)
{
/* Nothing to do here. */
}
void DynamicObject::Unregister(void)

View File

@ -119,6 +119,8 @@ public:
void Register(void);
void Unregister(void);
virtual void Start(void);
static DynamicObject::Ptr GetObject(const String& type, const String& name);
static pair<TypeMap::iterator, TypeMap::iterator> GetTypes(void);
static pair<NameMap::iterator, NameMap::iterator> GetObjects(const String& type);