Consistent ordering for method declarations.

This commit is contained in:
Gunnar Beutner 2012-05-21 23:42:54 +02:00
parent 918cbad764
commit 59dcfa801c
29 changed files with 229 additions and 232 deletions

View File

@ -36,28 +36,6 @@ public:
typedef shared_ptr<Application> Ptr; typedef shared_ptr<Application> Ptr;
typedef weak_ptr<Application> WeakPtr; typedef weak_ptr<Application> WeakPtr;
private:
static Application::Ptr m_Instance;
bool m_ShuttingDown; /**< Whether the application is in the process of
shutting down. */
ConfigHive::Ptr m_ConfigHive; /**< The application's configuration. */
map< string, shared_ptr<Component> > m_Components; /**< Components that
were loaded by the application. */
vector<string> m_Arguments; /**< Command-line arguments */
bool m_Debugging; /**< Whether debugging is enabled. */
#ifndef _WIN32
static void SigIntHandler(int signum);
#else /* _WIN32 */
static BOOL WINAPI CtrlHandler(DWORD type);
#endif /* _WIN32 */
protected:
void RunEventLoop(void);
string GetExeDirectory(void) const;
public:
Application(void); Application(void);
~Application(void); ~Application(void);
@ -81,6 +59,27 @@ public:
void AddComponentSearchDir(const string& componentDirectory); void AddComponentSearchDir(const string& componentDirectory);
bool IsDebugging(void) const; bool IsDebugging(void) const;
protected:
void RunEventLoop(void);
string GetExeDirectory(void) const;
private:
static Application::Ptr m_Instance;
bool m_ShuttingDown; /**< Whether the application is in the process of
shutting down. */
ConfigHive::Ptr m_ConfigHive; /**< The application's configuration. */
map< string, shared_ptr<Component> > m_Components; /**< Components that
were loaded by the application. */
vector<string> m_Arguments; /**< Command-line arguments */
bool m_Debugging; /**< Whether debugging is enabled. */
#ifndef _WIN32
static void SigIntHandler(int signum);
#else /* _WIN32 */
static BOOL WINAPI CtrlHandler(DWORD type);
#endif /* _WIN32 */
}; };
} }

View File

@ -31,9 +31,6 @@ namespace icinga
*/ */
class I2_BASE_API Component : public Object class I2_BASE_API Component : public Object
{ {
private:
ConfigObject::Ptr m_Config;
public: public:
typedef shared_ptr<Component> Ptr; typedef shared_ptr<Component> Ptr;
typedef weak_ptr<Component> WeakPtr; typedef weak_ptr<Component> WeakPtr;
@ -44,6 +41,9 @@ public:
virtual string GetName(void) const = 0; virtual string GetName(void) const = 0;
virtual void Start(void) = 0; virtual void Start(void) = 0;
virtual void Stop(void) = 0; virtual void Stop(void) = 0;
private:
ConfigObject::Ptr m_Config;
}; };
typedef Component *(*CreateComponentFunction)(void); typedef Component *(*CreateComponentFunction)(void);

View File

@ -32,9 +32,6 @@ class ConfigHive;
*/ */
class I2_BASE_API ConfigCollection : public Object class I2_BASE_API ConfigCollection : public Object
{ {
private:
weak_ptr<ConfigHive> m_Hive;
public: public:
typedef shared_ptr<ConfigCollection> Ptr; typedef shared_ptr<ConfigCollection> Ptr;
typedef weak_ptr<ConfigCollection> WeakPtr; typedef weak_ptr<ConfigCollection> WeakPtr;
@ -54,6 +51,10 @@ public:
Observable<EventArgs> OnObjectCommitted; Observable<EventArgs> OnObjectCommitted;
Observable<EventArgs> OnObjectRemoved; Observable<EventArgs> OnObjectRemoved;
private:
weak_ptr<ConfigHive> m_Hive;
}; };
} }

View File

