]> granicus.if.org Git - icinga2/commitdiff
Code cleanup.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 3 Aug 2012 13:35:27 +0000 (15:35 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 3 Aug 2012 13:35:27 +0000 (15:35 +0200)
base/event.cpp
base/event.h
base/fifo.cpp
base/tcpserver.cpp
base/tcpserver.h
base/timer.cpp
base/tlsclient.cpp
components/cibsync/cibsynccomponent.cpp

index 404ad5c6ed334693c056e34be5e8e9eca152d830..e68bc5e50242faa7a4d02a817148e11986599dbb 100644 (file)
@@ -25,7 +25,7 @@ vector<Event> Event::m_Events;
 condition_variable Event::m_EventAvailable;
 mutex Event::m_Mutex;
 
-Event::Event(const function<void ()>& callback)
+Event::Event(const Event::Callback& callback)
        : m_Callback(callback)
 { }
 
@@ -59,7 +59,7 @@ void Event::ProcessEvents(const system_time& wait_until)
        }
 }
 
-void Event::Post(const function<void ()>& callback)
+void Event::Post(const Event::Callback& callback)
 {
        if (Application::IsMainThread()) {
                callback();
@@ -74,3 +74,4 @@ void Event::Post(const function<void ()>& callback)
                m_EventAvailable.notify_all();
        }
 }
+
index 4f1b16e7b78e985cab0f9a349354e6dd3ce2fb57..79771186671da053dfe533a4d7b4b81509e8cb88 100644 (file)
@@ -26,13 +26,15 @@ namespace icinga
 class I2_BASE_API Event
 {
 public:
+       typedef function<void ()> Callback;
+
        static void ProcessEvents(const system_time& wait_until);
-       static void Post(const function<void ()>& callback);
+       static void Post(const Callback& callback);
 
 private:
-       Event(const function<void ()>& callback);
+       Event(const Callback& callback);
 
-       function<void ()> m_Callback;
+       Callback m_Callback;
 
        static vector<Event> m_Events;
        static condition_variable m_EventAvailable;
index 5ea4dff9e44be79e6646068979965c160fc8401b..e46c9f4d053f17c4b69d71542496725610e7c004 100644 (file)
@@ -27,12 +27,8 @@ using namespace icinga;
  * Constructor for the FIFO class.
  */
 FIFO::FIFO(void)
-{
-       m_Buffer = NULL;
-       m_DataSize = 0;
-       m_AllocSize = 0;
-       m_Offset = 0;
-}
+       : m_Buffer(NULL), m_DataSize(0), m_AllocSize(0), m_Offset(0)
+{ }
 
 /**
  * Destructor for the FIFO class.
index 866530084f33f4474b8359ccd44bd2f26f0b5a60..4bfb3db818280d454da2f91c2d0dacb92afd7967 100644 (file)
@@ -25,16 +25,15 @@ using namespace icinga;
  * Constructor for the TcpServer class.
  */
 TcpServer::TcpServer(void)
-{
-       m_ClientFactory = boost::bind(&TcpClientFactory, RoleInbound);
-}
+       : m_ClientFactory(boost::bind(&TcpClientFactory, RoleInbound))
+{ }
 
 /**
  * Sets the client factory.
  *
  * @param clientFactory The client factory function.
  */
-void TcpServer::SetClientFactory(function<TcpClient::Ptr(SOCKET)> clientFactory)
+void TcpServer::SetClientFactory(const TcpServer::ClientFactory& clientFactory)
 {
        m_ClientFactory = clientFactory;
 }
@@ -44,7 +43,7 @@ void TcpServer::SetClientFactory(function<TcpClient::Ptr(SOCKET)> clientFactory)
  *
  * @returns The client factory function.
  */
-function<TcpClient::Ptr(SOCKET)> TcpServer::GetFactoryFunction(void) const
+TcpServer::ClientFactory TcpServer::GetFactoryFunction(void) const
 {
        return m_ClientFactory;
 }
@@ -87,3 +86,4 @@ void TcpServer::HandleReadable(void)
 
        Event::Post(boost::bind(boost::ref(OnNewClient), GetSelf(), client));
 }
+
index fa64a34e4d0c1303abf5bc3d4266b04cd901a131..3ac03f08fc13f0e007cbf12da27c114ca9089cbb 100644 (file)
@@ -35,10 +35,12 @@ public:
        typedef shared_ptr<TcpServer> Ptr;
        typedef weak_ptr<TcpServer> WeakPtr;
 
+       typedef function<TcpClient::Ptr(SOCKET)> ClientFactory;
+
        TcpServer(void);
 
-       void SetClientFactory(function<TcpClient::Ptr(SOCKET)> function);
-       function<TcpClient::Ptr(SOCKET)> GetFactoryFunction(void) const;
+       void SetClientFactory(const ClientFactory& function);
+       ClientFactory GetFactoryFunction(void) const;
 
        void Listen(void);
 
@@ -50,7 +52,7 @@ protected:
        virtual void HandleReadable(void);
 
 private:
-       function<TcpClient::Ptr(SOCKET)> m_ClientFactory;
+       ClientFactory m_ClientFactory;
 };
 
 }
index cf2eac609d6ccc1dbfe4f033b15afd174668f488..ce24369088642fb7c7ed44c66be6e809e1e68a73 100644 (file)
@@ -27,9 +27,8 @@ Timer::CollectionType Timer::m_Timers;
  * Constructor for the Timer class.
  */
 Timer::Timer(void)
-{
-       m_Interval = 0;
-}
+       : m_Interval(0)
+{ }
 
 /**
  * Calls expired timers and returned when the next wake-up should happen.
index d9dd42779c63bada6d017f038944ce9dc50c00f3..2ba222d1450180264f7588bf471d29fda4c447a4 100644 (file)
@@ -30,12 +30,10 @@ bool I2_EXPORT TlsClient::m_SSLIndexInitialized = false;
  * @param role The role of the client.
  * @param sslContext The SSL context for the client.
  */
-TlsClient::TlsClient(TcpClientRole role, shared_ptr<SSL_CTX> sslContext) : TcpClient(role)
-{
-       m_SSLContext = sslContext;
-       m_BlockRead = false;
-       m_BlockWrite = false;
-}
+TlsClient::TlsClient(TcpClientRole role, shared_ptr<SSL_CTX> sslContext)
+       : TcpClient(role), m_SSLContext(sslContext),
+         m_BlockRead(false), m_BlockWrite(false)
+{ }
 
 void TlsClient::Start(void)
 {
index 9b1264a3af1b99c512dce6947314b93a42e22e8f..c65053d084df0b8013a45a24eece4f52bed292be 100644 (file)
@@ -210,6 +210,8 @@ void CIBSyncComponent::RemoteObjectUpdateHandler(const Endpoint::Ptr& sender, co
 
        DynamicObject::Ptr object = DynamicObject::GetObject(type, name);
 
+       // TODO: sanitize update, disallow __local
+
        if (!object) {
                object = DynamicObject::Create(type, update);