Component::RefType component;
Component *(*pCreateComponent)();
+ component = GetComponent(name);
+
+ if (component.get() != NULL)
+ return component;
+
ConfigObject::RefType componentConfig = m_ConfigHive->GetObject("component", name);
if (componentConfig.get() == NULL) {
component = Component::RefType(pCreateComponent());
component->SetApplication(static_pointer_cast<Application>(shared_from_this()));
+ component->SetConfig(componentConfig);
m_Components[component->GetName()] = component;
- component->Start(componentConfig);
+ component->Start();
return component;
}
+Component::RefType Application::GetComponent(string name)
+{
+ map<string, Component::RefType>::iterator ci = m_Components.find(name);
+
+ if (ci == m_Components.end())
+ return Component::RefType();
+
+ return ci->second;
+}
+
void Application::UnloadComponent(string name)
{
map<string, Component::RefType>::iterator ci = m_Components.find(name);
<PropertyGroup Label="Globals">
<ProjectGuid>{9C92DA90-FD53-43A9-A244-90F2E8AF9677}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
- <RootNamespace>i2base</RootNamespace>
+ <RootNamespace>icinga</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
using namespace icinga;
-void Component::SetApplication(Application::WeakRefType application)
+void Component::SetApplication(const Application::WeakRefType& application)
{
m_Application = application;
}
{
return m_Application.lock();
}
+
+void Component::SetConfig(ConfigObject::RefType componentConfig)
+{
+ m_Config = componentConfig;
+}
+
+ConfigObject::RefType Component::GetConfig(void)
+{
+ return m_Config;
+}
{
private:
Application::WeakRefType m_Application;
+ ConfigObject::RefType m_Config;
public:
typedef shared_ptr<Component> RefType;
typedef weak_ptr<Component> WeakRefType;
- void SetApplication(Application::WeakRefType application);
+ void SetApplication(const Application::WeakRefType& application);
Application::RefType GetApplication(void);
+ void SetConfig(ConfigObject::RefType componentConfig);
+ ConfigObject::RefType GetConfig(void);
+
virtual string GetName(void) = 0;
- virtual void Start(ConfigObject::RefType componentConfig) = 0;
+ virtual void Start(void) = 0;
virtual void Stop(void) = 0;
};