@ -34,13 +34,6 @@ class ConfigHive;
*/ */
class I2_BASE_API ConfigObject : public Dictionary class I2_BASE_API ConfigObject : public Dictionary
{ {
private:
weak_ptr<ConfigHive> m_Hive;
string m_Name;
string m_Type;
bool m_Replicated;
public: public:
typedef shared_ptr<ConfigObject> Ptr; typedef shared_ptr<ConfigObject> Ptr;
typedef weak_ptr<ConfigObject> WeakPtr; typedef weak_ptr<ConfigObject> WeakPtr;
@ -60,6 +53,13 @@ public:
bool GetReplicated(void) const; bool GetReplicated(void) const;
void Commit(void); void Commit(void);
private:
weak_ptr<ConfigHive> m_Hive;
string m_Name;
string m_Type;
bool m_Replicated;
}; };
} }

View File

@ -33,9 +33,6 @@ typedef map<string, Variant>::iterator DictionaryIterator;
*/ */
class I2_BASE_API Dictionary : public Object class I2_BASE_API Dictionary : public Object
{ {
private:
map<string, Variant> m_Data;
public: public:
typedef shared_ptr<Dictionary> Ptr; typedef shared_ptr<Dictionary> Ptr;
typedef weak_ptr<Dictionary> WeakPtr; typedef weak_ptr<Dictionary> WeakPtr;
@ -99,6 +96,9 @@ public:
DictionaryIterator End(void); DictionaryIterator End(void);
long GetLength(void) const; long GetLength(void) const;
private:
map<string, Variant> m_Data;
}; };
} }

View File

@ -30,12 +30,6 @@ namespace icinga
*/ */
class I2_BASE_API Exception : public exception class I2_BASE_API Exception : public exception
{ {
private:
char *m_Message;
protected:
void SetMessage(const char *message);
public: public:
Exception(void); Exception(void);
Exception(const char *message); Exception(const char *message);
@ -44,6 +38,12 @@ public:
const char *GetMessage(void) const; const char *GetMessage(void) const;
virtual const char *what(void) const throw(); virtual const char *what(void) const throw();
protected:
void SetMessage(const char *message);
private:
char *m_Message;
}; };
#define DEFINE_EXCEPTION_CLASS(klass) \ #define DEFINE_EXCEPTION_CLASS(klass) \

View File

@ -30,15 +30,6 @@ namespace icinga
*/ */
class I2_BASE_API FIFO : public Object class I2_BASE_API FIFO : public Object
{ {
private:
char *m_Buffer;
size_t m_DataSize;
size_t m_AllocSize;
size_t m_Offset;
void ResizeBuffer(size_t newSize);
void Optimize(void);
public: public:
static const size_t BlockSize = 16 * 1024; static const size_t BlockSize = 16 * 1024;
@ -55,6 +46,15 @@ public:
size_t Read(void *buffer, size_t count); size_t Read(void *buffer, size_t count);
size_t Write(const void *buffer, size_t count); size_t Write(const void *buffer, size_t count);
private:
char *m_Buffer;
size_t m_DataSize;
size_t m_AllocSize;
size_t m_Offset;
void ResizeBuffer(size_t newSize);
void Optimize(void);
}; };
} }

View File

@ -24,8 +24,8 @@
* @mainpage Icinga Documentation * @mainpage Icinga Documentation
* *
* Icinga implements a framework for run-time-loadable components which can * Icinga implements a framework for run-time-loadable components which can
* pass messages between them. These components can either be hosted in the * pass messages between each other. These components can either be hosted in
* same process or in several host processes (either on the same machine or * the same process or in several host processes (either on the same machine or
* on different machines). * on different machines).
* *
* The framework's code critically depends on the following patterns: * The framework's code critically depends on the following patterns:
@ -34,7 +34,8 @@
* <item>Smart pointers * <item>Smart pointers
* *
* The shared_ptr and weak_ptr template classes are used to simplify memory * The shared_ptr and weak_ptr template classes are used to simplify memory
* management and to avoid accidental memory leaks and use-after-free bugs.</item> * management and to avoid accidental memory leaks and use-after-free
* bugs.</item>
* *
* <item>Observer pattern * <item>Observer pattern
* *

