From: Gunnar Beutner Date: Tue, 8 May 2012 13:14:20 +0000 (+0200) Subject: Updated documentation for some of the classes. X-Git-Tag: v0.0.1~550 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bef85cac1aba2a7d69bb0e68ec71ae04d1bc14a6;p=icinga2 Updated documentation for some of the classes. --- diff --git a/base/dictionary.cpp b/base/dictionary.cpp index b1d9cfc91..02e0581f2 100644 --- a/base/dictionary.cpp +++ b/base/dictionary.cpp @@ -2,6 +2,15 @@ using namespace icinga; +/** + * GetProperty + * + * Retrieves a value from the dictionary. + * + * @param key The key. + * @param value Pointer to the value. + * @returns true if the value was retrieved, false otherwise. + */ bool Dictionary::GetProperty(string key, Variant *value) const { ConstDictionaryIterator i = m_Data.find(key); @@ -13,6 +22,14 @@ bool Dictionary::GetProperty(string key, Variant *value) const return true; } +/** + * SetProperty + * + * Sets a value in the dictionary. + * + * @param key The key. + * @param value The value. + */ void Dictionary::SetProperty(string key, const Variant& value) { DictionaryIterator i = m_Data.find(key); @@ -33,6 +50,15 @@ void Dictionary::SetProperty(string key, const Variant& value) OnPropertyChanged(dpce); } +/** + * GetPropertyString + * + * Retrieves a value from the dictionary and converts it to a string. + * + * @param key The key. + * @param value Pointer to the value. + * @returns true if the value was retrieved, false otherwise. + */ bool Dictionary::GetPropertyString(string key, string *value) { Variant data; @@ -44,11 +70,28 @@ bool Dictionary::GetPropertyString(string key, string *value) return true; } +/** + * SetPropertyString + * + * Sets a value in the dictionary. + * + * @param key The key. + * @param value The value. + */ void Dictionary::SetPropertyString(string key, const string& value) { SetProperty(key, Variant(value)); } +/** + * GetPropertyInteger + * + * Retrieves a value from the dictionary and converts it to an integer. + * + * @param key The key. + * @param value Pointer to the value. + * @returns true if the value was retrieved, false otherwise. + */ bool Dictionary::GetPropertyInteger(string key, long *value) { Variant data; @@ -60,11 +103,28 @@ bool Dictionary::GetPropertyInteger(string key, long *value) return true; } +/** + * SetPropertyInteger + * + * Sets a value in the dictionary. + * + * @param key The key. + * @param value The value. + */ void Dictionary::SetPropertyInteger(string key, long value) { SetProperty(key, Variant(value)); } +/** + * GetPropertyDictionary + * + * Retrieves a value from the dictionary and converts it to a dictionary. + * + * @param key The key. + * @param value Pointer to the value. + * @returns true if the value was retrieved, false otherwise. + */ bool Dictionary::GetPropertyDictionary(string key, Dictionary::Ptr *value) { Dictionary::Ptr dictionary; @@ -83,11 +143,28 @@ bool Dictionary::GetPropertyDictionary(string key, Dictionary::Ptr *value) return true; } +/** + * SetPropertyDictionary + * + * Sets a value in the dictionary. + * + * @param key The key. + * @param value The value. + */ void Dictionary::SetPropertyDictionary(string key, const Dictionary::Ptr& value) { SetProperty(key, Variant(value)); } +/** + * GetPropertyObject + * + * Retrieves a value from the dictionary and converts it to an object. + * + * @param key The key. + * @param value Pointer to the value. + * @returns true if the value was retrieved, false otherwise. + */ bool Dictionary::GetPropertyObject(string key, Object::Ptr *value) { Variant data; @@ -99,26 +176,62 @@ bool Dictionary::GetPropertyObject(string key, Object::Ptr *value) return true; } +/** + * SetPropertyObject + * + * Sets a value in the dictionary. + * + * @param key The key. + * @param value The value. + */ void Dictionary::SetPropertyObject(string key, const Object::Ptr& value) { SetProperty(key, Variant(value)); } +/** + * Begin + * + * Returns an iterator to the beginning of the dictionary. + * + * @returns An iterator. + */ DictionaryIterator Dictionary::Begin(void) { return m_Data.begin(); } +/** + * End + * + * Returns an iterator to the end of the dictionary. + * + * @returns An iterator. + */ DictionaryIterator Dictionary::End(void) { return m_Data.end(); } +/** + * GetLength + * + * Returns the number of elements in the dictionary. + * + * @returns Number of elements. + */ long Dictionary::GetLength(void) const { return m_Data.size(); } +/** + * AddUnnamedProperty + * + * Adds an unnamed value to the dictionary. + * + * @param value The value. + */ void Dictionary::AddUnnamedProperty(const Variant& value) { map::const_iterator it; @@ -136,21 +249,49 @@ void Dictionary::AddUnnamedProperty(const Variant& value) m_Data[key] = value; } +/** + * AddUnnamedPropertyString + * + * Adds an unnamed value to the dictionary. + * + * @param value The value. + */ void Dictionary::AddUnnamedPropertyString(const string& value) { AddUnnamedProperty(Variant(value)); } +/** + * AddUnnamedPropertyInteger + * + * Adds an unnamed value to the dictionary. + * + * @param value The value. + */ void Dictionary::AddUnnamedPropertyInteger(long value) { AddUnnamedProperty(Variant(value)); } +/** + * AddUnnamedPropertyDictionary + * + * Adds an unnamed value to the dictionary. + * + * @param value The value. + */ void Dictionary::AddUnnamedPropertyDictionary(const Dictionary::Ptr& value) { AddUnnamedProperty(Variant(value)); } +/** + * AddUnnamedPropertyObject + * + * Adds an unnamed value to the dictionary. + * + * @param value The value. + */ void Dictionary::AddUnnamedPropertyObject(const Object::Ptr& value) { AddUnnamedProperty(Variant(value)); diff --git a/base/event.h b/base/event.h index 9628142af..f156d3fa2 100644 --- a/base/event.h +++ b/base/event.h @@ -19,18 +19,40 @@ private: vector m_Delegates; public: + /** + * operator += + * + * Adds a delegate to this event. + * + * @param rhs The delegate. + */ Event& operator +=(const DelegateType& rhs) { m_Delegates.push_back(rhs); return *this; } + /** + * operator -= + * + * Removes a delegate from this event. + * + * @param rhs The delegate. + */ Event& operator -=(const DelegateType& rhs) { m_Delegates.erase(rhs); return *this; } + /** + * operator () + * + * Invokes each delegate that is registered for this event. Any delegates + * which return -1 are removed. + * + * @param args Event arguments. + */ void operator()(const TArgs& args) { typename vector::iterator i; diff --git a/base/exception.cpp b/base/exception.cpp index febf609e8..da155561a 100644 --- a/base/exception.cpp +++ b/base/exception.cpp @@ -2,26 +2,60 @@ using namespace icinga; +/** + * Exception + * + * Default constructor for the Exception class. + */ Exception::Exception(void) { } +/** + * Exception + * + * Constructor for the exception class. + * + * @param message A message describing the exception. + */ Exception::Exception(const string& message) { SetMessage(message); } +/** + * GetMessage + * + * Retrieves the description for the exception. + * + * @returns The description. + */ string Exception::GetMessage(void) const { return m_Message; } +/** + * SetMessage + * + * Sets the description for the exception. + * + * @param message The description. + */ void Exception::SetMessage(string message) { m_Message = message; } #ifdef _WIN32 +/** + * FormatError + * + * Formats an Win32 error code. + * + * @param code The error code. + * @returns A string describing the error. + */ string Win32Exception::FormatErrorCode(int code) { char *message; @@ -40,11 +74,27 @@ string Win32Exception::FormatErrorCode(int code) } #endif /* _WIN32 */ +/** + * FormatError + * + * Formats a Posix error code. + * + * @param code The error code. + * @returns A string describing the error. + */ string PosixException::FormatErrorCode(int code) { return strerror(code); } +/** + * FormatError + * + * Formats an OpenSSL error code. + * + * @param code The error code. + * @returns A string describing the error. + */ string OpenSSLException::FormatErrorCode(int code) { const char *message = ERR_error_string(code, NULL); diff --git a/base/fifo.cpp b/base/fifo.cpp index 5abbdd06b..810c20413 100644 --- a/base/fifo.cpp +++ b/base/fifo.cpp @@ -2,6 +2,11 @@ using namespace icinga; +/** + * FIFO + * + * Constructor for the FIFO class. + */ FIFO::FIFO(void) { m_Buffer = NULL; @@ -10,11 +15,23 @@ FIFO::FIFO(void) m_Offset = 0; } +/** + * ~FIFO + * + * Destructor for the FIFO class. + */ FIFO::~FIFO(void) { Memory::Free(m_Buffer); } +/** + * ResizeBuffer + * + * Resizes the FIFO's buffer so that it is at least newSize bytes long. + * + * @param newSize The minimum new size of the FIFO buffer. + */ void FIFO::ResizeBuffer(size_t newSize) { if (m_AllocSize >= newSize) @@ -26,6 +43,12 @@ void FIFO::ResizeBuffer(size_t newSize) m_AllocSize = newSize; } +/** + * Optimize + * + * Optimizes memory usage of the FIFO buffer by reallocating + * and moving the buffer. + */ void FIFO::Optimize(void) { //char *newBuffer; @@ -50,16 +73,40 @@ void FIFO::Optimize(void) m_Offset = 0;*/ } +/** + * GetSize + * + * Returns the number of bytes that are contained in the FIFO. + * + * @returns The number of bytes. + */ size_t FIFO::GetSize(void) const { return m_DataSize; } +/** + * GetReadBuffer + * + * Returns a pointer to the start of the read buffer. + * + * @returns Pointer to the read buffer. + */ const void *FIFO::GetReadBuffer(void) const { return m_Buffer + m_Offset; } +/** + * Read + * + * Reads data from the FIFO and places it in the specified buffer. + * + * @param buffer The buffer where the data should be placed (can be NULL if + * the reader is not interested in the data). + * @param count The number of bytes to read. + * @returns The number of bytes read which may be less than what was requested. + */ size_t FIFO::Read(void *buffer, size_t count) { count = (count <= m_DataSize) ? count : m_DataSize; @@ -75,6 +122,15 @@ size_t FIFO::Read(void *buffer, size_t count) return count; } +/** + * GetWriteBuffer + * + * Returns a pointer to the start of the write buffer. + * + * @param count Minimum size of the buffer; on return this parameter + * contains the actual size of the available buffer which can + * be larger than the requested size. + */ void *FIFO::GetWriteBuffer(size_t *count) { ResizeBuffer(m_Offset + m_DataSize + *count); @@ -83,6 +139,16 @@ void *FIFO::GetWriteBuffer(size_t *count) return m_Buffer + m_Offset + m_DataSize; } +/** + * Write + * + * Writes data to the FIFO. + * + * @param buffer The data that is to be written (can be NULL if the writer has + * already filled the write buffer, e.g. via GetWriteBuffer()). + * @param count The number of bytes to write. + * @returns The number of bytes written + */ size_t FIFO::Write(const void *buffer, size_t count) { if (buffer != NULL) { diff --git a/base/memory.cpp b/base/memory.cpp index b14505ad6..71454f648 100644 --- a/base/memory.cpp +++ b/base/memory.cpp @@ -2,10 +2,24 @@ using namespace icinga; +/** + * Memory + * + * Constructor for the memory class. + */ Memory::Memory(void) { } +/** + * Allocate + * + * Allocates memory. Throws an exception if no memory is available. Alignment + * guarantees are the same like for malloc(). + * + * @param size The size of the requested memory block. + * @returns A new block of memory. + */ void *Memory::Allocate(size_t size) { void *ptr = malloc(size); @@ -16,6 +30,15 @@ void *Memory::Allocate(size_t size) return ptr; } +/** + * Reallocate + * + * Resizes a block of memory. Throws an exception if no memory is available. + * + * @param ptr The old memory block or NULL. + * @param size The requested new size of the block. + * @returns A pointer to the new memory block. + */ void *Memory::Reallocate(void *ptr, size_t size) { void *new_ptr = realloc(ptr, size); @@ -26,6 +49,14 @@ void *Memory::Reallocate(void *ptr, size_t size) return new_ptr; } +/** + * StrDup + * + * Duplicates a string. Throws an exception if no memory is available. + * + * @param str The string. + * @returns A copy of the string. + */ char *Memory::StrDup(const char *str) { char *new_str = strdup(str); @@ -36,6 +67,13 @@ char *Memory::StrDup(const char *str) return new_str; } +/** + * Free + * + * Frees a memory block. + * + * @param ptr The memory block. + */ void Memory::Free(void *ptr) { if (ptr != NULL) diff --git a/base/mutex.cpp b/base/mutex.cpp index 9a49e5b90..42c0cf72b 100644 --- a/base/mutex.cpp +++ b/base/mutex.cpp @@ -2,6 +2,11 @@ using namespace icinga; +/** + * Mutex + * + * Constructor for the Mutex class. + */ Mutex::Mutex(void) { #ifdef _WIN32 @@ -11,6 +16,11 @@ Mutex::Mutex(void) #endif /* _WIN32 */ } +/** + * ~Mutex + * + * Destructor for the Mutex class. + */ Mutex::~Mutex(void) { #ifdef _WIN32 @@ -20,6 +30,14 @@ Mutex::~Mutex(void) #endif /* _WIN32 */ } +/** + * TryEnter + * + * Tries to lock the mutex. If the mutex cannot be immediatelly + * locked the operation fails. + * + * @returns true if the operation succeeded, false otherwise. + */ bool Mutex::TryEnter(void) { #ifdef _WIN32 @@ -29,6 +47,11 @@ bool Mutex::TryEnter(void) #endif /* _WIN32 */ } +/** + * Enter + * + * Locks the mutex. + */ void Mutex::Enter(void) { #ifdef _WIN32 @@ -38,6 +61,11 @@ void Mutex::Enter(void) #endif /* _WIN32 */ } +/** + * Exit + * + * Unlocks the mutex. + */ void Mutex::Exit(void) { #ifdef _WIN32 @@ -47,6 +75,13 @@ void Mutex::Exit(void) #endif /* _WIN32 */ } +/** + * Get + * + * Retrieves the platform-specific mutex handle. + * + * @returns The platform-specific mutex handle. + */ #ifdef _WIN32 CRITICAL_SECTION *Mutex::Get(void) #else /* _WIN32 */ diff --git a/base/socket.cpp b/base/socket.cpp index 7be38071a..9fb62556a 100644 --- a/base/socket.cpp +++ b/base/socket.cpp @@ -2,18 +2,39 @@ using namespace icinga; +/** + * Socket::Sockets + * + * A collection of weak pointers to Socket objects which have been + * registered with the socket sub-system. + */ Socket::CollectionType Socket::Sockets; +/** + * Socket + * + * Constructor for the Socket class. + */ Socket::Socket(void) { m_FD = INVALID_SOCKET; } +/** + * ~Socket + * + * Destructor for the Socket class. + */ Socket::~Socket(void) { CloseInternal(true); } +/** + * Start + * + * Registers the socket and starts handling events for it. + */ void Socket::Start(void) { assert(m_FD != INVALID_SOCKET); @@ -23,11 +44,23 @@ void Socket::Start(void) Sockets.push_back(static_pointer_cast(shared_from_this())); } +/** + * Stop + * + * Unregisters the sockets and stops handling events for it. + */ void Socket::Stop(void) { Sockets.remove_if(weak_ptr_eq_raw(this)); } +/** + * SetFD + * + * Sets the file descriptor for this socket object. + * + * @param fd The file descriptor. + */ void Socket::SetFD(SOCKET fd) { unsigned long lTrue = 1; @@ -38,16 +71,35 @@ void Socket::SetFD(SOCKET fd) m_FD = fd; } +/** + * GetFD + * + * Retrieves the file descriptor for this socket object. + * + * @returns The file descriptor. + */ SOCKET Socket::GetFD(void) const { return m_FD; } +/** + * Close + * + * Closes the socket. + */ void Socket::Close(void) { CloseInternal(false); } +/** + * CloseInternal + * + * Closes the socket. + * + * @param from_dtor Whether this method was called from the destructor. + */ void Socket::CloseInternal(bool from_dtor) { if (m_FD == INVALID_SOCKET) @@ -67,6 +119,11 @@ void Socket::CloseInternal(bool from_dtor) } } +/** + * HandleSocketError + * + * Handles a socket error by calling the OnError event. + */ void Socket::HandleSocketError(void) { int opt; @@ -89,6 +146,14 @@ void Socket::HandleSocketError(void) return; } +/** + * ExceptionEventHandler + * + * Processes errors that have occured for the socket. + * + * @param ea Event arguments for the socket error. + * @returns 0 + */ int Socket::ExceptionEventHandler(const EventArgs& ea) { HandleSocketError(); @@ -96,16 +161,37 @@ int Socket::ExceptionEventHandler(const EventArgs& ea) return 0; } +/** + * WantsToRead + * + * Checks whether data should be read for this socket object. + * + * @returns true if the socket should be registered for reading, false otherwise. + */ bool Socket::WantsToRead(void) const { return false; } +/** + * WantsToWrite + * + * Checks whether data should be written for this socket object. + * + * @returns true if the socket should be registered for writing, false otherwise. + */ bool Socket::WantsToWrite(void) const { return false; } +/** + * GetAddressFromSockaddr + * + * Formats a sockaddr in a human-readable way. + * + * @returns A string describing the sockaddr. + */ string Socket::GetAddressFromSockaddr(sockaddr *address, socklen_t len) { char host[NI_MAXHOST]; @@ -119,6 +205,13 @@ string Socket::GetAddressFromSockaddr(sockaddr *address, socklen_t len) return s.str(); } +/** + * GetClientAddress + * + * Returns a string describing the local address of the socket. + * + * @returns A string describing the local address. + */ string Socket::GetClientAddress(void) { sockaddr_storage sin; @@ -133,6 +226,13 @@ string Socket::GetClientAddress(void) return GetAddressFromSockaddr((sockaddr *)&sin, len); } +/** + * GetPeerAddress + * + * Returns a string describing the peer address of the socket. + * + * @returns A string describing the peer address. + */ string Socket::GetPeerAddress(void) { sockaddr_storage sin; diff --git a/base/tcpsocket.cpp b/base/tcpsocket.cpp index e6bfe5d70..d94e56146 100644 --- a/base/tcpsocket.cpp +++ b/base/tcpsocket.cpp @@ -2,6 +2,13 @@ using namespace icinga; +/** + * MakeSocket + * + * Creates a socket. + * + * @param family The socket family for the new socket. + */ void TCPSocket::MakeSocket(int family) { assert(GetFD() == INVALID_SOCKET); @@ -17,11 +24,27 @@ void TCPSocket::MakeSocket(int family) SetFD(fd); } +/** + * Bind + * + * Creates a socket and binds it to the specified service. + * + * @param service The service. + * @param family The address family for the socket. + */ void TCPSocket::Bind(string service, int family) { Bind(string(), service, family); } +/** + * Bind + * + * Creates a socket and binds it to the specified node and service. + * + * @param service The service. + * @param family The address family for the socket. + */ void TCPSocket::Bind(string node, string service, int family) { addrinfo hints; diff --git a/base/timer.cpp b/base/timer.cpp index 6a94ac340..7e55c5667 100644 --- a/base/timer.cpp +++ b/base/timer.cpp @@ -7,11 +7,21 @@ using namespace icinga; time_t Timer::NextCall; Timer::CollectionType Timer::Timers; +/** + * Constructor for the Timer class. + */ Timer::Timer(void) { m_Interval = 0; } +/** + * GetNextCall + * + * Retrieves when the next timer is due. + * + * @returns Time when the next timer is due. + */ time_t Timer::GetNextCall(void) { if (NextCall < time(NULL)) @@ -20,6 +30,12 @@ time_t Timer::GetNextCall(void) return NextCall; } +/** + * RescheduleTimers + * + * Reschedules all timers, thereby updating the NextCall + * timestamp used by the GetNextCall() function. + */ void Timer::RescheduleTimers(void) { /* Make sure we wake up at least once every 30 seconds */ @@ -36,6 +52,11 @@ void Timer::RescheduleTimers(void) } } +/** + * CallExpiredTimers + * + * Calls all expired timers and reschedules them. + */ void Timer::CallExpiredTimers(void) { time_t now; @@ -61,8 +82,13 @@ void Timer::CallExpiredTimers(void) } } -/* Note: the timer delegate must not call Disable() on any other timers than - * the timer that originally invoked the delegate */ +/** + * Call + * + * Calls this timer. Note: the timer delegate must not call + * Disable() on any other timers than the timer that originally + * invoked the delegate. + */ void Timer::Call(void) { TimerEventArgs tea; @@ -71,27 +97,59 @@ void Timer::Call(void) OnTimerExpired(tea); } +/** + * SetInterval + * + * Sets the interval for this timer. + * + * @param interval The new interval. + */ void Timer::SetInterval(unsigned int interval) { m_Interval = interval; } +/** + * GetInterval + * + * Retrieves the interval for this timer. + * + * @returns The interval. + */ unsigned int Timer::GetInterval(void) const { return m_Interval; } +/** + * SetUserArgs + * + * Sets user arguments for the timer callback. + * + * @param userArgs The user arguments. + */ void Timer::SetUserArgs(const EventArgs& userArgs) { m_UserArgs = userArgs; } - +/** + * GetUserArgs + * + * Retrieves the user arguments for the timer callback. + * + * @returns The user arguments. + */ EventArgs Timer::GetUserArgs(void) const { return m_UserArgs; } +/** + * Start + * + * Registers the timer and starts processing events for it. + */ void Timer::Start(void) { Timers.push_back(static_pointer_cast(shared_from_this())); @@ -99,11 +157,23 @@ void Timer::Start(void) Reschedule(time(NULL) + m_Interval); } +/** + * Stop + * + * Unregisters the timer and stops processing events for it. + */ void Timer::Stop(void) { Timers.remove_if(weak_ptr_eq_raw(this)); } +/** + * Reschedule + * + * Reschedules this timer. + * + * @param next The time when this timer should be called again. + */ void Timer::Reschedule(time_t next) { m_Next = next; diff --git a/base/unix.cpp b/base/unix.cpp index 3e7eca403..40787c4bd 100644 --- a/base/unix.cpp +++ b/base/unix.cpp @@ -5,11 +5,25 @@ using namespace icinga; +/** + * Sleep + * + * Sleeps for the specified amount of time. + * + * @param milliseconds The amount of time in milliseconds. + */ void Sleep(unsigned long milliseconds) { usleep(milliseconds * 1000); } +/** + * closesocket + * + * Closes a socket. + * + * @param fd The socket that is to be closed. + */ void closesocket(SOCKET fd) { close(fd); diff --git a/base/utility.cpp b/base/utility.cpp index 53919e1be..4136f81f0 100644 --- a/base/utility.cpp +++ b/base/utility.cpp @@ -43,6 +43,11 @@ void Utility::Daemonize(void) { #endif } +/** + * InitializeOpenSSL + * + * Initializes the OpenSSL library. + */ void Utility::InitializeOpenSSL(void) { if (!m_SSLInitialized) { @@ -53,6 +58,16 @@ void Utility::InitializeOpenSSL(void) } } +/** + * MakeSSLContext + * + * Initializes an SSL context using the specified certificates. + * + * @param pubkey The public key. + * @param privkey The matching private key. + * @param cakey CA certificate chain file. + * @returns An SSL context. + */ shared_ptr Utility::MakeSSLContext(string pubkey, string privkey, string cakey) { InitializeOpenSSL(); @@ -75,6 +90,14 @@ shared_ptr Utility::MakeSSLContext(string pubkey, string privkey, strin return sslContext; } +/** + * GetCertificateCN + * + * Retrieves the common name for a X509 certificate. + * + * @param certificate The X509 certificate. + * @returns The common name. + */ string Utility::GetCertificateCN(const shared_ptr& certificate) { char buffer[256]; @@ -87,6 +110,14 @@ string Utility::GetCertificateCN(const shared_ptr& certificate) return buffer; } +/** + * GetX509Certificate + * + * Retrieves an X509 certificate from the specified file. + * + * @param pemfile The filename. + * @returns An X509 certificate. + */ shared_ptr Utility::GetX509Certificate(string pemfile) { X509 *cert; diff --git a/components/configrpc/configrpccomponent.cpp b/components/configrpc/configrpccomponent.cpp index b7ea05633..20a3fccfe 100644 --- a/components/configrpc/configrpccomponent.cpp +++ b/components/configrpc/configrpccomponent.cpp @@ -43,7 +43,10 @@ void ConfigRpcComponent::Start(void) void ConfigRpcComponent::Stop(void) { - // TODO: implement + EndpointManager::Ptr mgr = GetEndpointManager(); + + if (mgr) + mgr->UnregisterEndpoint(m_ConfigRpcEndpoint); } int ConfigRpcComponent::NewEndpointHandler(const NewEndpointEventArgs& ea) diff --git a/components/demo/democomponent.cpp b/components/demo/democomponent.cpp index 1416e2225..17f15823b 100644 --- a/components/demo/democomponent.cpp +++ b/components/demo/democomponent.cpp @@ -2,11 +2,23 @@ using namespace icinga; +/** + * GetName + * + * Returns the name of the component. + * + * @returns The name. + */ string DemoComponent::GetName(void) const { return "democomponent"; } +/** + * Start + * + * Starts the component. + */ void DemoComponent::Start(void) { m_DemoEndpoint = make_shared(); @@ -23,6 +35,11 @@ void DemoComponent::Start(void) m_DemoTimer->Start(); } +/** + * Stop + * + * Stops the component. + */ void DemoComponent::Stop(void) { IcingaApplication::Ptr app = GetIcingaApplication(); @@ -33,6 +50,14 @@ void DemoComponent::Stop(void) } } +/** + * DemoTimerHandler + * + * Periodically sends a demo::HelloWorld message. + * + * @param tea Event arguments for the timer. + * @returns 0 + */ int DemoComponent::DemoTimerHandler(const TimerEventArgs& tea) { Application::Log("Sending multicast 'hello world' message."); @@ -46,6 +71,11 @@ int DemoComponent::DemoTimerHandler(const TimerEventArgs& tea) return 0; } +/** + * HelloWorldRequestHandler + * + * Processes demo::HelloWorld messages. + */ int DemoComponent::HelloWorldRequestHandler(const NewRequestEventArgs& nrea) { Application::Log("Got 'hello world' from address=" + nrea.Sender->GetAddress() + ", identity=" + nrea.Sender->GetIdentity()); diff --git a/components/discovery/discoverycomponent.cpp b/components/discovery/discoverycomponent.cpp index 49002474d..4717f47bb 100644 --- a/components/discovery/discoverycomponent.cpp +++ b/components/discovery/discoverycomponent.cpp @@ -83,7 +83,7 @@ int DiscoveryComponent::CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewE return 0; if (endpoint->GetIdentity() == neea.Endpoint->GetIdentity()) { - Application::Log("Detected duplicate identity (" + endpoint->GetIdentity() + " - Disconnecting old endpoint."); + Application::Log("Detected duplicate identity:" + endpoint->GetIdentity() + " - Disconnecting old endpoint."); neea.Endpoint->Stop(); GetEndpointManager()->UnregisterEndpoint(neea.Endpoint);