2012-05-10 12:06:41 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2018-10-18 09:27:04 +02:00
|
|
|
* Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/) *
|
2012-05-10 12:06:41 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
2012-05-11 13:33:57 +02:00
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
2012-05-10 12:06:41 +02:00
|
|
|
******************************************************************************/
|
|
|
|
|
2012-04-02 08:56:30 +02:00
|
|
|
#ifndef I2BASE_H
|
|
|
|
#define I2BASE_H
|
2012-03-28 13:24:49 +02:00
|
|
|
|
2012-05-18 22:21:28 +02:00
|
|
|
/**
|
2012-05-19 10:48:00 +02:00
|
|
|
* @mainpage Icinga Documentation
|
|
|
|
*
|
|
|
|
* Icinga implements a framework for run-time-loadable components which can
|
2012-05-21 23:42:54 +02:00
|
|
|
* 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
|
2012-05-19 10:48:00 +02:00
|
|
|
* on different machines).
|
|
|
|
*
|
|
|
|
* The framework's code critically depends on the following patterns:
|
|
|
|
*
|
2012-05-19 11:04:52 +02:00
|
|
|
* <list type="bullet">
|
|
|
|
* <item>Smart pointers
|
2012-05-19 10:48:00 +02:00
|
|
|
*
|
|
|
|
* The shared_ptr and weak_ptr template classes are used to simplify memory
|
2012-05-21 23:42:54 +02:00
|
|
|
* management and to avoid accidental memory leaks and use-after-free
|
|
|
|
* bugs.</item>
|
2012-05-19 10:48:00 +02:00
|
|
|
*
|
2012-05-19 11:04:52 +02:00
|
|
|
* <item>Observer pattern
|
2012-05-19 10:48:00 +02:00
|
|
|
*
|
|
|
|
* Framework classes expose events which other objects can subscribe to. This
|
|
|
|
* is used to decouple clients of a class from the class' internal
|
2012-05-19 11:04:52 +02:00
|
|
|
* implementation.</item>
|
|
|
|
* </list>
|
2012-05-18 22:21:28 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup base Base class library
|
|
|
|
*
|
2012-05-19 10:48:00 +02:00
|
|
|
* The base class library implements commonly-used functionality like
|
|
|
|
* event handling for sockets and timers.
|
2012-05-18 22:21:28 +02:00
|
|
|
*/
|
|
|
|
|
2017-06-29 21:07:04 +02:00
|
|
|
#include <boost/config.hpp>
|
|
|
|
|
|
|
|
#if defined(__clang__) && __cplusplus >= 201103L
|
|
|
|
# undef BOOST_NO_CXX11_HDR_TUPLE
|
|
|
|
#endif
|
|
|
|
|
2012-04-03 15:47:32 +02:00
|
|
|
#ifdef _MSC_VER
|
2012-04-06 08:56:52 +02:00
|
|
|
# pragma warning(disable:4251)
|
2012-06-14 16:09:04 +02:00
|
|
|
# pragma warning(disable:4275)
|
2012-07-14 13:57:20 +02:00
|
|
|
# pragma warning(disable:4345)
|
2012-04-03 13:38:30 +02:00
|
|
|
#endif /* _MSC_VER */
|
|
|
|
|
2014-08-30 18:08:28 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2012-04-26 16:45:00 +02:00
|
|
|
#ifdef _WIN32
|
2014-05-25 16:23:35 +02:00
|
|
|
# include "base/win32.hpp"
|
2012-04-26 16:45:00 +02:00
|
|
|
#else
|
2014-05-25 16:23:35 +02:00
|
|
|
# include "base/unix.hpp"
|
2012-04-26 16:45:00 +02:00
|
|
|
#endif
|
|
|
|
|
2012-04-01 09:48:52 +02:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdarg>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
|
|
|
#include <cerrno>
|
2012-03-28 13:24:49 +02:00
|
|
|
|
2013-02-01 23:10:48 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2013-03-07 15:00:26 +01:00
|
|
|
#include <signal.h>
|
2013-02-01 23:10:48 +01:00
|
|
|
|
2012-05-25 16:56:47 +02:00
|
|
|
#include <exception>
|
2012-05-26 23:12:46 +02:00
|
|
|
#include <stdexcept>
|
2012-05-25 14:40:10 +02:00
|
|
|
|
2012-04-24 19:58:32 +02:00
|
|
|
#if defined(__APPLE__) && defined(__MACH__)
|
2013-02-17 19:14:34 +01:00
|
|
|
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
2012-04-24 19:58:32 +02:00
|
|
|
#endif
|
|
|
|
|
2016-04-19 09:37:41 +02:00
|
|
|
#if defined(__GNUC__)
|
|
|
|
# define likely(x) __builtin_expect(!!(x), 1)
|
|
|
|
# define unlikely(x) __builtin_expect(!!(x), 0)
|
|
|
|
#else
|
|
|
|
# define likely(x) (x)
|
|
|
|
# define unlikely(x) (x)
|
|
|
|
#endif
|
|
|
|
|
2017-11-21 11:52:55 +01:00
|
|
|
#define BOOST_BIND_NO_PLACEHOLDERS
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
using namespace std::placeholders;
|
2016-04-19 09:37:41 +02:00
|
|
|
|
2012-04-02 08:56:30 +02:00
|
|
|
#endif /* I2BASE_H */
|