View File

@ -32,14 +32,14 @@ DEFINE_EXCEPTION_CLASS(OutOfMemoryException);
*/ */
class I2_BASE_API Memory class I2_BASE_API Memory
{ {
private:
Memory(void);
public: public:
static void *Allocate(size_t size); static void *Allocate(size_t size);
static void *Reallocate(void *ptr, size_t size); static void *Reallocate(void *ptr, size_t size);
static char *StrDup(const char *str); static char *StrDup(const char *str);
static void Free(void *ptr); static void Free(void *ptr);
private:
Memory(void);
}; };
} }

View File

@ -29,19 +29,19 @@ namespace icinga
* *
* @ingroup base * @ingroup base
*/ */
class I2_BASE_API Object : public enable_shared_from_this<Object> class I2_BASE_API Object : protected enable_shared_from_this<Object>
{ {
private: public:
Object(const Object& other); typedef shared_ptr<Object> Ptr;
Object operator=(const Object& rhs); typedef weak_ptr<Object> WeakPtr;
protected: protected:
Object(void); Object(void);
virtual ~Object(void); virtual ~Object(void);
public: private:
typedef shared_ptr<Object> Ptr; Object(const Object& other);
typedef weak_ptr<Object> WeakPtr; Object operator=(const Object& rhs);
}; };
/** /**

View File

@ -44,10 +44,6 @@ class Observable
public: public:
typedef function<int (const TArgs&)> ObserverType; typedef function<int (const TArgs&)> ObserverType;
private:
vector<ObserverType> m_Observers;
public:
/** /**
* Adds an observer to this event. * Adds an observer to this event.
* *
@ -89,6 +85,9 @@ public:
i++; i++;
} }
} }
private:
vector<ObserverType> m_Observers;
}; };
} }

View File

@ -40,19 +40,6 @@ struct I2_BASE_API SocketErrorEventArgs : public EventArgs
*/ */
class I2_BASE_API Socket : public Object class I2_BASE_API Socket : public Object
{ {
private:
SOCKET m_FD; /**< The socket descriptor. */
int ExceptionEventHandler(const EventArgs& ea);
static string GetAddressFromSockaddr(sockaddr *address, socklen_t len);
protected:
Socket(void);
void HandleSocketError(void);
virtual void CloseInternal(bool from_dtor);
public: public:
typedef shared_ptr<Socket> Ptr; typedef shared_ptr<Socket> Ptr;
typedef weak_ptr<Socket> WeakPtr; typedef weak_ptr<Socket> WeakPtr;
@ -83,6 +70,19 @@ public:
string GetClientAddress(void); string GetClientAddress(void);
string GetPeerAddress(void); string GetPeerAddress(void);
protected:
Socket(void);
void HandleSocketError(void);
virtual void CloseInternal(bool from_dtor);
private:
SOCKET m_FD; /**< The socket descriptor. */
int ExceptionEventHandler(const EventArgs& ea);
static string GetAddressFromSockaddr(sockaddr *address, socklen_t len);
}; };
} }

View File

@ -43,15 +43,6 @@ enum TcpClientRole
*/ */
class I2_BASE_API TcpClient : public TcpSocket class I2_BASE_API TcpClient : public TcpSocket
{ {
private:
TcpClientRole m_Role;
FIFO::Ptr m_SendQueue;
FIFO::Ptr m_RecvQueue;
virtual int ReadableEventHandler(const EventArgs& ea);
virtual int WritableEventHandler(const EventArgs& ea);
public: public:
typedef shared_ptr<TcpClient> Ptr; typedef shared_ptr<TcpClient> Ptr;
typedef weak_ptr<TcpClient> WeakPtr; typedef weak_ptr<TcpClient> WeakPtr;
@ -71,6 +62,15 @@ public:
virtual bool WantsToWrite(void) const; virtual bool WantsToWrite(void) const;
Observable<EventArgs> OnDataAvailable; Observable<EventArgs> OnDataAvailable;
private:
TcpClientRole m_Role;
FIFO::Ptr m_SendQueue;
FIFO::Ptr m_RecvQueue;
virtual int ReadableEventHandler(const EventArgs& ea);
virtual int WritableEventHandler(const EventArgs& ea);
}; };
/** /**

View File

@ -41,11 +41,6 @@ struct I2_BASE_API NewClientEventArgs : public EventArgs
*/ */
class I2_BASE_API TcpServer : public TcpSocket class I2_BASE_API TcpServer : public TcpSocket
{ {
private:
int ReadableEventHandler(const EventArgs& ea);
function<TcpClient::Ptr()> m_ClientFactory;
public: public:
typedef shared_ptr<TcpServer> Ptr; typedef shared_ptr<TcpServer> Ptr;
typedef weak_ptr<TcpServer> WeakPtr; typedef weak_ptr<TcpServer> WeakPtr;
@ -62,6 +57,11 @@ public:
Observable<NewClientEventArgs> OnNewClient; Observable<NewClientEventArgs> OnNewClient;
virtual bool WantsToRead(void) const; virtual bool WantsToRead(void) const;
private:
int ReadableEventHandler(const EventArgs& ea);
function<TcpClient::Ptr()> m_ClientFactory;
}; };
} }

View File

@ -30,15 +30,15 @@ namespace icinga
*/ */
class I2_BASE_API TcpSocket : public Socket class I2_BASE_API TcpSocket : public Socket
{ {
private:
void MakeSocket(int family);
public: public:
typedef shared_ptr<TcpSocket> Ptr; typedef shared_ptr<TcpSocket> Ptr;
typedef weak_ptr<TcpSocket> WeakPtr; typedef weak_ptr<TcpSocket> WeakPtr;
void Bind(string service, int family); void Bind(string service, int family);
void Bind(string node, string service, int family); void Bind(string node, string service, int family);
private:
void MakeSocket(int family);
}; };
} }

View File

@ -41,17 +41,6 @@ struct I2_BASE_API TimerEventArgs : public EventArgs
*/ */
class I2_BASE_API Timer : public Object class I2_BASE_API Timer : public Object
{ {
private:
EventArgs m_UserArgs; /**< User-specified event arguments. */
unsigned int m_Interval; /**< The interval of the timer. */
time_t m_Next; /**< When the next event should happen. */
static time_t NextCall; /**< When the next event should happen (for all timers). */
static void RescheduleTimers(void);
void Call(void);
public: public:
typedef shared_ptr<Timer> Ptr; typedef shared_ptr<Timer> Ptr;
typedef weak_ptr<Timer> WeakPtr; typedef weak_ptr<Timer> WeakPtr;
@ -77,6 +66,17 @@ public:
void Reschedule(time_t next); void Reschedule(time_t next);
Observable<TimerEventArgs> OnTimerExpired; Observable<TimerEventArgs> OnTimerExpired;
private:
EventArgs m_UserArgs; /**< User-specified event arguments. */
unsigned int m_Interval; /**< The interval of the timer. */
time_t m_Next; /**< When the next event should happen. */
static time_t NextCall; /**< When the next event should happen (for all timers). */
static void RescheduleTimers(void);
void Call(void);
}; };
} }

View File

@ -44,6 +44,22 @@ struct I2_BASE_API VerifyCertificateEventArgs : public EventArgs
*/ */
class I2_BASE_API TlsClient : public TcpClient class I2_BASE_API TlsClient : public TcpClient
{ {
public:
TlsClient(TcpClientRole role, shared_ptr<SSL_CTX> sslContext);
shared_ptr<X509> GetClientCertificate(void) const;
shared_ptr<X509> GetPeerCertificate(void) const;
virtual void Start(void);
virtual bool WantsToRead(void) const;
virtual bool WantsToWrite(void) const;
Observable<VerifyCertificateEventArgs> OnVerifyCertificate;
protected:
void HandleSSLError(void);
private: private:
shared_ptr<SSL_CTX> m_SSLContext; shared_ptr<SSL_CTX> m_SSLContext;
shared_ptr<SSL> m_SSL; shared_ptr<SSL> m_SSL;
@ -62,22 +78,6 @@ private:
static void NullCertificateDeleter(X509 *certificate); static void NullCertificateDeleter(X509 *certificate);
static int SSLVerifyCertificate(int ok, X509_STORE_CTX *x509Context); static int SSLVerifyCertificate(int ok, X509_STORE_CTX *x509Context);
protected:
void HandleSSLError(void);
public:
TlsClient(TcpClientRole role, shared_ptr<SSL_CTX> sslContext);
shared_ptr<X509> GetClientCertificate(void) const;
shared_ptr<X509> GetPeerCertificate(void) const;
virtual void Start(void);
virtual bool WantsToRead(void) const;
virtual bool WantsToWrite(void) const;
Observable<VerifyCertificateEventArgs> OnVerifyCertificate;
}; };
TcpClient::Ptr TlsClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext); TcpClient::Ptr TlsClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext);

View File

@ -30,13 +30,6 @@ namespace icinga
*/ */
class I2_BASE_API Utility class I2_BASE_API Utility
{ {
private:
static bool m_SSLInitialized;
Utility(void);
static void InitializeOpenSSL(void);
public: public:
/** /**
* Returns a human-readable type name of an object (using RTTI). * Returns a human-readable type name of an object (using RTTI).
@ -69,6 +62,13 @@ public:
static shared_ptr<X509> GetX509Certificate(string pemfile); static shared_ptr<X509> GetX509Certificate(string pemfile);
static bool Match(string pattern, string text); static bool Match(string pattern, string text);
private:
static bool m_SSLInitialized;
Utility(void);
static void InitializeOpenSSL(void);
}; };
} }

View File

@ -44,18 +44,6 @@ enum VariantType
*/ */
class I2_BASE_API Variant class I2_BASE_API Variant
{ {
private:
mutable VariantType m_Type; /**< The type of the Variant. */
mutable long m_IntegerValue; /**< The value of the Variant
if m_Type == VariantInteger */
mutable string m_StringValue; /**< The value of the Variant
if m_Type == VariantString */
mutable Object::Ptr m_ObjectValue; /**< The value of the Variant
if m_Type == VariantObject */
void Convert(VariantType newType) const;
public: public:
inline Variant(void) : m_Type(VariantEmpty) { } inline Variant(void) : m_Type(VariantEmpty) { }
@ -86,6 +74,18 @@ public:
operator long(void) const; operator long(void) const;
operator string(void) const; operator string(void) const;
operator Object::Ptr(void) const; operator Object::Ptr(void) const;
private:
mutable VariantType m_Type; /**< The type of the Variant. */
mutable long m_IntegerValue; /**< The value of the Variant
if m_Type == VariantInteger */
mutable string m_StringValue; /**< The value of the Variant
if m_Type == VariantString */
mutable Object::Ptr m_ObjectValue; /**< The value of the Variant
if m_Type == VariantObject */
void Convert(VariantType newType) const;
}; };
} }

View File

@ -28,17 +28,17 @@ namespace icinga
*/ */
class DemoComponent : public IcingaComponent class DemoComponent : public IcingaComponent
{ {
public:
virtual string GetName(void) const;
virtual void Start(void);
virtual void Stop(void);
private: private:
Timer::Ptr m_DemoTimer; Timer::Ptr m_DemoTimer;
VirtualEndpoint::Ptr m_DemoEndpoint; VirtualEndpoint::Ptr m_DemoEndpoint;
int DemoTimerHandler(const TimerEventArgs& tea); int DemoTimerHandler(const TimerEventArgs& tea);
int HelloWorldRequestHandler(const NewRequestEventArgs& nrea); int HelloWorldRequestHandler(const NewRequestEventArgs& nrea);
public:
virtual string GetName(void) const;
virtual void Start(void);
virtual void Stop(void);
}; };
} }

