Added preliminary version of the dynamic object framework.

This commit is contained in:
Gunnar Beutner 2012-05-25 11:10:11 +02:00
parent 3f708fce21
commit 04aaf2f354
23 changed files with 690 additions and 34 deletions

View File

@ -112,7 +112,7 @@ void ConfigObject::SetReplicated(bool replicated)
*
* @returns Whether this object was replicated.
*/
bool ConfigObject::GetReplicated(void) const
bool ConfigObject::IsReplicated(void) const
{
return m_Replicated;
}

View File

@ -50,7 +50,7 @@ public:
string GetType(void) const;
void SetReplicated(bool replicated);
bool GetReplicated(void) const;
bool IsReplicated(void) const;
void Commit(void);

View File

@ -57,6 +57,27 @@ public:
return true;
}
/**
* Retrieves a value from the dictionary.
*
* @param key The key.
* @param[out] value Pointer to the value.
* @returns true if the value was retrieved, false otherwise.
*/
bool GetProperty(string key, Dictionary::Ptr *value)
{
Object::Ptr object;
if (!GetProperty(key, &object))
return false;
*value = dynamic_pointer_cast<Dictionary>(object);
if (!*value)
throw InvalidCastException();
return true;
}
/**
* Sets a value in the dictionary.
*

View File

@ -55,6 +55,7 @@ void TcpSocket::Bind(string service, int family)
/**
* Creates a socket and binds it to the specified node and service.
*
* @param node The node.
* @param service The service.
* @param family The address family for the socket.
*/

View File

