Made IComponent::GetConfig() usable in IComponent::Start().

Fixes #3200
This commit is contained in:
Gunnar Beutner 2012-09-28 10:39:28 +02:00
parent bd37c357d1
commit e55aa712b5
4 changed files with 23 additions and 4 deletions

View File

@ -94,8 +94,6 @@ Component::Component(const Dictionary::Ptr& properties)
throw; throw;
} }
impl->m_Config = this;
impl->Start();
m_Impl = impl; m_Impl = impl;
} }
@ -108,6 +106,16 @@ Component::~Component(void)
m_Impl->Stop(); 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. * Adds a directory to the component search path.
* *
@ -129,7 +137,7 @@ void Component::AddSearchDir(const String& componentDirectory)
*/ */
DynamicObject::Ptr IComponent::GetConfig(void) const 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; DynamicObject::Ptr GetConfig(void) const;
private: private:
DynamicObject *m_Config; /**< The configuration object for this DynamicObject::WeakPtr m_Config; /**< The configuration object for this
component. */ component. */
friend class Component; friend class Component;
@ -62,6 +62,8 @@ public:
Component(const Dictionary::Ptr& properties); Component(const Dictionary::Ptr& properties);
~Component(void); ~Component(void);
virtual void Start(void);
static void AddSearchDir(const String& componentDirectory); static void AddSearchDir(const String& componentDirectory);
private: private:

View File

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

View File

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