return m_Debugging;
}
+/**
+ * Checks whether we're currently on the main thread.
+ *
+ * @returns true if this is the main thread, false otherwise
+ */
bool Application::IsMainThread(void)
{
return (boost::this_thread::get_id() == m_MainThreadID);
}
+/**
+ * Sets the main thread to the currently running thread.
+ */
void Application::SetMainThread(void)
{
m_MainThreadID = boost::this_thread::get_id();
return result;
}
+/**
+ * Grabs the PID file lock and updates the PID.
+ *
+ * @param filename The name of the PID file.
+ */
void Application::UpdatePidFile(const String& filename)
{
ClosePidFile();
fflush(m_PidFile);
}
+/**
+ * Closes the PID file. Does nothing if the PID file is not currently open.
+ */
void Application::ClosePidFile(void)
{
if (m_PidFile != NULL)
m_Impl = impl;
}
+/**
+ * Destructor for the Component class.
+ */
Component::~Component(void)
{
if (m_Impl)
using namespace icinga;
+/**
+ * Compares the keys of dictionary keys using the less operator.
+ */
struct DictionaryKeyLessComparer
{
bool operator()(const pair<String, Value>& a, const char *b)
condition_variable Event::m_EventAvailable;
boost::mutex Event::m_Mutex;
+/**
+ * Constructor for the Event class
+ *
+ * @param callback The callback function for the new event object.
+ */
Event::Event(const Event::Callback& callback)
: m_Callback(callback)
{ }
+/**
+ * Waits for events using the specified timeout value and processes
+ * them.
+ *
+ * @param wait_until The wait timeout.
+ */
void Event::ProcessEvents(const system_time& wait_until)
{
vector<Event> events;
+ assert(Application::IsMainThread());
+
{
boost::mutex::scoped_lock lock(m_Mutex);
}
}
+/**
+ * Appends an event to the event queue. Events will be processed in FIFO
+ * order on the main thread.
+ *
+ * @param callback The callback function for the event.
+ */
void Event::Post(const Event::Callback& callback)
{
if (Application::IsMainThread()) {
StreamLogger::ProcessLogEntry(std::cout, entry);
}
+/**
+ * Converts a severity enum value to a string.
+ *
+ * @param severity The severity value.
+ */
String Logger::SeverityToString(LogSeverity severity)
{
switch (severity) {
}
}
+/**
+ * Converts a string to a severity enum value.
+ *
+ * @param severity The severity.
+ */
LogSeverity Logger::StringToSeverity(const String& severity)
{
if (severity == "debug")
m_HeldObjects.clear();
}
+/**
+ * Returns a reference-counted pointer to this object.
+ *
+ * @returns A shared_ptr object that points to this object
+ */
Object::SharedPtrHolder Object::GetSelf(void)
{
return Object::SharedPtrHolder(shared_from_this());
}
#ifdef _DEBUG
+/**
+ * Retrieves the number of currently alive objects.
+ *
+ * @returns The number of alive objects.
+ */
int Object::GetAliveObjects(void)
{
boost::mutex::scoped_lock lock(m_Mutex);
return m_AliveObjects.size();
}
+/**
+ * Dumps a memory histogram to the "dictionaries.dump" file.
+ */
void Object::PrintMemoryProfile(void)
{
map<String, int> types;
return false;
}
+/**
+ * Retrives the stdout file descriptor for the child process.
+ *
+ * @returns The stdout file descriptor.
+ */
int Process::GetFD(void) const
{
return fileno(m_FP);
CloseInternal(true);
}
+/**
+ * Starts I/O processing for this socket.
+ */
void Socket::Start(void)
{
assert(!m_ReadThread.joinable() && !m_WriteThread.joinable());
SetMessage(msg.CStr());
}
+/**
+ * Read thread procedure for sockets. This function waits until the
+ * socket is readable and processes inbound data.
+ */
void Socket::ReadThreadProc(void)
{
boost::mutex::scoped_lock lock(m_SocketMutex);
}
}
+/**
+ * Write thread procedure for sockets. This function waits until the socket
+ * is writable and processes outbound data.
+ */
void Socket::WriteThreadProc(void)
{
boost::mutex::scoped_lock lock(m_SocketMutex);
}
}
+/**
+ * Sets whether the socket is fully connected.
+ *
+ * @param connected Whether the socket is connected
+ */
void Socket::SetConnected(bool connected)
{
m_Connected = connected;
}
+/**
+ * Checks whether the socket is fully connected.
+ *
+ * @returns true if the socket is connected, false otherwise
+ */
bool Socket::IsConnected(void) const
{
return m_Connected;
}
+/**
+ * Checks whether an exception is available for this socket. Should be called
+ * by user-supplied handlers for the OnClosed signal.
+ */
void Socket::CheckException(void)
{
if (m_Exception)
throw_exception(runtime_error("Could not create a suitable socket."));
}
+/**
+ * Processes data that is available for this socket.
+ */
void TcpClient::HandleWritable(void)
{
int rc;
m_SendQueue->Write(buffer, count);
}
+/**
+ * Processes data that can be written for this socket.
+ */
void TcpClient::HandleReadable(void)
{
if (!IsConnected()) {
return (m_Value.type() == typeid(boost::blank));
}
+/**
+ * Checks whether the variant is scalar (i.e. not an object and not empty).
+ *
+ * @returns true if the variant is scalar, false otherwise.
+ */
bool Value::IsScalar(void) const
{
return !IsEmpty() && !IsObject();
}
+/**
+ * Checks whether the variant is a non-null object.
+ *
+ * @returns true if the variant is a non-null object, false otherwise.
+ */
bool Value::IsObject(void) const
{
return !IsEmpty() && (m_Value.type() == typeid(Object::Ptr));
}
+/**
+ * Converts a JSON object into a variant.
+ *
+ * @param json The JSON object.
+ */
Value Value::FromJson(cJSON *json)
{
if (json->type == cJSON_Number)
throw_exception(invalid_argument("Unsupported JSON type."));
}
+/**
+ * Serializes a variant into a string.
+ *
+ * @returns A string representing this variant.
+ */
String Value::Serialize(void) const
{
cJSON *json = ToJson();
return result;
}
+/**
+ * Serializes the variant.
+ *
+ * @returns A JSON object representing this variant.
+ */
cJSON *Value::ToJson(void) const
{
if (m_Value.type() == typeid(long)) {
}
}
+/**
+ * Deserializes the string representation of a variant.
+ *
+ * @params jsonString A JSON string obtained from Value::Serialize
+ * @returns The newly deserialized variant.
+ */
Value Value::Deserialize(const String& jsonString)
{
cJSON *json = cJSON_Parse(jsonString.CStr());