typedef shared_ptr<Application> Ptr;
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);
void AddComponentSearchDir(const string& componentDirectory);
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 */
};
}
*/
class I2_BASE_API Component : public Object
{
-private:
- ConfigObject::Ptr m_Config;
-
public:
typedef shared_ptr<Component> Ptr;
typedef weak_ptr<Component> WeakPtr;
virtual string GetName(void) const = 0;
virtual void Start(void) = 0;
virtual void Stop(void) = 0;
+
+private:
+ ConfigObject::Ptr m_Config;
};
typedef Component *(*CreateComponentFunction)(void);
*/
class I2_BASE_API ConfigCollection : public Object
{
-private:
- weak_ptr<ConfigHive> m_Hive;
-
public:
typedef shared_ptr<ConfigCollection> Ptr;
typedef weak_ptr<ConfigCollection> WeakPtr;
Observable<EventArgs> OnObjectCommitted;
Observable<EventArgs> OnObjectRemoved;
+
+private:
+ weak_ptr<ConfigHive> m_Hive;
+
};
}
*/
class I2_BASE_API ConfigObject : public Dictionary
{
-private:
- weak_ptr<ConfigHive> m_Hive;
-
- string m_Name;
- string m_Type;
- bool m_Replicated;
-
public:
typedef shared_ptr<ConfigObject> Ptr;
typedef weak_ptr<ConfigObject> WeakPtr;
bool GetReplicated(void) const;
void Commit(void);
+
+private:
+ weak_ptr<ConfigHive> m_Hive;
+
+ string m_Name;
+ string m_Type;
+ bool m_Replicated;
};
}
*/
class I2_BASE_API Dictionary : public Object
{
-private:
- map<string, Variant> m_Data;
-
public:
typedef shared_ptr<Dictionary> Ptr;
typedef weak_ptr<Dictionary> WeakPtr;
DictionaryIterator End(void);
long GetLength(void) const;
+
+private:
+ map<string, Variant> m_Data;
};
}
*/
class I2_BASE_API Exception : public exception
{
-private:
- char *m_Message;
-
-protected:
- void SetMessage(const char *message);
-
public:
Exception(void);
Exception(const char *message);
const char *GetMessage(void) const;
virtual const char *what(void) const throw();
+
+protected:
+ void SetMessage(const char *message);
+
+private:
+ char *m_Message;
};
#define DEFINE_EXCEPTION_CLASS(klass) \
*/
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:
static const size_t BlockSize = 16 * 1024;
size_t Read(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);
};
}
* @mainpage Icinga Documentation
*
* Icinga implements a framework for run-time-loadable components which can
- * pass messages between them. These components can either be hosted in the
- * same process or in several host processes (either on the same machine or
+ * pass messages between each other. These components can either be hosted in
+ * the same process or in several host processes (either on the same machine or
* on different machines).
*
* The framework's code critically depends on the following patterns:
* <item>Smart pointers
*
* 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
*
*/
class I2_BASE_API Memory
{
-private:
- Memory(void);
-
public:
static void *Allocate(size_t size);
static void *Reallocate(void *ptr, size_t size);
static char *StrDup(const char *str);
static void Free(void *ptr);
+
+private:
+ Memory(void);
};
}
*
* @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:
- Object(const Object& other);
- Object operator=(const Object& rhs);
+public:
+ typedef shared_ptr<Object> Ptr;
+ typedef weak_ptr<Object> WeakPtr;
protected:
Object(void);
virtual ~Object(void);
-public:
- typedef shared_ptr<Object> Ptr;
- typedef weak_ptr<Object> WeakPtr;
+private:
+ Object(const Object& other);
+ Object operator=(const Object& rhs);
};
/**
public:
typedef function<int (const TArgs&)> ObserverType;
-private:
- vector<ObserverType> m_Observers;
-
-public:
/**
* Adds an observer to this event.
*
i++;
}
}
+
+private:
+ vector<ObserverType> m_Observers;
};
}
*/
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:
typedef shared_ptr<Socket> Ptr;
typedef weak_ptr<Socket> WeakPtr;
string GetClientAddress(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);
};
}
*/
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:
typedef shared_ptr<TcpClient> Ptr;
typedef weak_ptr<TcpClient> WeakPtr;
virtual bool WantsToWrite(void) const;
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);
};
/**
*/
class I2_BASE_API TcpServer : public TcpSocket
{
-private:
- int ReadableEventHandler(const EventArgs& ea);
-
- function<TcpClient::Ptr()> m_ClientFactory;
-
public:
typedef shared_ptr<TcpServer> Ptr;
typedef weak_ptr<TcpServer> WeakPtr;
Observable<NewClientEventArgs> OnNewClient;
virtual bool WantsToRead(void) const;
+
+private:
+ int ReadableEventHandler(const EventArgs& ea);
+
+ function<TcpClient::Ptr()> m_ClientFactory;
};
}
*/
class I2_BASE_API TcpSocket : public Socket
{
-private:
- void MakeSocket(int family);
-
public:
typedef shared_ptr<TcpSocket> Ptr;
typedef weak_ptr<TcpSocket> WeakPtr;
void Bind(string service, int family);
void Bind(string node, string service, int family);
+
+private:
+ void MakeSocket(int family);
};
}
*/
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:
typedef shared_ptr<Timer> Ptr;
typedef weak_ptr<Timer> WeakPtr;
void Reschedule(time_t next);
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);
};
}
*/
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:
shared_ptr<SSL_CTX> m_SSLContext;
shared_ptr<SSL> m_SSL;
static void NullCertificateDeleter(X509 *certificate);
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);
*/
class I2_BASE_API Utility
{
-private:
- static bool m_SSLInitialized;
-
- Utility(void);
-
- static void InitializeOpenSSL(void);
-
public:
/**
* Returns a human-readable type name of an object (using RTTI).
static shared_ptr<X509> GetX509Certificate(string pemfile);
static bool Match(string pattern, string text);
+
+private:
+ static bool m_SSLInitialized;
+
+ Utility(void);
+
+ static void InitializeOpenSSL(void);
};
}
*/
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:
inline Variant(void) : m_Type(VariantEmpty) { }
operator long(void) const;
operator string(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;
};
}
*/
class DemoComponent : public IcingaComponent
{
+public:
+ virtual string GetName(void) const;
+ virtual void Start(void);
+ virtual void Stop(void);
+
private:
Timer::Ptr m_DemoTimer;
VirtualEndpoint::Ptr m_DemoEndpoint;
int DemoTimerHandler(const TimerEventArgs& tea);
int HelloWorldRequestHandler(const NewRequestEventArgs& nrea);
-
-public:
- virtual string GetName(void) const;
- virtual void Start(void);
- virtual void Stop(void);
};
}
*/
class DiscoveryComponent : public IcingaComponent
{
+public:
+ virtual string GetName(void) const;
+ virtual void Start(void);
+ virtual void Stop(void);
+
private:
VirtualEndpoint::Ptr m_DiscoveryEndpoint;
map<string, ComponentDiscoveryInfo::Ptr> m_Components;
bool HasMessagePermission(Dictionary::Ptr roles, string messageType, string message);
static const int RegistrationTTL = 300;
-
-public:
- virtual string GetName(void) const;
- virtual void Start(void);
- virtual void Stop(void);
};
}
*/
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:
typedef shared_ptr<Endpoint> Ptr;
typedef weak_ptr<Endpoint> WeakPtr;
Observable<EventArgs> OnIdentityChanged;
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. */
};
}
*/
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:
typedef shared_ptr<EndpointManager> Ptr;
typedef weak_ptr<EndpointManager> WeakPtr;
Endpoint::Ptr GetEndpointByIdentity(string identity) const;
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 */
*/
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:
typedef shared_ptr<IcingaApplication> Ptr;
typedef weak_ptr<IcingaApplication> WeakPtr;
void SetService(string service);
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);
};
}
*/
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:
typedef shared_ptr<JsonRpcEndpoint> Ptr;
typedef weak_ptr<JsonRpcEndpoint> WeakPtr;
virtual void ProcessResponse(Endpoint::Ptr sender, const ResponseMessage& message);
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);
};
}
*/
class I2_ICINGA_API VirtualEndpoint : public Endpoint
{
-private:
- map< string, Observable<NewRequestEventArgs> > m_TopicHandlers;
-
public:
typedef shared_ptr<VirtualEndpoint> Ptr;
typedef weak_ptr<VirtualEndpoint> WeakPtr;
virtual void ProcessResponse(Endpoint::Ptr sender, const ResponseMessage& message);
virtual void Stop(void);
+
+private:
+ map< string, Observable<NewRequestEventArgs> > m_TopicHandlers;
};
}
*/
class I2_JSONRPC_API JsonRpcClient : public TlsClient
{
-private:
- int DataAvailableHandler(const EventArgs&);
-
public:
typedef shared_ptr<JsonRpcClient> Ptr;
typedef weak_ptr<JsonRpcClient> WeakPtr;
virtual void Start(void);
Observable<NewMessageEventArgs> OnNewMessage;
+
+private:
+ int DataAvailableHandler(const EventArgs&);
};
JsonRpcClient::Ptr JsonRpcClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext);
*/
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:
MessagePart(void);
MessagePart(string json);
DictionaryIterator Begin(void);
DictionaryIterator End(void);
+
+private:
+ Dictionary::Ptr m_Dictionary;
+
+ static Dictionary::Ptr GetDictionaryFromJson(json_t *json);
+ static json_t *GetJsonFromDictionary(const Dictionary::Ptr& dictionary);
};
}
*/
class I2_JSONRPC_API Netstring
{
-private:
- Netstring(void);
-
public:
static bool ReadStringFromFIFO(FIFO::Ptr fifo, string *message);
static void WriteStringToFIFO(FIFO::Ptr fifo, const string& message);
+
+private:
+ Netstring(void);
};
}