]> granicus.if.org Git - icinga2/commitdiff
Documentation update.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 18 May 2012 20:53:35 +0000 (22:53 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 18 May 2012 20:56:34 +0000 (22:56 +0200)
Code cleanup.

base/application.cpp
base/application.h
base/base.vcxproj
base/dictionary.h
components/configfile/Makefile.am
components/configfile/configfile.vcxproj
components/configfile/i2-configfile.h
components/configrpc/Makefile.am
jsonrpc/netstring.cpp
jsonrpc/netstring.h

index de3054477d85165b7480713b457d5ac15713601b..5ed95f8956b3af7ff265213e2d323e3134d1ede5 100644 (file)
@@ -75,7 +75,8 @@ Application::~Application(void)
 }
 
 /**
- * Processes events (e.g. sockets and timers).
+ * Processes events for registered sockets and timers and calls whatever
+ * handlers have been set up for these events.
  */
 void Application::RunEventLoop(void)
 {
@@ -274,18 +275,18 @@ void Application::UnregisterComponent(Component::Ptr component)
  * @param name The name of the component.
  * @returns The component or a null pointer if the component could not be found.
  */
-Component::Ptr Application::GetComponent(const string& name)
+Component::Ptr Application::GetComponent(const string& name) const
 {
-       map<string, Component::Ptr>::iterator ci = m_Components.find(name);
+       map<string, Component::Ptr>::const_iterator i = m_Components.find(name);
 
-       if (ci == m_Components.end())
+       if (i == m_Components.end())
                return Component::Ptr();
 
-       return ci->second;
+       return i->second;
 }
 
 /**
- * Logs a message.
+ * Writes a message to the application's log.
  *
  * @param message The message.
  */
@@ -408,11 +409,12 @@ bool Application::IsDebugging(void) const
 
 #ifndef _WIN32
 /**
- * Signal handler for SIGINT.
+ * Signal handler for SIGINT. Prepares the application for cleanly
+ * shutting down during the next execution of the event loop.
  *
  * @param signum The signal number.
  */
-static void ApplicationSigIntHandler(int signum)
+void Application::SigIntHandler(int signum)
 {
        assert(signum == SIGINT);
 
@@ -442,7 +444,7 @@ int Application::Run(int argc, char **argv)
 #ifndef _WIN32
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
-       sa.sa_handler = ApplicationSigIntHandler;
+       sa.sa_handler = Application::SigIntHandler;
        sigaction(SIGINT, &sa, NULL);
 
        sa.sa_handler = SIG_IGN;
index 6fce496145f4cc0bae610d23c39c707694cb5e0b..d6d364548b36b96fd2857f7c364768de2e1c88dd 100644 (file)
@@ -41,6 +41,10 @@ private:
        vector<string> m_Arguments; /**< Command-line arguments */
        bool m_Debugging; /**< Whether debugging is enabled. */
 
+#ifndef _WIN32
+       static void SigIntHandler(int signum);
+#endif /* _WIN32 */
+
 protected:
        void RunEventLoop(void);
        string GetExeDirectory(void) const;
@@ -68,7 +72,7 @@ public:
            const ConfigObject::Ptr& componentConfig);
        void RegisterComponent(shared_ptr<Component> component);
        void UnregisterComponent(shared_ptr<Component> component);
-       shared_ptr<Component> GetComponent(const string& name);
+       shared_ptr<Component> GetComponent(const string& name) const;
        void AddComponentSearchDir(const string& componentDirectory);
 
        bool IsDebugging(void) const;
index 44e415aea3606b429a5d56e30e5cd18a1d37ab4e..59821309e0c82500f33c9ba7f704a1ae340045a3 100644 (file)
   <ItemGroup>
     <ClCompile Include="application.cpp" />
     <ClCompile Include="component.cpp" />
-    <ClCompile Include="condvar.cpp" />
     <ClCompile Include="configcollection.cpp" />
     <ClCompile Include="confighive.cpp" />
     <ClCompile Include="configobject.cpp" />
     <ClCompile Include="dictionary.cpp" />
     <ClCompile Include="exception.cpp" />
     <ClCompile Include="fifo.cpp" />
-    <ClCompile Include="lock.cpp" />
     <ClCompile Include="memory.cpp" />
-    <ClCompile Include="mutex.cpp" />
     <ClCompile Include="object.cpp" />
     <ClCompile Include="socket.cpp" />
     <ClCompile Include="tcpclient.cpp" />
     <ClCompile Include="tcpserver.cpp" />
     <ClCompile Include="tcpsocket.cpp" />
-    <ClCompile Include="thread.cpp" />
     <ClCompile Include="timer.cpp" />
     <ClCompile Include="tlsclient.cpp" />
     <ClCompile Include="unix.cpp" />
   <ItemGroup>
     <ClInclude Include="application.h" />
     <ClInclude Include="component.h" />
-    <ClInclude Include="condvar.h" />
     <ClInclude Include="configcollection.h" />
     <ClInclude Include="confighive.h" />
     <ClInclude Include="configobject.h" />
     <ClInclude Include="cxx11-compat.h" />
     <ClInclude Include="delegate.h" />
     <ClInclude Include="dictionary.h" />
-    <ClInclude Include="lock.h" />
     <ClInclude Include="observable.h" />
     <ClInclude Include="exception.h" />
     <ClInclude Include="fifo.h" />
@@ -57,7 +51,6 @@
     <ClInclude Include="tcpclient.h" />
     <ClInclude Include="tcpserver.h" />
     <ClInclude Include="tcpsocket.h" />
-    <ClInclude Include="thread.h" />
     <ClInclude Include="timer.h" />
     <ClInclude Include="tlsclient.h" />
     <ClInclude Include="unix.h" />
@@ -65,9 +58,6 @@
     <ClInclude Include="variant.h" />
     <ClInclude Include="win32.h" />
   </ItemGroup>
-  <ItemGroup>
-    <None Include="mutex.h" />
-  </ItemGroup>
   <PropertyGroup Label="Globals">
     <ProjectGuid>{9C92DA90-FD53-43A9-A244-90F2E8AF9677}</ProjectGuid>
     <Keyword>Win32Proj</Keyword>
index 58d35911acf62688b8aa3ef36b57c326c5528400..83a32c3bfe74aee5788acc7ae94fe780b01dd86a 100644 (file)
@@ -44,7 +44,7 @@ public:
         * Retrieves a value from the dictionary.
         *
         * @param key The key.
-        * @param value Pointer to the value.
+        * @param[out] value Pointer to the value.
         * @returns true if the value was retrieved, false otherwise.
         */
        template<typename T>
index cb2b29cde484ce2132f4e6ec36ba7233ef80a4b7..cd38dcb1bd3022c144a27694b6ae25b68c615667 100644 (file)
@@ -10,6 +10,7 @@ configfile_la_SOURCES = \
 
 configfile_la_CXXFLAGS = \
        -I${top_srcdir}/base \
+       -I${top_srcdir}/icinga \
        -I${top_srcdir}/jsonrpc \
        -I${top_srcdir}/cJSON
 
@@ -20,4 +21,5 @@ configfile_la_LDFLAGS = \
 
 configfile_la_LIBADD = \
        $(top_builddir)/base/libbase.la \
+       $(top_builddir)/icinga/libicinga.la \
        $(top_builddir)/cJSON/libcJSON.la
index 1f8708527b68a84756291a7bc460364e9f4b978d..61612eb004677e4cb1c4cea08d2d58534e3f89fe 100644 (file)
   </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <IncludePath>$(SolutionDir)\base;$(SolutionDir)\cJSON;$(IncludePath)</IncludePath>
+    <IncludePath>$(SolutionDir)\base;$(SolutionDir)\jsonrpc;$(SolutionDir)\icinga;$(SolutionDir)\cJSON;$(IncludePath)</IncludePath>
     <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <IncludePath>$(SolutionDir)\base;$(SolutionDir)\cJSON;$(IncludePath)</IncludePath>
+    <IncludePath>$(SolutionDir)\base;$(SolutionDir)\jsonrpc;$(SolutionDir)\icinga;$(SolutionDir)\cJSON;$(IncludePath)</IncludePath>
     <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -63,7 +63,7 @@
     <Link>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Lib>
       <AdditionalDependencies>
@@ -86,7 +86,7 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>base.lib;jsonrpc.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
     <Lib>
       <AdditionalDependencies>$(OutDir)\base.lib;$(OutDir)\jsonrpc.lib</AdditionalDependencies>
index 9a548a96770e9a12f5f4b4b56874d4441671d653..589f8d4e4e927a9e8c76a1bc37f35e999a553365 100644 (file)
@@ -21,6 +21,7 @@
 #define I2CONFIGFILECOMPONENT_H
 
 #include <i2-base.h>
+#include <i2-icinga.h>
 
 #include "configfilecomponent.h"
 
index 5661e148d35047ffe3f1e630a08c994f98767eb4..aa92bba17707cd199a22134541ad7433afe79017 100644 (file)
@@ -11,7 +11,6 @@ configrpc_la_SOURCES = \
 configrpc_la_CXXFLAGS = \
        -I${top_srcdir}/base \
        -I${top_srcdir}/jsonrpc \
-       -I${top_srcdir}/cJSON \
        -I${top_srcdir}/icinga
 
 configrpc_la_LDFLAGS = \
@@ -22,5 +21,4 @@ configrpc_la_LDFLAGS = \
 configrpc_la_LIBADD = \
        ${top_builddir}/base/libbase.la \
        ${top_builddir}/jsonrpc/libjsonrpc.la \
-       ${top_builddir}/cJSON/libcJSON.la \
        ${top_builddir}/icinga/libicinga.la
index 307f16b5d407dbc8a27e73e44563bce3b2cec957..10ab6686f7df126a1dd8460b54405c938418f1ef 100644 (file)
 
 using namespace icinga;
 
-/* based on https://github.com/PeterScott/netstring-c/blob/master/netstring.c */
+/**
+ * Reads data from a FIFO in netstring format.
+ *
+ * @param fifo The FIFO to read from.
+ * @param[out] str The string that has been read from the FIFO.
+ * @returns true if a complete string was read from the FIFO, false otherwise.
+ * @exception InvalidNetstringException The input stream is invalid.
+ * @see https://github.com/PeterScott/netstring-c/blob/master/netstring.c
+ */
 bool Netstring::ReadStringFromFIFO(FIFO::Ptr fifo, string *str)
 {
        size_t buffer_length = fifo->GetSize();
@@ -66,6 +74,12 @@ bool Netstring::ReadStringFromFIFO(FIFO::Ptr fifo, string *str)
        return true;
 }
 
+/**
+ * Writes data into a FIFO using the netstring format.
+ *
+ * @param fifo The FIFO.
+ * @param str The string that is to be written.
+ */
 void Netstring::WriteStringToFIFO(FIFO::Ptr fifo, const string& str)
 {
        unsigned long len = str.size();
index cb315445548766bc2bb3900676ef684dbc182d27..5fc1087ebb8a9b8239f8f9392972fe0215a7b88c 100644 (file)
 namespace icinga
 {
 
+/**
+ * Thrown when an invalid netstring was encountered while reading from a FIFO.
+ */
+DEFINE_EXCEPTION_CLASS(InvalidNetstringException);
+
 /**
  * Utility functions for reading/writing messages in the netstring format.
  * See http://cr.yp.to/proto/netstrings.txt for details.