@ -64,6 +64,18 @@ long Variant::GetInteger(void) const
return m_IntegerValue;
}
/**
* Retrieves the variant's value as a bool.
*
* @returns The variant's value as a bool.
*/
long Variant::GetBool(void) const
{
Convert(VariantInteger);
return (m_IntegerValue != 0);
}
/**
* Retrieves the variant's value as a string.
*
@ -108,6 +120,16 @@ Variant::operator long(void) const
return GetInteger();
}
/**
* Retrieves the variant's value as a bool.
*
* @returns The variant's value as a bool.
*/
Variant::operator bool(void) const
{
return GetBool();
}
/**
* Retrieves the variant's value as a string.
*

View File

@ -50,6 +50,9 @@ public:
inline Variant(int value)
: m_Type(VariantInteger), m_IntegerValue(value) { }
inline Variant(bool value)
: m_Type(VariantInteger), m_IntegerValue(value ? 1 : 0) { }
inline Variant(long value)
: m_Type(VariantInteger), m_IntegerValue(value) { }
@ -66,12 +69,14 @@ public:
VariantType GetType(void) const;
long GetInteger(void) const;
long GetBool(void) const;
string GetString(void) const;
Object::Ptr GetObject(void) const;
bool IsEmpty(void) const;
operator long(void) const;
operator bool(void) const;
operator string(void) const;
operator Object::Ptr(void) const;

View File

@ -219,7 +219,7 @@ int ConfigRpcComponent::RemoteObjectRemovedHandler(const NewRequestEventArgs& ea
if (!object)
return 0;
if (object->GetReplicated())
if (object->IsReplicated())
configHive->RemoveObject(object);
return 0;

View File

@ -1,10 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="i2-demo.h" />
<ClInclude Include="democomponent.h" />
<ClInclude Include="democomponent.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="i2-demo.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="democomponent.cpp" />
<Filter Include="Headerdateien">
<UniqueIdentifier>{11a495bf-a705-4766-b3d3-9b5db266a6ef}</UniqueIdentifier>
</Filter>
<Filter Include="Quelldateien">
<UniqueIdentifier>{1fb6337f-a17f-46ea-9316-2d800a94b53d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="democomponent.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -1,12 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="discoverycomponent.cpp" />
<ClCompile Include="discoverymessage.cpp" />
<ClCompile Include="discoverycomponent.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="discoverymessage.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="discoverycomponent.h" />
<ClInclude Include="i2-discovery.h" />
<ClInclude Include="discoverymessage.h" />
<ClInclude Include="discoverycomponent.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="i2-discovery.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="discoverymessage.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Headerdateien">
<UniqueIdentifier>{53341f7e-6bad-4cf1-92cf-be906efe1704}</UniqueIdentifier>
</Filter>
<Filter Include="Quelldateien">
<UniqueIdentifier>{c7b2deba-743b-4449-ae46-0b7ba1b1350a}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View File

@ -254,12 +254,12 @@ int DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
{
Endpoint::Ptr endpoint = nrea.Sender;
if (endpoint->GetReceivedWelcome())
if (endpoint->HasReceivedWelcome())
return 0;
endpoint->SetReceivedWelcome(true);
if (endpoint->GetSentWelcome()) {
if (endpoint->HasSentWelcome()) {
EventArgs ea;
ea.Source = endpoint;
endpoint->OnSessionEstablished(ea);
@ -277,7 +277,7 @@ int DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
*/
void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
{
if (endpoint->GetSentWelcome())
if (endpoint->HasSentWelcome())
return;
// we assume the other component _always_ wants
@ -289,7 +289,7 @@ void DiscoveryComponent::FinishDiscoverySetup(Endpoint::Ptr endpoint)
endpoint->SetSentWelcome(true);
if (endpoint->GetReceivedWelcome()) {
if (endpoint->HasReceivedWelcome()) {
EventArgs ea;
ea.Source = endpoint;
endpoint->OnSessionEstablished(ea);

94
dyn/dyn.vcxproj Normal file
View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="dynamicdictionary.h" />
<ClInclude Include="dynamicobject.h" />
<ClInclude Include="i2-dyn.h" />
<ClInclude Include="objectspace.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dynamicdictionary.cpp" />
<ClCompile Include="dynamicobject.cpp" />
<ClCompile Include="objectspace.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>dyn</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)\base;$(IncludePath)</IncludePath>
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)\base;$(IncludePath)</IncludePath>
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>base.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>base.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

22
dyn/dynamicdictionary.cpp Normal file
View File

@ -0,0 +1,22 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#include "i2-dyn.h"
using namespace icinga;

79
dyn/dynamicdictionary.h Normal file
View File

@ -0,0 +1,79 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#ifndef DYNAMICDICTIONARY_H
#define DYNAMICDICTIONARY_H
namespace icinga
{
enum DynamicDictionaryOperator
{
OperatorSet,
OperatorPlus,
OperatorMinus,
OperatorMultiply,
OperatorDivide
};
struct DynamicDictionaryValue
{
Variant Value;
DynamicDictionaryOperator Operator;
};
class DynamicDictionary : public Object
{
public:
typedef shared_ptr<DynamicDictionary> Ptr;
typedef weak_ptr<DynamicDictionary> WeakPtr;
DynamicDictionary(void);
DynamicDictionary(Dictionary::Ptr serializedDictionary);
void AddParent(DynamicDictionary::Ptr parent);
void ClearParents(void);
template<typename T>
bool GetProperty(string name, T *value, DynamicDictionaryOperator *op) const
{
map<string, DynamicDictionaryValue>::const_iterator di;
di = m_Values.find(name);
if (di == m_Values.end())
return false;
return di->second.op;
}
template<typename T>
void SetProperty(string name, const T& value, DynamicDictionaryOperator op);
Dictionary::Ptr ToFlatDictionary(void) const;
Dictionary::Ptr Serialize(void);
private:
set<DynamicDictionary::Ptr> m_Parents;
map<string, DynamicDictionaryValue> m_Values;
};
}
#endif /* DYNAMICDICTIONARY_H */

90
dyn/dynamicobject.cpp Normal file
View File

@ -0,0 +1,90 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#include "i2-dyn.h"
using namespace icinga;
DynamicDictionary::Ptr DynamicObject::GetProperties(void) const
{
return m_Properties;
}
void DynamicObject::SetProperties(DynamicDictionary::Ptr properties)
{
m_Properties = properties;
Dictionary::Ptr resolvedProperties = properties->ToFlatDictionary();
Reload(resolvedProperties);
}
string DynamicObject::GetName(void) const
{
return m_Name;
}
void DynamicObject::SetName(string name)
{
m_Name = name;
}
string DynamicObject::GetType(void) const
{
return m_Type;
}
void DynamicObject::SetType(string type)
{
m_Type = type;
}
bool DynamicObject::IsLocal(void) const
{
return m_Local;
}
void DynamicObject::SetLocal(bool value)
{
m_Local = value;
}
bool DynamicObject::IsAbstract(void) const
{
return m_Abstract;
}
void DynamicObject::SetAbstract(bool value)
{
m_Abstract = value;
}
void DynamicObject::Commit(void)
{
// TODO: link properties to parent objects
Dictionary::Ptr resolvedProperties = m_Properties->ToFlatDictionary();
Reload(resolvedProperties);
}
void DynamicObject::Reload(Dictionary::Ptr resolvedProperties)
{
resolvedProperties->GetProperty("__name", &m_Name);
resolvedProperties->GetProperty("__type", &m_Type);
resolvedProperties->GetProperty("__local", &m_Local);
resolvedProperties->GetProperty("__abstract", &m_Abstract);
}

71
dyn/dynamicobject.h Normal file
View File

@ -0,0 +1,71 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#ifndef DYNAMICOBJECT_H
#define DYNAMICOBJECT_H
namespace icinga
{
class DynamicObject : public Object
{
public:
typedef shared_ptr<DynamicObject> Ptr;
typedef weak_ptr<DynamicObject> WeakPtr;
void AddParentObject(DynamicObject::Ptr parent);
void RemoveParentObject(DynamicObject::Ptr parent);
void AddChildObject(DynamicObject::WeakPtr parent);
void RemoveChildObject(DynamicObject::WeakPtr parent);
DynamicDictionary::Ptr GetProperties(void) const;
void SetProperties(DynamicDictionary::Ptr properties);
Dictionary::Ptr GetResolvedProperties(void) const;
string GetName(void) const;
string GetType(void) const;
bool IsLocal(void) const;
bool IsAbstract(void) const;
void Commit(void);
protected:
virtual void Reload(Dictionary::Ptr resolvedProperties);
private:
set<DynamicObject::Ptr> m_Parents;
set<DynamicObject::WeakPtr> m_Children;
DynamicDictionary::Ptr m_Properties;
string m_Type;
string m_Name;
bool m_Local;
bool m_Abstract;
void SetName(string name);
void SetType(string type);
void SetLocal(bool local);
void SetAbstract(bool abstract);
};
}
#endif /* DYNAMICOBJECT_H */

36
dyn/i2-dyn.h Normal file
View File

@ -0,0 +1,36 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#ifndef I2DYN_H
#define I2DYN_H
/**
* @defgroup dyn Dynamic object library
*
* The dynamic object library implements serializable objects which support
* inheritance.
*/
#include <i2-base.h>
#include "dynamicdictionary.h"
#include "dynamicobject.h"
#include "objectspace.h"
#endif /* I2DYN_H */

91
dyn/objectspace.cpp Normal file
View File

@ -0,0 +1,91 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#include "i2-dyn.h"
using namespace icinga;
void ObjectSpace::RegisterClass(string name, DynamicObjectFactory factory)
{
m_Classes[name] = factory;
}
void ObjectSpace::UnregisterClass(string name)
{
map<string, DynamicObjectFactory>::iterator ci = m_Classes.find(name);
if (ci != m_Classes.end())
m_Classes.erase(ci);
}
void ObjectSpace::RegisterObject(DynamicObject::Ptr object)
{
m_Objects.insert(object);
}
void ObjectSpace::UnregisterObject(DynamicObject::Ptr object)
{
set<DynamicObject::Ptr>::iterator di = m_Objects.find(object);
if (di != m_Objects.end())
m_Objects.erase(di);
}
Dictionary::Ptr ObjectSpace::SerializeObject(DynamicObject::Ptr object)
{
DynamicDictionary::Ptr properties = object->GetProperties();
if (!properties)
throw InvalidArgumentException();
Dictionary::Ptr data = make_shared<Dictionary>();
data->SetProperty("type", object->GetType());
Dictionary::Ptr serializedProperties = properties->Serialize();
data->SetProperty("properties", serializedProperties);
return data;
}
DynamicObject::Ptr ObjectSpace::UnserializeObject(Dictionary::Ptr data)
{
string type;
if (!data->GetProperty("type", &type))
throw InvalidArgumentException();
Dictionary::Ptr serializedProperties;
if (!data->GetProperty("properties", &serializedProperties))
throw InvalidArgumentException();
DynamicDictionary::Ptr properties = make_shared<DynamicDictionary>(serializedProperties);
map<string, DynamicObjectFactory>::iterator di = m_Classes.find(type);
DynamicObject::Ptr object;
if (di != m_Classes.end())
object = di->second();
else
object = make_shared<DynamicObject>();
object->SetProperties(properties);
object->Commit();
return object;
}
vector<DynamicObject::Ptr> FindObjects(function<bool (DynamicObject::Ptr)> predicate)
{
return vector<DynamicObject::Ptr>();
}

49
dyn/objectspace.h Normal file
View File

@ -0,0 +1,49 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#ifndef OBJECTSPACE_H
#define OBJECTSPACE_H
namespace icinga
{
typedef function<DynamicObject::Ptr()> DynamicObjectFactory;
class ObjectSpace : public Object
{
public:
void RegisterClass(string name, DynamicObjectFactory factory);
void UnregisterClass(string name);
Dictionary::Ptr SerializeObject(DynamicObject::Ptr object);
DynamicObject::Ptr UnserializeObject(Dictionary::Ptr serializedObject);
vector<DynamicObject::Ptr> FindObjects(function<bool (DynamicObject::Ptr)> predicate);
private:
map<string, DynamicObjectFactory> m_Classes;
set<DynamicObject::Ptr> m_Objects;
void RegisterObject(DynamicObject::Ptr object);
void UnregisterObject(DynamicObject::Ptr object);
};
}
#endif /* OBJECTSPACE_H */

View File

@ -51,6 +51,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "discovery", "components\dis
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mmatch", "mmatch\mmatch.vcxproj", "{19CBCE06-3F5C-479A-BD75-E2AB6215D345}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dyn", "dyn\dyn.vcxproj", "{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}"
ProjectSection(ProjectDependencies) = postProject
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -97,6 +102,10 @@ Global
{19CBCE06-3F5C-479A-BD75-E2AB6215D345}.Debug|Win32.Build.0 = Debug|Win32
{19CBCE06-3F5C-479A-BD75-E2AB6215D345}.Release|Win32.ActiveCfg = Release|Win32
{19CBCE06-3F5C-479A-BD75-E2AB6215D345}.Release|Win32.Build.0 = Release|Win32
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}.Debug|Win32.ActiveCfg = Debug|Win32
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}.Debug|Win32.Build.0 = Debug|Win32
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}.Release|Win32.ActiveCfg = Release|Win32
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -207,7 +207,7 @@ void Endpoint::SetReceivedWelcome(bool value)
*
* @returns Whether we've received a welcome message.
*/
bool Endpoint::GetReceivedWelcome(void) const
bool Endpoint::HasReceivedWelcome(void) const
{
return m_ReceivedWelcome;
}
@ -227,7 +227,7 @@ void Endpoint::SetSentWelcome(bool value)
*
* @returns Whether we've sent a welcome message.
*/
bool Endpoint::GetSentWelcome(void) const
bool Endpoint::HasSentWelcome(void) const
{
return m_SentWelcome;
}

View File

@ -46,10 +46,10 @@ public:
void SetIdentity(string identity);
void SetReceivedWelcome(bool value);
bool GetReceivedWelcome(void) const;
bool HasReceivedWelcome(void) const;
void SetSentWelcome(bool value);
bool GetSentWelcome(void) const;
bool HasSentWelcome(void) const;
shared_ptr<EndpointManager> GetEndpointManager(void) const;
void SetEndpointManager(weak_ptr<EndpointManager> manager);

View File

@ -108,7 +108,7 @@ int IcingaApplication::NewComponentHandler(const EventArgs& ea)
ConfigObject::Ptr object = static_pointer_cast<ConfigObject>(ea.Source);
/* don't allow replicated config objects */
if (object->GetReplicated())
if (object->IsReplicated())
return 0;
string path;
@ -140,7 +140,7 @@ int IcingaApplication::NewIcingaConfigHandler(const EventArgs& ea)
ConfigObject::Ptr object = static_pointer_cast<ConfigObject>(ea.Source);
/* don't allow replicated config objects */
if (object->GetReplicated())
if (object->IsReplicated())
return 0;
string privkey;

View File

@ -1,20 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="jsonrpcclient.cpp" />
<ClCompile Include="jsonrpcserver.cpp" />
<ClCompile Include="netstring.cpp" />
<ClCompile Include="messagepart.cpp" />
<ClCompile Include="requestmessage.cpp" />
<ClCompile Include="responsemessage.cpp" />
<ClCompile Include="jsonrpcclient.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="responsemessage.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="jsonrpcserver.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="messagepart.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="netstring.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="requestmessage.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="i2-jsonrpc.h" />
<ClInclude Include="jsonrpcclient.h" />
<ClInclude Include="jsonrpcserver.h" />
<ClInclude Include="netstring.h" />
<ClInclude Include="messagepart.h" />
<ClInclude Include="requestmessage.h" />
<ClInclude Include="responsemessage.h" />
<ClInclude Include="i2-jsonrpc.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="jsonrpcclient.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="jsonrpcserver.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="messagepart.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="netstring.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="requestmessage.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="responsemessage.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Headerdateien">
<UniqueIdentifier>{796f79ec-5628-4c91-9e2b-3d603ab2acfc}</UniqueIdentifier>
</Filter>
<Filter Include="Quelldateien">
<UniqueIdentifier>{0457f937-d12b-4328-818b-77359de2425f}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>