View File

@ -46,6 +46,11 @@ public:
*/ */
class DiscoveryComponent : public IcingaComponent class DiscoveryComponent : public IcingaComponent
{ {
public:
virtual string GetName(void) const;
virtual void Start(void);
virtual void Stop(void);
private: private:
VirtualEndpoint::Ptr m_DiscoveryEndpoint; VirtualEndpoint::Ptr m_DiscoveryEndpoint;
map<string, ComponentDiscoveryInfo::Ptr> m_Components; map<string, ComponentDiscoveryInfo::Ptr> m_Components;
@ -76,11 +81,6 @@ private:
bool HasMessagePermission(Dictionary::Ptr roles, string messageType, string message); bool HasMessagePermission(Dictionary::Ptr roles, string messageType, string message);
static const int RegistrationTTL = 300; static const int RegistrationTTL = 300;
public:
virtual string GetName(void) const;
virtual void Start(void);
virtual void Stop(void);
}; };
} }

View File

@ -32,21 +32,6 @@ class EndpointManager;
*/ */
class I2_ICINGA_API Endpoint : public Object class I2_ICINGA_API Endpoint : public Object
{ {
private:
string m_Identity; /**< The identity of this endpoint. */
set<string> m_Subscriptions; /**< The topics this endpoint is
subscribed to. */
set<string> m_Publications; /**< The topics this endpoint is
publishing. */
bool m_ReceivedWelcome; /**< Have we received a welcome message
from this endpoint? */
bool m_SentWelcome; /**< Have we sent a welcome message to this
endpoint? */
weak_ptr<EndpointManager> m_EndpointManager; /**< The endpoint manager
this endpoint is
registered with. */
public: public:
typedef shared_ptr<Endpoint> Ptr; typedef shared_ptr<Endpoint> Ptr;
typedef weak_ptr<Endpoint> WeakPtr; typedef weak_ptr<Endpoint> WeakPtr;
@ -96,6 +81,21 @@ public:
Observable<EventArgs> OnIdentityChanged; Observable<EventArgs> OnIdentityChanged;
Observable<EventArgs> OnSessionEstablished; Observable<EventArgs> OnSessionEstablished;
private:
string m_Identity; /**< The identity of this endpoint. */
set<string> m_Subscriptions; /**< The topics this endpoint is
subscribed to. */
set<string> m_Publications; /**< The topics this endpoint is
publishing. */
bool m_ReceivedWelcome; /**< Have we received a welcome message
from this endpoint? */
bool m_SentWelcome; /**< Have we sent a welcome message to this
endpoint? */
weak_ptr<EndpointManager> m_EndpointManager; /**< The endpoint manager
this endpoint is
registered with. */
}; };
} }

View File

@ -40,17 +40,6 @@ struct I2_ICINGA_API NewEndpointEventArgs : public EventArgs
*/ */
class I2_ICINGA_API EndpointManager : public Object class I2_ICINGA_API EndpointManager : public Object
{ {
string m_Identity;
shared_ptr<SSL_CTX> m_SSLContext;
vector<JsonRpcServer::Ptr> m_Servers;
vector<Endpoint::Ptr> m_Endpoints;
void RegisterServer(JsonRpcServer::Ptr server);
void UnregisterServer(JsonRpcServer::Ptr server);
int NewClientHandler(const NewClientEventArgs& ncea);
public: public:
typedef shared_ptr<EndpointManager> Ptr; typedef shared_ptr<EndpointManager> Ptr;
typedef weak_ptr<EndpointManager> WeakPtr; typedef weak_ptr<EndpointManager> WeakPtr;
@ -76,8 +65,18 @@ public:
Endpoint::Ptr GetEndpointByIdentity(string identity) const; Endpoint::Ptr GetEndpointByIdentity(string identity) const;
Observable<NewEndpointEventArgs> OnNewEndpoint; Observable<NewEndpointEventArgs> OnNewEndpoint;
};
private:
string m_Identity;
shared_ptr<SSL_CTX> m_SSLContext;
vector<JsonRpcServer::Ptr> m_Servers;
vector<Endpoint::Ptr> m_Endpoints;
void RegisterServer(JsonRpcServer::Ptr server);
void UnregisterServer(JsonRpcServer::Ptr server);
int NewClientHandler(const NewClientEventArgs& ncea);
} }
#endif /* ENDPOINTMANAGER_H */ #endif /* ENDPOINTMANAGER_H */

