Implemented component loader app.

This commit is contained in:
Gunnar Beutner 2012-03-31 16:29:53 +02:00
parent 7340c6250b
commit b291bf3cfc
5 changed files with 193 additions and 0 deletions

9
icinga/i2-icinga.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef I2_ICINGA_H
#define I2_ICINGA_H
#include <i2-base.h>
#include <i2-jsonrpc.h>
#include "icingaapplication.h"
#endif /* I2_ICINGA_H */

93
icinga/icinga.vcxproj Normal file
View File

@ -0,0 +1,93 @@
<?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>
<PropertyGroup Label="Globals">
<ProjectGuid>{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>icinga</RootNamespace>
<ProjectName>icinga</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</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'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\config;$(IncludePath)</IncludePath>
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir)\..\base;$(ProjectDir)\..\jsonrpc;$(ProjectDir)\..\config;$(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;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>base.lib;jsonrpc.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;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>base.lib;jsonrpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="icingaapplication.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="icingaapplication.h" />
<ClInclude Include="i2-icinga.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,37 @@
#include <cstdio>
#include <iostream>
#include "i2-icinga.h"
using namespace icinga;
using std::cout;
using std::endl;
IcingaApplication::IcingaApplication(void)
{
m_ConnectionManager = new_object<ConnectionManager>();
}
int IcingaApplication::Main(const vector<string>& args)
{
ConfigObject::RefType fileComponentConfig = new_object<ConfigObject>();
fileComponentConfig->SetName("configfilecomponent");
fileComponentConfig->SetType("component");
fileComponentConfig->SetProperty("filename", "icinga.conf");
GetConfigHive()->AddObject(fileComponentConfig);
LoadComponent("configfilecomponent");
LoadComponent("configrpccomponent");
RunEventLoop();
return 0;
}
ConnectionManager::RefType IcingaApplication::GetConnectionManager(void)
{
return m_ConnectionManager;
}
SET_START_CLASS(icinga::IcingaApplication);

View File

@ -0,0 +1,25 @@
#ifndef I2_ICINGAAPPLICATION_H
#define I2_ICINGAAPPLICATION_H
namespace icinga
{
class IcingaApplication : public Application
{
private:
ConnectionManager::RefType m_ConnectionManager;
public:
typedef shared_ptr<IcingaApplication> RefType;
typedef weak_ptr<IcingaApplication> WeakRefType;
IcingaApplication(void);
virtual int Main(const vector<string>& args);
virtual ConnectionManager::RefType GetConnectionManager(void);
};
}
#endif /* I2_ICINGAAPPLICATION_H */

View File

@ -14,6 +14,23 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsonrpc", "jsonrpc\jsonrpc.
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3F525944-70CB-4F7A-BA18-3E87CA79488D}"
ProjectSection(SolutionItems) = preProject
TODO.txt = TODO.txt
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga", "icinga\icinga.vcxproj", "{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}"
ProjectSection(ProjectDependencies) = postProject
{697C6D7E-3109-484C-A7AF-384D28711610} = {697C6D7E-3109-484C-A7AF-384D28711610}
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
{E58F1DA7-B723-412B-B2B7-7FF58E2A944E} = {E58F1DA7-B723-412B-B2B7-7FF58E2A944E}
{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8} = {8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configfilecomponent", "configfilecomponent\configfilecomponent.vcxproj", "{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configrpccomponent", "configrpccomponent\configrpccomponent.vcxproj", "{697C6D7E-3109-484C-A7AF-384D28711610}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -32,6 +49,18 @@ Global
{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}.Debug|Win32.Build.0 = Debug|Win32
{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}.Release|Win32.ActiveCfg = Release|Win32
{8DD52FAC-ECEE-48C2-B266-E7C47ED485F8}.Release|Win32.Build.0 = Release|Win32
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}.Debug|Win32.ActiveCfg = Debug|Win32
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}.Debug|Win32.Build.0 = Debug|Win32
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}.Release|Win32.ActiveCfg = Release|Win32
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}.Release|Win32.Build.0 = Release|Win32
{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}.Debug|Win32.ActiveCfg = Debug|Win32
{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}.Debug|Win32.Build.0 = Debug|Win32
{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}.Release|Win32.ActiveCfg = Release|Win32
{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}.Release|Win32.Build.0 = Release|Win32
{697C6D7E-3109-484C-A7AF-384D28711610}.Debug|Win32.ActiveCfg = Debug|Win32
{697C6D7E-3109-484C-A7AF-384D28711610}.Debug|Win32.Build.0 = Debug|Win32
{697C6D7E-3109-484C-A7AF-384D28711610}.Release|Win32.ActiveCfg = Release|Win32
{697C6D7E-3109-484C-A7AF-384D28711610}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE