m_Stopped = false;
- m_Thread = thread(boost::bind(&CheckerComponent::CheckThreadProc, this));
+ m_Thread = boost::thread(boost::bind(&CheckerComponent::CheckThreadProc, this));
m_ResultTimer = boost::make_shared<Timer>();
m_ResultTimer->SetInterval(5);
boost::mutex m_Mutex;
boost::condition_variable m_CV;
bool m_Stopped;
- thread m_Thread;
+ boost::thread m_Thread;
ServiceSet m_IdleServices;
ServiceSet m_PendingServices;
m_StatusTimer->Reschedule(0);
#ifndef _WIN32
- m_CommandThread = thread(boost::bind(&CompatComponent::CommandPipeThread, this, GetCommandPath()));
+ m_CommandThread = boost::thread(boost::bind(&CompatComponent::CommandPipeThread, this, GetCommandPath()));
m_CommandThread.detach();
#endif /* _WIN32 */
}
Attribute<String> m_CommandPath;
#ifndef _WIN32
- thread m_CommandThread;
+ boost::thread m_CommandThread;
void CommandPipeThread(const String& commandPath);
#endif /* _WIN32 */
class Column
{
public:
- typedef function<Value (const Object::Ptr&)> ValueAccessor;
- typedef function<Object::Ptr (const Object::Ptr&)> ObjectAccessor;
+ typedef boost::function<Value (const Object::Ptr&)> ValueAccessor;
+ typedef boost::function<Object::Ptr (const Object::Ptr&)> ObjectAccessor;
Column(const ValueAccessor& valueAccessor, const ObjectAccessor& objectAccessor);
******************************************************************************/
#include "i2-livestatus.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
using namespace livestatus;
return "comments";
}
-void CommentsTable::FetchRows(const function<void (const Object::Ptr&)>& addRowFn)
+void CommentsTable::FetchRows(const AddRowFunction& addRowFn)
{
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Service")) {
Service::Ptr service = static_pointer_cast<Service>(object);
ObjectLock olock(comments);
Value comment;
- BOOST_FOREACH(tie(tuples::ignore, comment), comments) {
+ BOOST_FOREACH(boost::tie(boost::tuples::ignore, comment), comments) {
addRowFn(comment);
}
}
virtual String GetName(void) const;
protected:
- virtual void FetchRows(const function<void (const Object::Ptr&)>& addRowFn);
+ virtual void FetchRows(const AddRowFunction& addRowFn);
};
}
return "contactgroups";
}
-void ContactGroupsTable::FetchRows(const function<void (const Object::Ptr&)>& addRowFn)
+void ContactGroupsTable::FetchRows(const AddRowFunction& addRowFn)
{
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("UserGroup")) {
addRowFn(object);
}
return members;
-}
\ No newline at end of file
+}
virtual String GetName(void) const;
protected:
- virtual void FetchRows(const function<void (const Object::Ptr&)>& addRowFn);
+ virtual void FetchRows(const AddRowFunction& addRowFn);
static Value NameAccessor(const Object::Ptr& object);
static Value MembersAccessor(const Object::Ptr& object);
return "contacts";
}
-void ContactsTable::FetchRows(const function<void (const Object::Ptr&)>& addRowFn)
+void ContactsTable::FetchRows(const AddRowFunction& addRowFn)
{
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("User")) {
addRowFn(object);
virtual String GetName(void) const;
protected:
- virtual void FetchRows(const function<void (const Object::Ptr&)>& addRowFn);
+ virtual void FetchRows(const AddRowFunction& addRowFn);
static Value NameAccessor(const Object::Ptr& object);
static Value MembersAccessor(const Object::Ptr& object);
******************************************************************************/
#include "i2-livestatus.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
using namespace livestatus;
return "downtimes";
}
-void DowntimesTable::FetchRows(const function<void (const Object::Ptr&)>& addRowFn)
+void DowntimesTable::FetchRows(const AddRowFunction& addRowFn)
{
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Service")) {
Service::Ptr service = static_pointer_cast<Service>(object);
ObjectLock olock(downtimes);
Value downtime;
- BOOST_FOREACH(tie(tuples::ignore, downtime), downtimes) {
+ BOOST_FOREACH(boost::tie(boost::tuples::ignore, downtime), downtimes) {
addRowFn(downtime);
}
}
virtual String GetName(void) const;
protected:
- virtual void FetchRows(const function<void (const Object::Ptr&)>& addRowFn);
+ virtual void FetchRows(const AddRowFunction& addRowFn);
};
}
return "hosts";
}
-void HostsTable::FetchRows(const function<void (const Object::Ptr&)>& addRowFn)
+void HostsTable::FetchRows(const AddRowFunction& addRowFn)
{
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Host")) {
addRowFn(object);
virtual String GetName(void) const;
protected:
- virtual void FetchRows(const function<void (const Object::Ptr&)>& addRowFn);
+ virtual void FetchRows(const AddRowFunction& addRowFn);
static Value NameAccessor(const Object::Ptr& object);
static Value DisplayNameAccessor(const Object::Ptr& object);
******************************************************************************/
#include "i2-livestatus.h"
+#include <boost/algorithm/string/classification.hpp>
using namespace icinga;
using namespace livestatus;
else if (header == "OutputFormat")
m_OutputFormat = params;
else if (header == "Columns")
- m_Columns = params.Split(is_any_of(" "));
+ m_Columns = params.Split(boost::is_any_of(" "));
else if (header == "ColumnHeaders")
m_ColumnHeaders = (params == "on");
else if (header == "Filter" || header == "Stats") {
- vector<String> tokens = params.Split(is_any_of(" "));
+ vector<String> tokens = params.Split(boost::is_any_of(" "));
if (tokens.size() == 2)
tokens.push_back("");
return "services";
}
-void ServicesTable::FetchRows(const function<void (const Object::Ptr&)>& addRowFn)
+void ServicesTable::FetchRows(const AddRowFunction& addRowFn)
{
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Service")) {
addRowFn(object);
virtual String GetName(void) const;
protected:
- virtual void FetchRows(const function<void (const Object::Ptr&)>& addRowFn);
+ virtual void FetchRows(const AddRowFunction& addRowFn);
static Object::Ptr HostAccessor(const Object::Ptr& object);
return "status";
}
-void StatusTable::FetchRows(const function<void (const Object::Ptr&)>& addRowFn)
+void StatusTable::FetchRows(const AddRowFunction& addRowFn)
{
Object::Ptr obj = boost::make_shared<Object>();
virtual String GetName(void) const;
protected:
- virtual void FetchRows(const function<void (const Object::Ptr&)>& addRowFn);
+ virtual void FetchRows(const AddRowFunction& addRowFn);
};
}
******************************************************************************/
#include "i2-livestatus.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
using namespace livestatus;
vector<String> names;
String name;
- BOOST_FOREACH(tie(name, tuples::ignore), m_Columns) {
+ BOOST_FOREACH(boost::tie(name, boost::tuples::ignore), m_Columns) {
names.push_back(name);
}
typedef shared_ptr<Table> Ptr;
typedef weak_ptr<Table> WeakPtr;
+ typedef boost::function<void (const Object::Ptr&)> AddRowFunction;
+
static Table::Ptr GetByName(const String& name);
protected:
Table(void);
- virtual void FetchRows(const function<void (const Object::Ptr&)>& addRowFn) = 0;
+ virtual void FetchRows(const AddRowFunction& addRowFn) = 0;
static Value ZeroAccessor(const Object::Ptr&);
static Value OneAccessor(const Object::Ptr&);
******************************************************************************/
#include <i2-icinga.h>
-
+#include <boost/program_options.hpp>
+#include <boost/tuple/tuple.hpp>
#ifndef _WIN32
# include "icinga-version.h"
}
String name, fragment;
- BOOST_FOREACH(tie(name, fragment), ConfigFragmentRegistry::GetInstance()->GetItems()) {
+ BOOST_FOREACH(boost::tie(name, fragment), ConfigFragmentRegistry::GetInstance()->GetItems()) {
ConfigCompiler::CompileText(name, fragment);
}
******************************************************************************/
#include "i2-base.h"
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
using namespace icinga;
void Application::RunEventLoop(void) const
{
/* Start the system time watch thread. */
- thread t(&Application::TimeWatchThreadProc);
+ boost::thread t(&Application::TimeWatchThreadProc);
t.detach();
/* Set up a timer that watches the m_Shutdown flag. */
#ifndef ASYNCTASK_H
#define ASYNCTASK_H
+#include <boost/function.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition_variable.hpp>
+#include <boost/bind.hpp>
+
namespace icinga
{
/**
* A completion callback for an AsyncTask.
*/
- typedef function<void (const shared_ptr<TClass>&)> CompletionCallback;
+ typedef boost::function<void (const shared_ptr<TClass>&)> CompletionCallback;
/**
* Constructor for the AsyncTask class.
******************************************************************************/
#include "i2-base.h"
+#include <boost/bind.hpp>
using namespace icinga;
******************************************************************************/
#include "i2-base.h"
+#include <boost/lexical_cast.hpp>
using namespace icinga;
#include "i2-base.h"
#include <cJSON.h>
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
String key;
Value value;
- BOOST_FOREACH(tie(key, value), m_Data) {
+ BOOST_FOREACH(boost::tie(key, value), m_Data) {
clone->Set(key, value);
}
String key;
Value value;
- BOOST_FOREACH(tie(key, value), m_Data) {
+ BOOST_FOREACH(boost::tie(key, value), m_Data) {
cJSON_AddItemToObject(json, key.CStr(), value.ToJson());
}
} catch (...) {
#ifndef DYNAMICOBJECT_H
#define DYNAMICOBJECT_H
+#include <boost/thread/once.hpp>
+
namespace icinga
{
#ifndef DYNAMICTYPE_H
#define DYNAMICTYPE_H
+#include <boost/function.hpp>
+
namespace icinga
{
typedef shared_ptr<DynamicType> Ptr;
typedef weak_ptr<DynamicType> WeakPtr;
- typedef function<DynamicObject::Ptr (const Dictionary::Ptr&)> ObjectFactory;
+ typedef boost::function<DynamicObject::Ptr (const Dictionary::Ptr&)> ObjectFactory;
DynamicType(const String& name, const ObjectFactory& factory);
*
* @ingroup base
*/
-class I2_BASE_API DynamicTypeRegistry : public Registry<DynamicType::Ptr>
+class DynamicTypeRegistry : public Registry<DynamicType::Ptr>
{ };
/**
******************************************************************************/
#include "i2-base.h"
+#include <boost/bind.hpp>
using namespace icinga;
EventQueue::EventQueue(void)
: m_Stopped(false)
{
- unsigned int threads = thread::hardware_concurrency();
+ unsigned int threads = boost::thread::hardware_concurrency();
if (threads == 0)
threads = 1;
for (unsigned int i = 0; i < threads; i++)
m_Threads.create_thread(boost::bind(&EventQueue::QueueThreadProc, this));
- thread reportThread(boost::bind(&EventQueue::ReportThreadProc, this));
+ boost::thread reportThread(boost::bind(&EventQueue::ReportThreadProc, this));
reportThread.detach();
}
#ifndef EVENTQUEUE_H
#define EVENTQUEUE_H
+#include <boost/function.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition_variable.hpp>
+
namespace icinga
{
class I2_BASE_API EventQueue
{
public:
- typedef function<void ()> Callback;
+ typedef boost::function<void ()> Callback;
EventQueue(void);
~EventQueue(void);
void Post(const Callback& callback);
private:
- thread_group m_Threads;
+ boost::thread_group m_Threads;
boost::mutex m_Mutex;
- condition_variable m_CV;
+ boost::condition_variable m_CV;
bool m_Stopped;
stack<Callback> m_Events;
#ifndef EXCEPTION_H
#define EXCEPTION_H
+#include <boost/thread/tss.hpp>
+
namespace icinga
{
#include <boost/smart_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/bind.hpp>
-#include <boost/function.hpp>
#include <boost/signals2.hpp>
-#include <boost/algorithm/string/trim.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <boost/algorithm/string/join.hpp>
-#include <boost/algorithm/string/compare.hpp>
-#include <boost/thread.hpp>
-#include <boost/variant.hpp>
-#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
-#include <boost/tuple/tuple.hpp>
-#include <boost/uuid/uuid.hpp>
-#include <boost/uuid/uuid_generators.hpp>
-#include <boost/uuid/uuid_io.hpp>
-#include <boost/program_options.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/exception/error_info.hpp>
#include <boost/exception/errinfo_api_function.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/key_extractors.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
using boost::shared_ptr;
using boost::weak_ptr;
-using boost::enable_shared_from_this;
using boost::dynamic_pointer_cast;
using boost::static_pointer_cast;
-using boost::function;
-using boost::thread;
-using boost::thread_group;
-using boost::recursive_mutex;
-using boost::condition_variable;
-using boost::system_time;
-using boost::posix_time::millisec;
-using boost::tie;
-using boost::rethrow_exception;
-using boost::current_exception;
using boost::diagnostic_information;
using boost::errinfo_api_function;
using boost::errinfo_errno;
using boost::multi_index::ordered_non_unique;
using boost::multi_index::nth_index;
-namespace tuples = boost::tuples;
namespace signals2 = boost::signals2;
#if defined(__APPLE__) && defined(__MACH__)
#ifndef OBJECT_H
#define OBJECT_H
+#include <boost/thread/mutex.hpp>
+
namespace icinga
{
*
* @ingroup base
*/
-class I2_BASE_API Object : public enable_shared_from_this<Object>
+class I2_BASE_API Object : public boost::enable_shared_from_this<Object>
{
public:
typedef shared_ptr<Object> Ptr;
******************************************************************************/
#include "i2-base.h"
+#include <boost/bind.hpp>
+#include <boost/tuple/tuple.hpp>
#ifndef _WIN32
#include <execvpe.h>
using namespace icinga;
-condition_variable Process::m_CV;
+boost::condition_variable Process::m_CV;
int Process::m_TaskFd;
Timer::Ptr Process::m_StatusTimer;
m_TaskFd = fds[1];
- unsigned int threads = thread::hardware_concurrency();
+ unsigned int threads = boost::thread::hardware_concurrency();
if (threads == 0)
threads = 2;
Utility::SetNonBlocking(childTaskFd);
Utility::SetCloExec(childTaskFd);
- thread t(&Process::WorkerThreadProc, childTaskFd);
+ boost::thread t(&Process::WorkerThreadProc, childTaskFd);
t.detach();
}
int idx = 0;
int fd;
- BOOST_FOREACH(tie(fd, tuples::ignore), tasks) {
+ BOOST_FOREACH(boost::tie(fd, boost::tuples::ignore), tasks) {
pfds[idx].fd = fd;
pfds[idx].events = POLLIN | POLLHUP;
idx++;
String key;
Value value;
int index = envc;
- BOOST_FOREACH(tie(key, value), m_ExtraEnvironment) {
+ BOOST_FOREACH(boost::tie(key, value), m_ExtraEnvironment) {
String kv = key + "=" + Convert::ToString(value);
envp[index] = strdup(kv.CStr());
index++;
#ifndef PROCESS_H
#define PROCESS_H
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/once.hpp>
+
namespace icinga
{
static boost::mutex m_Mutex;
static deque<Process::Ptr> m_Tasks;
#ifndef _WIN32
- static condition_variable m_CV;
+ static boost::condition_variable m_CV;
static int m_TaskFd;
static Timer::Ptr m_StatusTimer;
******************************************************************************/
#include "i2-base.h"
+#include <boost/algorithm/string/trim.hpp>
+#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/compare.hpp>
using namespace icinga;
#ifndef STRING_H
#define STRING_H
+#include <boost/algorithm/string/split.hpp>
+
namespace icinga {
/**
* @ingroup base
*/
template<typename T>
-class Registry
+class I2_BASE_API Registry
{
public:
typedef map<String, T, string_iless> ItemMap;
/**
* Constructor for the Script class.
*
- * @param properties A serialized dictionary containing attributes.
+ * @param serializedUpdate A serialized dictionary containing attributes.
*/
-Script::Script(const Dictionary::Ptr& properties)
- : DynamicObject(properties)
+Script::Script(const Dictionary::Ptr& serializedUpdate)
+ : DynamicObject(serializedUpdate)
{
RegisterAttribute("language", Attribute_Config, &m_Language);
RegisterAttribute("code", Attribute_Config, &m_Code);
typedef shared_ptr<Script> Ptr;
typedef weak_ptr<Script> WeakPtr;
- Script(const Dictionary::Ptr& properties);
+ Script(const Dictionary::Ptr& serializedUpdate);
virtual void Start(void);
#ifndef SCRIPTFUNCTION_H
#define SCRIPTFUNCTION_H
+#include <boost/function.hpp>
+
namespace icinga
{
typedef shared_ptr<ScriptFunction> Ptr;
typedef weak_ptr<ScriptFunction> WeakPtr;
- typedef function<void (const shared_ptr<ScriptTask>&, const vector<Value>& arguments)> Callback;
+ typedef boost::function<void (const shared_ptr<ScriptTask>&, const vector<Value>& arguments)> Callback;
explicit ScriptFunction(const Callback& function);
* @ingroup base
*/
template<typename T>
-class Singleton
+class I2_BASE_API Singleton
{
public:
static T *GetInstance(void)
static boost::mutex mutex;
boost::mutex::scoped_lock lock(mutex);
- static T *instance = NULL;
+ if (!m_Instance)
+ m_Instance = new T();
- if (!instance)
- instance = new T();
-
- return instance;
+ return m_Instance;
}
private:
friend T *T::GetInstance(void);
+
+ static T *m_Instance;
};
+template<typename T>
+T *Singleton<T>::m_Instance = NULL;
+
}
#endif /* SINGLETON_H */
******************************************************************************/
#include "i2-base.h"
+#include <boost/bind.hpp>
using namespace icinga;
ASSERT(!m_ReadThread.joinable() && !m_WriteThread.joinable());
ASSERT(GetFD() != INVALID_SOCKET);
- // TODO: figure out why we're not using "this" here
- m_ReadThread = thread(boost::bind(&Socket::ReadThreadProc, static_cast<Socket::Ptr>(GetSelf())));
+ // TODO: figure out why we're not using "this" here (hint: to keep the object alive until the threads are done)
+ m_ReadThread = boost::thread(boost::bind(&Socket::ReadThreadProc, static_cast<Socket::Ptr>(GetSelf())));
m_ReadThread.detach();
- m_WriteThread = thread(boost::bind(&Socket::WriteThreadProc, static_cast<Socket::Ptr>(GetSelf())));
+ m_WriteThread = boost::thread(boost::bind(&Socket::WriteThreadProc, static_cast<Socket::Ptr>(GetSelf())));
m_WriteThread.detach();
Stream::Start();
#ifndef SOCKET_H
#define SOCKET_H
+#include <boost/thread/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition_variable.hpp>
+
namespace icinga {
/**
bool m_Connected;
bool m_Listening;
- thread m_ReadThread;
- thread m_WriteThread;
+ boost::thread m_ReadThread;
+ boost::thread m_WriteThread;
- condition_variable m_WriteCV;
+ boost::condition_variable m_WriteCV;
void ReadThreadProc(void);
void WriteThreadProc(void);
#ifndef STACKTRACE_H
#define STACKTRACE_H
+#include <boost/thread/once.hpp>
+
namespace icinga
{
******************************************************************************/
#include "i2-base.h"
+#include <boost/algorithm/string/trim.hpp>
using namespace icinga;
#ifndef STREAM_H
#define STREAM_H
+#include <boost/exception_ptr.hpp>
+
namespace icinga
{
******************************************************************************/
#include "i2-base.h"
+#include <boost/bind.hpp>
using namespace icinga;
Timer::TimerSet Timer::m_Timers;
-thread Timer::m_Thread;
+boost::thread Timer::m_Thread;
boost::mutex Timer::m_Mutex;
boost::condition_variable Timer::m_CV;
bool Timer::m_StopThread;
{
boost::mutex::scoped_lock lock(m_Mutex);
m_StopThread = false;
- m_Thread = thread(boost::bind(&Timer::TimerThreadProc));
+ m_Thread = boost::thread(boost::bind(&Timer::TimerThreadProc));
}
/**
#ifndef TIMER_H
#define TIMER_H
-#include <time.h>
+#include <boost/thread/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition_variable.hpp>
namespace icinga {
static boost::mutex m_Mutex;
static boost::condition_variable m_CV;
- static thread m_Thread;
+ static boost::thread m_Thread;
static bool m_StopThread;
static TimerSet m_Timers;
******************************************************************************/
#include "i2-base.h"
+#include <boost/bind.hpp>
using namespace icinga;
#include "i2-base.h"
#include <mmatch.h>
+#include <boost/uuid/uuid.hpp>
+#include <boost/uuid/uuid_generators.hpp>
+#include <boost/uuid/uuid_io.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/function.hpp>
using namespace icinga;
*
* @param pathSpec The path specification.
*/
-bool Utility::Glob(const String& pathSpec, const function<void (const String&)>& callback)
+bool Utility::Glob(const String& pathSpec, const boost::function<void (const String&)>& callback)
{
#ifdef _WIN32
HANDLE handle;
#ifndef UTILITY_H
#define UTILITY_H
+#include <boost/function.hpp>
+
namespace icinga
{
static String NewUUID(void);
- static bool Glob(const String& pathSpec, const function<void (const String&)>& callback);
+ static bool Glob(const String& pathSpec, const boost::function<void (const String&)>& callback);
static void QueueAsyncCallback(const boost::function<void (void)>& callback);
#include "i2-base.h"
#include <cJSON.h>
+#include <boost/lexical_cast.hpp>
using namespace icinga;
#ifndef VALUE_H
#define VALUE_H
+#include <boost/variant.hpp>
+
struct cJSON;
namespace icinga
class I2_CONFIG_API ConfigCompiler
{
public:
- typedef function<void (const String&, bool, const DebugInfo&)> HandleIncludeFunc;
+ typedef boost::function<void (const String&, bool, const DebugInfo&)> HandleIncludeFunc;
explicit ConfigCompiler(const String& path, istream *input = &cin,
HandleIncludeFunc includeHandler = &ConfigCompiler::HandleFileInclude);
void DestroyScanner(void);
};
-class I2_CONFIG_API ConfigFragmentRegistry : public Registry<String>
+class ConfigFragmentRegistry : public Registry<String>
{ };
/**
******************************************************************************/
#include "i2-config.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
-recursive_mutex ConfigItem::m_Mutex;
+boost::mutex ConfigItem::m_Mutex;
ConfigItem::ItemMap ConfigItem::m_Items;
signals2::signal<void (const ConfigItem::Ptr&)> ConfigItem::OnCommitted;
signals2::signal<void (const ConfigItem::Ptr&)> ConfigItem::OnRemoved;
ConfigItem::Ptr oldItem;
{
- recursive_mutex::scoped_lock lock(m_Mutex);
+ boost::mutex::scoped_lock lock(m_Mutex);
ItemMap::iterator it = m_Items.find(ikey);
ConfigItem::Ptr self = GetSelf();
{
- recursive_mutex::scoped_lock lock(m_Mutex);
+ boost::mutex::scoped_lock lock(m_Mutex);
/* Register this item. */
m_Items[ikey] = self;
String key;
Value data;
- BOOST_FOREACH(tie(key, data), properties) {
+ BOOST_FOREACH(boost::tie(key, data), properties) {
Dictionary::Ptr attr = boost::make_shared<Dictionary>();
attr->Set("data", data);
attr->Set("type", Attribute_Config);
*/
ConfigItem::Ptr ConfigItem::GetObject(const String& type, const String& name)
{
- recursive_mutex::scoped_lock lock(m_Mutex);
+ boost::mutex::scoped_lock lock(m_Mutex);
ConfigItem::ItemMap::iterator it;
*/
void ConfigItem::UnloadUnit(const String& unit)
{
- recursive_mutex::scoped_lock lock(m_Mutex);
+ vector<ConfigItem::Ptr> obsoleteItems;
- Logger::Write(LogInformation, "config", "Unloading config items from compilation unit '" + unit + "'");
+ {
+ boost::mutex::scoped_lock lock(m_Mutex);
- vector<ConfigItem::Ptr> obsoleteItems;
+ Logger::Write(LogInformation, "config", "Unloading config items from compilation unit '" + unit + "'");
- ConfigItem::Ptr item;
- BOOST_FOREACH(tie(tuples::ignore, item), m_Items) {
- ObjectLock olock(item);
+ ConfigItem::Ptr item;
+ BOOST_FOREACH(boost::tie(boost::tuples::ignore, item), m_Items) {
+ ObjectLock olock(item);
- if (item->m_Unit != unit)
- continue;
+ if (item->m_Unit != unit)
+ continue;
- obsoleteItems.push_back(item);
+ obsoleteItems.push_back(item);
+ }
}
BOOST_FOREACH(const ConfigItem::Ptr& item, obsoleteItems) {
set<ConfigItem::WeakPtr> m_ChildObjects; /**< Instantiated items
* that inherit from this item */
- static recursive_mutex m_Mutex;
+ static boost::mutex m_Mutex;
typedef map<pair<String, String>, ConfigItem::Ptr> ItemMap;
static ItemMap m_Items; /**< All registered configuration items. */
******************************************************************************/
#include "i2-config.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
String key;
Value value;
- BOOST_FOREACH(tie(key, value), dictionary) {
+ BOOST_FOREACH(boost::tie(key, value), dictionary) {
TypeValidationResult overallResult = ValidationUnknownField;
vector<TypeRuleList::Ptr> subRuleLists;
******************************************************************************/
#include "i2-config.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
String key;
Value value;
- BOOST_FOREACH(tie(key, value), valueDict) {
+ BOOST_FOREACH(boost::tie(key, value), valueDict) {
dict->Set(key, value);
}
} else {
String k;
Value v;
- BOOST_FOREACH(tie(k, v), static_cast<Dictionary::Ptr>(value)) {
+ BOOST_FOREACH(boost::tie(k, v), static_cast<Dictionary::Ptr>(value)) {
for (int i = 0; i < indent; i++)
fp << "\t";
******************************************************************************/
#include "i2-icinga.h"
+#include <boost/algorithm/string/classification.hpp>
using namespace icinga;
if (ts == 0)
BOOST_THROW_EXCEPTION(invalid_argument("Invalid timestamp in command: " + line));
- vector<String> argv = args.Split(is_any_of(";"));
+ vector<String> argv = args.Split(boost::is_any_of(";"));
if (argv.empty())
BOOST_THROW_EXCEPTION(invalid_argument("Missing arguments in command: " + line));
static void Execute(double time, const String& command, const vector<String>& arguments);
private:
- typedef function<void (double time, const vector<String>& arguments)> Callback;
+ typedef boost::function<void (double time, const vector<String>& arguments)> Callback;
static boost::once_flag m_InitializeOnce;
static boost::mutex m_Mutex;
******************************************************************************/
#include "i2-icinga.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
if (m_SlaveServices) {
ConfigItem::Ptr service;
- BOOST_FOREACH(tie(tuples::ignore, service), m_SlaveServices) {
+ BOOST_FOREACH(boost::tie(boost::tuples::ignore, service), m_SlaveServices) {
service->Unregister();
}
}
ObjectLock olock(serviceDescs);
String svcname;
Value svcdesc;
- BOOST_FOREACH(tie(svcname, svcdesc), serviceDescs) {
+ BOOST_FOREACH(boost::tie(svcname, svcdesc), serviceDescs) {
if (svcdesc.IsScalar())
svcname = svcdesc;
ObjectLock olock(oldServices);
ConfigItem::Ptr service;
- BOOST_FOREACH(tie(tuples::ignore, service), oldServices) {
+ BOOST_FOREACH(boost::tie(boost::tuples::ignore, service), oldServices) {
if (!service)
continue;
boost::mutex::scoped_lock lock(m_ServiceMutex);
Service::WeakPtr wservice;
- BOOST_FOREACH(tie(tuples::ignore, wservice), m_ServicesCache[GetName()]) {
+ BOOST_FOREACH(boost::tie(boost::tuples::ignore, wservice), m_ServicesCache[GetName()]) {
Service::Ptr service = wservice.lock();
if (!service)
String key;
Value value;
- BOOST_FOREACH(tie(key, value), attrs) {
+ BOOST_FOREACH(boost::tie(key, value), attrs) {
vector<String> templates;
if (!value.IsObjectType<Dictionary>())
#include <i2-config.h>
#include <i2-remoting.h>
-using boost::iterator_range;
-using boost::algorithm::is_any_of;
-
#ifdef I2_ICINGA_BUILD
# define I2_ICINGA_API I2_EXPORT
#else /* I2_ICINGA_BUILD */
******************************************************************************/
#include "i2-icinga.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
String key;
Value value;
- BOOST_FOREACH(tie(key, value), dict) {
+ BOOST_FOREACH(boost::tie(key, value), dict) {
if (!value.IsScalar())
continue;
******************************************************************************/
#include "i2-icinga.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
{
set<User::Ptr> result;
- Dictionary::Ptr users = m_Users;
+ Array::Ptr users = m_Users;
if (users) {
ObjectLock olock(users);
- String name;
- BOOST_FOREACH(tie(tuples::ignore, name), users) {
+ BOOST_FOREACH(const String& name, users) {
User::Ptr user = User::GetByName(name);
if (!user)
{
set<UserGroup::Ptr> result;
- Dictionary::Ptr groups = m_Groups;
+ Array::Ptr groups = m_Groups;
if (groups) {
ObjectLock olock(groups);
- String name;
- BOOST_FOREACH(tie(tuples::ignore, name), groups) {
+ BOOST_FOREACH(const String& name, groups) {
UserGroup::Ptr ug = UserGroup::GetByName(name);
if (!ug)
private:
Attribute<Value> m_NotificationCommand;
Attribute<Dictionary::Ptr> m_Macros;
- Attribute<Dictionary::Ptr> m_Users;
- Attribute<Dictionary::Ptr> m_Groups;
+ Attribute<Array::Ptr> m_Users;
+ Attribute<Array::Ptr> m_Groups;
Attribute<String> m_HostName;
Attribute<String> m_Service;
******************************************************************************/
#include "i2-icinga.h"
+#include <boost/algorithm/string/classification.hpp>
using namespace icinga;
String text;
String perfdata;
- vector<String> lines = output.Split(is_any_of("\r\n"));
+ vector<String> lines = output.Split(boost::is_any_of("\r\n"));
BOOST_FOREACH (const String& line, lines) {
size_t delim = line.FindFirstOf("|");
/**
* @threadsafety Always.
*/
-void Service::BeginExecuteCheck(const function<void (void)>& callback)
+void Service::BeginExecuteCheck(const boost::function<void (void)>& callback)
{
ASSERT(!OwnsLock());
* @threadsafety Always.
*/
void Service::CheckCompletedHandler(const Dictionary::Ptr& checkInfo,
- const ScriptTask::Ptr& task, const function<void (void)>& callback)
+ const ScriptTask::Ptr& task, const boost::function<void (void)>& callback)
{
ASSERT(!OwnsLock());
******************************************************************************/
#include "i2-icinga.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
ObjectLock olock(downtimes);
String id;
- BOOST_FOREACH(tie(id, tuples::ignore), downtimes) {
+ BOOST_FOREACH(boost::tie(id, boost::tuples::ignore), downtimes) {
TriggerDowntime(id);
}
}
Dictionary::Ptr triggers = downtime->Get("triggers");
ObjectLock olock(triggers);
String tid;
- BOOST_FOREACH(tie(tid, tuples::ignore), triggers) {
+ BOOST_FOREACH(boost::tie(tid, boost::tuples::ignore), triggers) {
TriggerDowntime(tid);
}
String id;
Dictionary::Ptr downtime;
- BOOST_FOREACH(tie(id, downtime), downtimes) {
+ BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
int legacy_id = downtime->Get("legacy_id");
if (legacy_id >= m_NextDowntimeID)
String id;
Dictionary::Ptr downtime;
- BOOST_FOREACH(tie(id, downtime), downtimes) {
+ BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
if (IsDowntimeExpired(downtime))
expiredDowntimes.push_back(id);
}
ObjectLock olock(downtimes);
Dictionary::Ptr downtime;
- BOOST_FOREACH(tie(tuples::ignore, downtime), downtimes) {
+ BOOST_FOREACH(boost::tie(boost::tuples::ignore, downtime), downtimes) {
if (Service::IsDowntimeActive(downtime))
return true;
}
******************************************************************************/
#include "i2-icinga.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
String nfcname;
Value nfcdesc;
- BOOST_FOREACH(tie(nfcname, nfcdesc), notificationDescs) {
+ BOOST_FOREACH(boost::tie(nfcname, nfcdesc), notificationDescs) {
stringstream namebuf;
namebuf << GetName() << "-" << nfcname;
String name = namebuf.str();
ObjectLock olock(oldNotifications);
ConfigItem::Ptr notification;
- BOOST_FOREACH(tie(tuples::ignore, notification), oldNotifications) {
+ BOOST_FOREACH(boost::tie(boost::tuples::ignore, notification), oldNotifications) {
if (!notification)
continue;
void AcknowledgeProblem(AcknowledgementType type, double expiry = 0);
void ClearAcknowledgement(void);
- void BeginExecuteCheck(const function<void (void)>& callback);
+ void BeginExecuteCheck(const boost::function<void (void)>& callback);
void ProcessCheckResult(const Dictionary::Ptr& cr);
static double CalculateExecutionTime(const Dictionary::Ptr& cr);
long m_SchedulingOffset;
void CheckCompletedHandler(const Dictionary::Ptr& checkInfo,
- const ScriptTask::Ptr& task, const function<void (void)>& callback);
+ const ScriptTask::Ptr& task, const boost::function<void (void)>& callback);
/* Downtimes */
Attribute<Dictionary::Ptr> m_Downtimes;
Touch("subscriptions");
}
-void Endpoint::RegisterTopicHandler(const String& topic, const function<Endpoint::Callback>& callback)
+void Endpoint::RegisterTopicHandler(const String& topic, const boost::function<Endpoint::Callback>& callback)
{
ObjectLock olock(this);
RegisterSubscription(topic);
}
-void Endpoint::UnregisterTopicHandler(const String&, const function<Endpoint::Callback>&)
+void Endpoint::UnregisterTopicHandler(const String&, const boost::function<Endpoint::Callback>&)
{
// TODO: implement
//m_TopicHandlers[method] -= callback;
void ClearSubscriptions(void);
- void RegisterTopicHandler(const String& topic, const function<Callback>& callback);
- void UnregisterTopicHandler(const String& topic, const function<Callback>& callback);
+ void RegisterTopicHandler(const String& topic, const boost::function<Callback>& callback);
+ void UnregisterTopicHandler(const String& topic, const boost::function<Callback>& callback);
String GetNode(void) const;
String GetService(void) const;
******************************************************************************/
#include "i2-remoting.h"
+#include <boost/tuple/tuple.hpp>
using namespace icinga;
ObjectLock olock(endpointSubscriptions);
String topic;
- BOOST_FOREACH(tie(tuples::ignore, topic), endpointSubscriptions) {
+ BOOST_FOREACH(boost::tie(boost::tuples::ignore, topic), endpointSubscriptions) {
subscriptions->Set(topic, topic);
}
}
void SendMulticastMessage(const RequestMessage& message);
void SendMulticastMessage(const Endpoint::Ptr& sender, const RequestMessage& message);
- typedef function<void(const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> APICallback;
+ typedef boost::function<void(const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> APICallback;
void SendAPIMessage(const Endpoint::Ptr& sender, const Endpoint::Ptr& recipient, RequestMessage& message,
const APICallback& callback, double timeout = 30);
{
double Timeout;
RequestMessage Request;
- function<void(const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> Callback;
+ boost::function<void(const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> Callback;
bool HasTimedOut(void) const
{