View File

@ -30,29 +30,6 @@ namespace icinga
*/ */
class I2_ICINGA_API IcingaApplication : public Application class I2_ICINGA_API IcingaApplication : public Application
{ {
private:
EndpointManager::Ptr m_EndpointManager;
string m_PrivateKeyFile;
string m_PublicKeyFile;
string m_CAKeyFile;
string m_Node;
string m_Service;
int NewComponentHandler(const EventArgs& ea);
int DeletedComponentHandler(const EventArgs& ea);
int NewIcingaConfigHandler(const EventArgs& ea);
int DeletedIcingaConfigHandler(const EventArgs& ea);
int NewRpcListenerHandler(const EventArgs& ea);
int DeletedRpcListenerHandler(const EventArgs& ea);
int NewRpcConnectionHandler(const EventArgs& ea);
int DeletedRpcConnectionHandler(const EventArgs& ea);
int TestTimerHandler(const TimerEventArgs& tea);
public: public:
typedef shared_ptr<IcingaApplication> Ptr; typedef shared_ptr<IcingaApplication> Ptr;
typedef weak_ptr<IcingaApplication> WeakPtr; typedef weak_ptr<IcingaApplication> WeakPtr;
@ -75,6 +52,27 @@ public:
void SetService(string service); void SetService(string service);
string GetService(void) const; string GetService(void) const;
private:
EndpointManager::Ptr m_EndpointManager;
string m_PrivateKeyFile;
string m_PublicKeyFile;
string m_CAKeyFile;
string m_Node;
string m_Service;
int NewComponentHandler(const EventArgs& ea);
int DeletedComponentHandler(const EventArgs& ea);
int NewIcingaConfigHandler(const EventArgs& ea);
int DeletedIcingaConfigHandler(const EventArgs& ea);
int NewRpcListenerHandler(const EventArgs& ea);
int DeletedRpcListenerHandler(const EventArgs& ea);
int NewRpcConnectionHandler(const EventArgs& ea);
int DeletedRpcConnectionHandler(const EventArgs& ea);
}; };
} }

View File

@ -31,17 +31,6 @@ namespace icinga
*/ */
class I2_ICINGA_API JsonRpcEndpoint : public Endpoint class I2_ICINGA_API JsonRpcEndpoint : public Endpoint
{ {
private:
shared_ptr<SSL_CTX> m_SSLContext;
string m_Address;
JsonRpcClient::Ptr m_Client;
map<string, Endpoint::Ptr> m_PendingCalls;
int NewMessageHandler(const NewMessageEventArgs& nmea);
int ClientClosedHandler(const EventArgs& ea);
int ClientErrorHandler(const SocketErrorEventArgs& ea);
int VerifyCertificateHandler(const VerifyCertificateEventArgs& ea);
public: public:
typedef shared_ptr<JsonRpcEndpoint> Ptr; typedef shared_ptr<JsonRpcEndpoint> Ptr;
typedef weak_ptr<JsonRpcEndpoint> WeakPtr; typedef weak_ptr<JsonRpcEndpoint> WeakPtr;
@ -62,6 +51,17 @@ public:
virtual void ProcessResponse(Endpoint::Ptr sender, const ResponseMessage& message); virtual void ProcessResponse(Endpoint::Ptr sender, const ResponseMessage& message);
virtual void Stop(void); virtual void Stop(void);
private:
shared_ptr<SSL_CTX> m_SSLContext;
string m_Address;
JsonRpcClient::Ptr m_Client;
map<string, Endpoint::Ptr> m_PendingCalls;
int NewMessageHandler(const NewMessageEventArgs& nmea);
int ClientClosedHandler(const EventArgs& ea);
int ClientErrorHandler(const SocketErrorEventArgs& ea);
int VerifyCertificateHandler(const VerifyCertificateEventArgs& ea);
}; };
} }

View File

@ -41,9 +41,6 @@ struct I2_ICINGA_API NewRequestEventArgs : public EventArgs
*/ */
class I2_ICINGA_API VirtualEndpoint : public Endpoint class I2_ICINGA_API VirtualEndpoint : public Endpoint
{ {
private:
map< string, Observable<NewRequestEventArgs> > m_TopicHandlers;
public: public:
typedef shared_ptr<VirtualEndpoint> Ptr; typedef shared_ptr<VirtualEndpoint> Ptr;
typedef weak_ptr<VirtualEndpoint> WeakPtr; typedef weak_ptr<VirtualEndpoint> WeakPtr;
@ -60,6 +57,9 @@ public:
virtual void ProcessResponse(Endpoint::Ptr sender, const ResponseMessage& message); virtual void ProcessResponse(Endpoint::Ptr sender, const ResponseMessage& message);
virtual void Stop(void); virtual void Stop(void);
private:
map< string, Observable<NewRequestEventArgs> > m_TopicHandlers;
}; };
} }

View File

@ -40,9 +40,6 @@ struct I2_JSONRPC_API NewMessageEventArgs : public EventArgs
*/ */
class I2_JSONRPC_API JsonRpcClient : public TlsClient class I2_JSONRPC_API JsonRpcClient : public TlsClient
{ {
private:
int DataAvailableHandler(const EventArgs&);
public: public:
typedef shared_ptr<JsonRpcClient> Ptr; typedef shared_ptr<JsonRpcClient> Ptr;
typedef weak_ptr<JsonRpcClient> WeakPtr; typedef weak_ptr<JsonRpcClient> WeakPtr;
@ -54,6 +51,9 @@ public:
virtual void Start(void); virtual void Start(void);
Observable<NewMessageEventArgs> OnNewMessage; Observable<NewMessageEventArgs> OnNewMessage;
private:
int DataAvailableHandler(const EventArgs&);
}; };
JsonRpcClient::Ptr JsonRpcClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext); JsonRpcClient::Ptr JsonRpcClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext);

View File

@ -34,12 +34,6 @@ typedef ::cJSON json_t;
*/ */
class I2_JSONRPC_API MessagePart class I2_JSONRPC_API MessagePart
{ {
private:
Dictionary::Ptr m_Dictionary;
static Dictionary::Ptr GetDictionaryFromJson(json_t *json);
static json_t *GetJsonFromDictionary(const Dictionary::Ptr& dictionary);
public: public:
MessagePart(void); MessagePart(void);
MessagePart(string json); MessagePart(string json);
@ -93,6 +87,12 @@ public:
DictionaryIterator Begin(void); DictionaryIterator Begin(void);
DictionaryIterator End(void); DictionaryIterator End(void);
private:
Dictionary::Ptr m_Dictionary;
static Dictionary::Ptr GetDictionaryFromJson(json_t *json);
static json_t *GetJsonFromDictionary(const Dictionary::Ptr& dictionary);
}; };
} }

View File

@ -39,12 +39,12 @@ DEFINE_EXCEPTION_CLASS(InvalidNetstringException);
*/ */
class I2_JSONRPC_API Netstring class I2_JSONRPC_API Netstring
{ {
private:
Netstring(void);
public: public:
static bool ReadStringFromFIFO(FIFO::Ptr fifo, string *message); static bool ReadStringFromFIFO(FIFO::Ptr fifo, string *message);
static void WriteStringToFIFO(FIFO::Ptr fifo, const string& message); static void WriteStringToFIFO(FIFO::Ptr fifo, const string& message);
private:
Netstring(void);
}; };
} }