mirror of https://github.com/Icinga/icinga2.git
Made IComponent::GetConfig() usable in IComponent::Start().
Fixes #3200
This commit is contained in:
parent
bd37c357d1
commit
e55aa712b5
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue