mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Apply clang-tidy fix 'modernize-redundant-void-arg'
This commit is contained in:
parent
be5a5783d2
commit
ac155d1dda
@ -93,7 +93,7 @@ static std::vector<String> GlobalArgumentCompletion(const String& argument, cons
|
|||||||
return std::vector<String>();
|
return std::vector<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Main(void)
|
static int Main()
|
||||||
{
|
{
|
||||||
int argc = Application::GetArgC();
|
int argc = Application::GetArgC();
|
||||||
char **argv = Application::GetArgV();
|
char **argv = Application::GetArgV();
|
||||||
|
@ -56,7 +56,7 @@ ConnectForm::ConnectForm(wxWindow *parent, const Url::Ptr& url)
|
|||||||
SetDefaultItem(m_ButtonsOK);
|
SetDefaultItem(m_ButtonsOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
Url::Ptr ConnectForm::GetUrl(void) const
|
Url::Ptr ConnectForm::GetUrl() const
|
||||||
{
|
{
|
||||||
wxString url = "https://" + m_UserText->GetValue() + ":" + m_PasswordText->GetValue()
|
wxString url = "https://" + m_UserText->GetValue() + ":" + m_PasswordText->GetValue()
|
||||||
+ "@" + m_HostText->GetValue() + ":" + m_PortText->GetValue() + "/";
|
+ "@" + m_HostText->GetValue() + ":" + m_PortText->GetValue() + "/";
|
||||||
|
@ -31,7 +31,7 @@ class ConnectForm final : public ConnectFormBase
|
|||||||
public:
|
public:
|
||||||
ConnectForm(wxWindow *parent, const Url::Ptr& url);
|
ConnectForm(wxWindow *parent, const Url::Ptr& url);
|
||||||
|
|
||||||
Url::Ptr GetUrl(void) const;
|
Url::Ptr GetUrl() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ using namespace icinga;
|
|||||||
class IcingaStudio final : public wxApp
|
class IcingaStudio final : public wxApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool OnInit(void) override
|
virtual bool OnInit() override
|
||||||
{
|
{
|
||||||
Application::InitializeBase();
|
Application::InitializeBase();
|
||||||
|
|
||||||
|
@ -23,12 +23,12 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
String Application::GetAppVersion(void)
|
String Application::GetAppVersion()
|
||||||
{
|
{
|
||||||
return VERSION;
|
return VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Application::GetAppSpecVersion(void)
|
String Application::GetAppSpecVersion()
|
||||||
{
|
{
|
||||||
return SPEC_VERSION;
|
return SPEC_VERSION;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ using namespace icinga;
|
|||||||
|
|
||||||
REGISTER_TYPE(Application);
|
REGISTER_TYPE(Application);
|
||||||
|
|
||||||
boost::signals2::signal<void (void)> Application::OnReopenLogs;
|
boost::signals2::signal<void ()> Application::OnReopenLogs;
|
||||||
Application::Ptr Application::m_Instance = nullptr;
|
Application::Ptr Application::m_Instance = nullptr;
|
||||||
bool Application::m_ShuttingDown = false;
|
bool Application::m_ShuttingDown = false;
|
||||||
bool Application::m_RequestRestart = false;
|
bool Application::m_RequestRestart = false;
|
||||||
@ -71,7 +71,7 @@ double Application::m_LastReloadFailed;
|
|||||||
/**
|
/**
|
||||||
* Constructor for the Application class.
|
* Constructor for the Application class.
|
||||||
*/
|
*/
|
||||||
void Application::OnConfigLoaded(void)
|
void Application::OnConfigLoaded()
|
||||||
{
|
{
|
||||||
m_PidFile = nullptr;
|
m_PidFile = nullptr;
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ void Application::Stop(bool runtimeRemoved)
|
|||||||
ObjectImpl<Application>::Stop(runtimeRemoved);
|
ObjectImpl<Application>::Stop(runtimeRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application(void)
|
Application::~Application()
|
||||||
{
|
{
|
||||||
m_Instance = nullptr;
|
m_Instance = nullptr;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ void Application::Exit(int rc)
|
|||||||
#endif /* I2_DEBUG */
|
#endif /* I2_DEBUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::InitializeBase(void)
|
void Application::InitializeBase()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* disable GUI-based error messages for LoadLibrary() */
|
/* disable GUI-based error messages for LoadLibrary() */
|
||||||
@ -160,7 +160,7 @@ void Application::InitializeBase(void)
|
|||||||
GetTP().Start();
|
GetTP().Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::UninitializeBase(void)
|
void Application::UninitializeBase()
|
||||||
{
|
{
|
||||||
Timer::Uninitialize();
|
Timer::Uninitialize();
|
||||||
|
|
||||||
@ -172,12 +172,12 @@ void Application::UninitializeBase(void)
|
|||||||
*
|
*
|
||||||
* @returns The application object.
|
* @returns The application object.
|
||||||
*/
|
*/
|
||||||
Application::Ptr Application::GetInstance(void)
|
Application::Ptr Application::GetInstance()
|
||||||
{
|
{
|
||||||
return m_Instance;
|
return m_Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::SetResourceLimits(void)
|
void Application::SetResourceLimits()
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
rlimit rl;
|
rlimit rl;
|
||||||
@ -289,7 +289,7 @@ void Application::SetResourceLimits(void)
|
|||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
int Application::GetArgC(void)
|
int Application::GetArgC()
|
||||||
{
|
{
|
||||||
return m_ArgC;
|
return m_ArgC;
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ void Application::SetArgC(int argc)
|
|||||||
m_ArgC = argc;
|
m_ArgC = argc;
|
||||||
}
|
}
|
||||||
|
|
||||||
char **Application::GetArgV(void)
|
char **Application::GetArgV()
|
||||||
{
|
{
|
||||||
return m_ArgV;
|
return m_ArgV;
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ void Application::SetArgV(char **argv)
|
|||||||
* Processes events for registered sockets and timers and calls whatever
|
* Processes events for registered sockets and timers and calls whatever
|
||||||
* handlers have been set up for these events.
|
* handlers have been set up for these events.
|
||||||
*/
|
*/
|
||||||
void Application::RunEventLoop(void)
|
void Application::RunEventLoop()
|
||||||
{
|
{
|
||||||
double lastLoop = Utility::GetTime();
|
double lastLoop = Utility::GetTime();
|
||||||
|
|
||||||
@ -365,12 +365,12 @@ mainloop:
|
|||||||
UninitializeBase();
|
UninitializeBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::IsShuttingDown(void)
|
bool Application::IsShuttingDown()
|
||||||
{
|
{
|
||||||
return m_ShuttingDown;
|
return m_ShuttingDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::OnShutdown(void)
|
void Application::OnShutdown()
|
||||||
{
|
{
|
||||||
/* Nothing to do here. */
|
/* Nothing to do here. */
|
||||||
}
|
}
|
||||||
@ -395,7 +395,7 @@ static void ReloadProcessCallback(const ProcessResult& pr)
|
|||||||
t.detach();
|
t.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t Application::StartReloadProcess(void)
|
pid_t Application::StartReloadProcess()
|
||||||
{
|
{
|
||||||
Log(LogInformation, "Application", "Got reload command: Starting new instance.");
|
Log(LogInformation, "Application", "Got reload command: Starting new instance.");
|
||||||
|
|
||||||
@ -428,7 +428,7 @@ pid_t Application::StartReloadProcess(void)
|
|||||||
* Signals the application to shut down during the next
|
* Signals the application to shut down during the next
|
||||||
* execution of the event loop.
|
* execution of the event loop.
|
||||||
*/
|
*/
|
||||||
void Application::RequestShutdown(void)
|
void Application::RequestShutdown()
|
||||||
{
|
{
|
||||||
Log(LogInformation, "Application", "Received request to shut down.");
|
Log(LogInformation, "Application", "Received request to shut down.");
|
||||||
|
|
||||||
@ -439,7 +439,7 @@ void Application::RequestShutdown(void)
|
|||||||
* Signals the application to restart during the next
|
* Signals the application to restart during the next
|
||||||
* execution of the event loop.
|
* execution of the event loop.
|
||||||
*/
|
*/
|
||||||
void Application::RequestRestart(void)
|
void Application::RequestRestart()
|
||||||
{
|
{
|
||||||
m_RequestRestart = true;
|
m_RequestRestart = true;
|
||||||
}
|
}
|
||||||
@ -448,7 +448,7 @@ void Application::RequestRestart(void)
|
|||||||
* Signals the application to reopen log files during the
|
* Signals the application to reopen log files during the
|
||||||
* next execution of the event loop.
|
* next execution of the event loop.
|
||||||
*/
|
*/
|
||||||
void Application::RequestReopenLogs(void)
|
void Application::RequestReopenLogs()
|
||||||
{
|
{
|
||||||
m_RequestReopenLogs = true;
|
m_RequestReopenLogs = true;
|
||||||
}
|
}
|
||||||
@ -577,7 +577,7 @@ void Application::DisplayBugMessage(std::ostream& os)
|
|||||||
<< "***" << "\n";
|
<< "***" << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
String Application::GetCrashReportFilename(void)
|
String Application::GetCrashReportFilename()
|
||||||
{
|
{
|
||||||
return GetLocalStateDir() + "/log/icinga2/crash/report." + Convert::ToString(Utility::GetTime());
|
return GetLocalStateDir() + "/log/icinga2/crash/report." + Convert::ToString(Utility::GetTime());
|
||||||
}
|
}
|
||||||
@ -787,7 +787,7 @@ BOOL WINAPI Application::CtrlHandler(DWORD type)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::IsProcessElevated(void) {
|
bool Application::IsProcessElevated() {
|
||||||
BOOL fIsElevated = FALSE;
|
BOOL fIsElevated = FALSE;
|
||||||
DWORD dwError = ERROR_SUCCESS;
|
DWORD dwError = ERROR_SUCCESS;
|
||||||
HANDLE hToken = nullptr;
|
HANDLE hToken = nullptr;
|
||||||
@ -825,7 +825,7 @@ bool Application::IsProcessElevated(void) {
|
|||||||
/**
|
/**
|
||||||
* Handler for unhandled exceptions.
|
* Handler for unhandled exceptions.
|
||||||
*/
|
*/
|
||||||
void Application::ExceptionHandler(void)
|
void Application::ExceptionHandler()
|
||||||
{
|
{
|
||||||
if (l_InExceptionHandler)
|
if (l_InExceptionHandler)
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -934,7 +934,7 @@ LONG CALLBACK Application::SEHUnhandledExceptionFilter(PEXCEPTION_POINTERS exi)
|
|||||||
/**
|
/**
|
||||||
* Installs the exception handlers.
|
* Installs the exception handlers.
|
||||||
*/
|
*/
|
||||||
void Application::InstallExceptionHandlers(void)
|
void Application::InstallExceptionHandlers()
|
||||||
{
|
{
|
||||||
std::set_terminate(&Application::ExceptionHandler);
|
std::set_terminate(&Application::ExceptionHandler);
|
||||||
|
|
||||||
@ -953,7 +953,7 @@ void Application::InstallExceptionHandlers(void)
|
|||||||
*
|
*
|
||||||
* @returns The application's exit code.
|
* @returns The application's exit code.
|
||||||
*/
|
*/
|
||||||
int Application::Run(void)
|
int Application::Run()
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
@ -1123,7 +1123,7 @@ pid_t Application::ReadPidFile(const String& filename)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetPrefixDir(void)
|
String Application::GetPrefixDir()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("PrefixDir");
|
return ScriptGlobal::Get("PrefixDir");
|
||||||
}
|
}
|
||||||
@ -1144,7 +1144,7 @@ void Application::DeclarePrefixDir(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetSysconfDir(void)
|
String Application::GetSysconfDir()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("SysconfDir");
|
return ScriptGlobal::Get("SysconfDir");
|
||||||
}
|
}
|
||||||
@ -1165,7 +1165,7 @@ void Application::DeclareSysconfDir(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetRunDir(void)
|
String Application::GetRunDir()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("RunDir");
|
return ScriptGlobal::Get("RunDir");
|
||||||
}
|
}
|
||||||
@ -1186,7 +1186,7 @@ void Application::DeclareRunDir(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetLocalStateDir(void)
|
String Application::GetLocalStateDir()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("LocalStateDir");
|
return ScriptGlobal::Get("LocalStateDir");
|
||||||
}
|
}
|
||||||
@ -1207,7 +1207,7 @@ void Application::DeclareLocalStateDir(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetZonesDir(void)
|
String Application::GetZonesDir()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("ZonesDir", &Empty);
|
return ScriptGlobal::Get("ZonesDir", &Empty);
|
||||||
}
|
}
|
||||||
@ -1228,7 +1228,7 @@ void Application::DeclareZonesDir(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetPkgDataDir(void)
|
String Application::GetPkgDataDir()
|
||||||
{
|
{
|
||||||
String defaultValue = "";
|
String defaultValue = "";
|
||||||
return ScriptGlobal::Get("PkgDataDir", &Empty);
|
return ScriptGlobal::Get("PkgDataDir", &Empty);
|
||||||
@ -1250,7 +1250,7 @@ void Application::DeclarePkgDataDir(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetIncludeConfDir(void)
|
String Application::GetIncludeConfDir()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("IncludeConfDir", &Empty);
|
return ScriptGlobal::Get("IncludeConfDir", &Empty);
|
||||||
}
|
}
|
||||||
@ -1271,7 +1271,7 @@ void Application::DeclareIncludeConfDir(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetStatePath(void)
|
String Application::GetStatePath()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("StatePath", &Empty);
|
return ScriptGlobal::Get("StatePath", &Empty);
|
||||||
}
|
}
|
||||||
@ -1292,7 +1292,7 @@ void Application::DeclareStatePath(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetModAttrPath(void)
|
String Application::GetModAttrPath()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("ModAttrPath", &Empty);
|
return ScriptGlobal::Get("ModAttrPath", &Empty);
|
||||||
}
|
}
|
||||||
@ -1313,7 +1313,7 @@ void Application::DeclareModAttrPath(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetObjectsPath(void)
|
String Application::GetObjectsPath()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("ObjectsPath", &Empty);
|
return ScriptGlobal::Get("ObjectsPath", &Empty);
|
||||||
}
|
}
|
||||||
@ -1334,7 +1334,7 @@ void Application::DeclareObjectsPath(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetVarsPath(void)
|
String Application::GetVarsPath()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("VarsPath", &Empty);
|
return ScriptGlobal::Get("VarsPath", &Empty);
|
||||||
}
|
}
|
||||||
@ -1355,7 +1355,7 @@ void Application::DeclareVarsPath(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The path.
|
* @returns The path.
|
||||||
*/
|
*/
|
||||||
String Application::GetPidPath(void)
|
String Application::GetPidPath()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("PidPath", &Empty);
|
return ScriptGlobal::Get("PidPath", &Empty);
|
||||||
}
|
}
|
||||||
@ -1376,7 +1376,7 @@ void Application::DeclarePidPath(const String& path)
|
|||||||
*
|
*
|
||||||
* @returns The name.
|
* @returns The name.
|
||||||
*/
|
*/
|
||||||
String Application::GetRunAsUser(void)
|
String Application::GetRunAsUser()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("RunAsUser");
|
return ScriptGlobal::Get("RunAsUser");
|
||||||
}
|
}
|
||||||
@ -1397,7 +1397,7 @@ void Application::DeclareRunAsUser(const String& user)
|
|||||||
*
|
*
|
||||||
* @returns The name.
|
* @returns The name.
|
||||||
*/
|
*/
|
||||||
String Application::GetRunAsGroup(void)
|
String Application::GetRunAsGroup()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("RunAsGroup");
|
return ScriptGlobal::Get("RunAsGroup");
|
||||||
}
|
}
|
||||||
@ -1418,12 +1418,12 @@ void Application::DeclareRunAsGroup(const String& group)
|
|||||||
*
|
*
|
||||||
* @returns The limit.
|
* @returns The limit.
|
||||||
*/
|
*/
|
||||||
int Application::GetRLimitFiles(void)
|
int Application::GetRLimitFiles()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("RLimitFiles");
|
return ScriptGlobal::Get("RLimitFiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
int Application::GetDefaultRLimitFiles(void)
|
int Application::GetDefaultRLimitFiles()
|
||||||
{
|
{
|
||||||
return 16 * 1024;
|
return 16 * 1024;
|
||||||
}
|
}
|
||||||
@ -1444,12 +1444,12 @@ void Application::DeclareRLimitFiles(int limit)
|
|||||||
*
|
*
|
||||||
* @returns The limit.
|
* @returns The limit.
|
||||||
*/
|
*/
|
||||||
int Application::GetRLimitProcesses(void)
|
int Application::GetRLimitProcesses()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("RLimitProcesses");
|
return ScriptGlobal::Get("RLimitProcesses");
|
||||||
}
|
}
|
||||||
|
|
||||||
int Application::GetDefaultRLimitProcesses(void)
|
int Application::GetDefaultRLimitProcesses()
|
||||||
{
|
{
|
||||||
return 16 * 1024;
|
return 16 * 1024;
|
||||||
}
|
}
|
||||||
@ -1470,12 +1470,12 @@ void Application::DeclareRLimitProcesses(int limit)
|
|||||||
*
|
*
|
||||||
* @returns The limit.
|
* @returns The limit.
|
||||||
*/
|
*/
|
||||||
int Application::GetRLimitStack(void)
|
int Application::GetRLimitStack()
|
||||||
{
|
{
|
||||||
return ScriptGlobal::Get("RLimitStack");
|
return ScriptGlobal::Get("RLimitStack");
|
||||||
}
|
}
|
||||||
|
|
||||||
int Application::GetDefaultRLimitStack(void)
|
int Application::GetDefaultRLimitStack()
|
||||||
{
|
{
|
||||||
return 256 * 1024;
|
return 256 * 1024;
|
||||||
}
|
}
|
||||||
@ -1507,7 +1507,7 @@ void Application::DeclareConcurrency(int ncpus)
|
|||||||
*
|
*
|
||||||
* @returns The concurrency level.
|
* @returns The concurrency level.
|
||||||
*/
|
*/
|
||||||
int Application::GetConcurrency(void)
|
int Application::GetConcurrency()
|
||||||
{
|
{
|
||||||
Value defaultConcurrency = std::thread::hardware_concurrency();
|
Value defaultConcurrency = std::thread::hardware_concurrency();
|
||||||
return ScriptGlobal::Get("Concurrency", &defaultConcurrency);
|
return ScriptGlobal::Get("Concurrency", &defaultConcurrency);
|
||||||
@ -1518,13 +1518,13 @@ int Application::GetConcurrency(void)
|
|||||||
*
|
*
|
||||||
* @returns The global thread pool.
|
* @returns The global thread pool.
|
||||||
*/
|
*/
|
||||||
ThreadPool& Application::GetTP(void)
|
ThreadPool& Application::GetTP()
|
||||||
{
|
{
|
||||||
static ThreadPool tp;
|
static ThreadPool tp;
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Application::GetStartTime(void)
|
double Application::GetStartTime()
|
||||||
{
|
{
|
||||||
return m_StartTime;
|
return m_StartTime;
|
||||||
}
|
}
|
||||||
@ -1534,7 +1534,7 @@ void Application::SetStartTime(double ts)
|
|||||||
m_StartTime = ts;
|
m_StartTime = ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Application::GetMainTime(void)
|
double Application::GetMainTime()
|
||||||
{
|
{
|
||||||
return m_MainTime;
|
return m_MainTime;
|
||||||
}
|
}
|
||||||
@ -1544,7 +1544,7 @@ void Application::SetMainTime(double ts)
|
|||||||
m_MainTime = ts;
|
m_MainTime = ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::GetScriptDebuggerEnabled(void)
|
bool Application::GetScriptDebuggerEnabled()
|
||||||
{
|
{
|
||||||
return m_ScriptDebuggerEnabled;
|
return m_ScriptDebuggerEnabled;
|
||||||
}
|
}
|
||||||
@ -1554,7 +1554,7 @@ void Application::SetScriptDebuggerEnabled(bool enabled)
|
|||||||
m_ScriptDebuggerEnabled = enabled;
|
m_ScriptDebuggerEnabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Application::GetLastReloadFailed(void)
|
double Application::GetLastReloadFailed()
|
||||||
{
|
{
|
||||||
return m_LastReloadFailed;
|
return m_LastReloadFailed;
|
||||||
}
|
}
|
||||||
|
@ -39,44 +39,44 @@ class Application : public ObjectImpl<Application> {
|
|||||||
public:
|
public:
|
||||||
DECLARE_OBJECT(Application);
|
DECLARE_OBJECT(Application);
|
||||||
|
|
||||||
static boost::signals2::signal<void (void)> OnReopenLogs;
|
static boost::signals2::signal<void ()> OnReopenLogs;
|
||||||
|
|
||||||
~Application(void);
|
~Application();
|
||||||
|
|
||||||
static void InitializeBase(void);
|
static void InitializeBase();
|
||||||
static void UninitializeBase(void);
|
static void UninitializeBase();
|
||||||
|
|
||||||
static Application::Ptr GetInstance(void);
|
static Application::Ptr GetInstance();
|
||||||
|
|
||||||
static void Exit(int rc);
|
static void Exit(int rc);
|
||||||
|
|
||||||
int Run(void);
|
int Run();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the application.
|
* Starts the application.
|
||||||
*
|
*
|
||||||
* @returns The exit code of the application.
|
* @returns The exit code of the application.
|
||||||
*/
|
*/
|
||||||
virtual int Main(void) = 0;
|
virtual int Main() = 0;
|
||||||
|
|
||||||
static void SetResourceLimits(void);
|
static void SetResourceLimits();
|
||||||
|
|
||||||
static int GetArgC(void);
|
static int GetArgC();
|
||||||
static void SetArgC(int argc);
|
static void SetArgC(int argc);
|
||||||
|
|
||||||
static char **GetArgV(void);
|
static char **GetArgV();
|
||||||
static void SetArgV(char **argv);
|
static void SetArgV(char **argv);
|
||||||
|
|
||||||
static void InstallExceptionHandlers(void);
|
static void InstallExceptionHandlers();
|
||||||
|
|
||||||
static void RequestShutdown(void);
|
static void RequestShutdown();
|
||||||
static void RequestRestart(void);
|
static void RequestRestart();
|
||||||
static void RequestReopenLogs(void);
|
static void RequestReopenLogs();
|
||||||
|
|
||||||
static bool IsShuttingDown(void);
|
static bool IsShuttingDown();
|
||||||
|
|
||||||
static void SetDebuggingSeverity(LogSeverity severity);
|
static void SetDebuggingSeverity(LogSeverity severity);
|
||||||
static LogSeverity GetDebuggingSeverity(void);
|
static LogSeverity GetDebuggingSeverity();
|
||||||
|
|
||||||
void UpdatePidFile(const String& filename, pid_t pid = Utility::GetPid());
|
void UpdatePidFile(const String& filename, pid_t pid = Utility::GetPid());
|
||||||
void ClosePidFile(bool unlink);
|
void ClosePidFile(bool unlink);
|
||||||
@ -84,95 +84,95 @@ public:
|
|||||||
|
|
||||||
static String GetExePath(const String& argv0);
|
static String GetExePath(const String& argv0);
|
||||||
|
|
||||||
static String GetPrefixDir(void);
|
static String GetPrefixDir();
|
||||||
static void DeclarePrefixDir(const String& path);
|
static void DeclarePrefixDir(const String& path);
|
||||||
|
|
||||||
static String GetSysconfDir(void);
|
static String GetSysconfDir();
|
||||||
static void DeclareSysconfDir(const String& path);
|
static void DeclareSysconfDir(const String& path);
|
||||||
|
|
||||||
static String GetZonesDir(void);
|
static String GetZonesDir();
|
||||||
static void DeclareZonesDir(const String& path);
|
static void DeclareZonesDir(const String& path);
|
||||||
|
|
||||||
static String GetRunDir(void);
|
static String GetRunDir();
|
||||||
static void DeclareRunDir(const String& path);
|
static void DeclareRunDir(const String& path);
|
||||||
|
|
||||||
static String GetLocalStateDir(void);
|
static String GetLocalStateDir();
|
||||||
static void DeclareLocalStateDir(const String& path);
|
static void DeclareLocalStateDir(const String& path);
|
||||||
|
|
||||||
static String GetPkgDataDir(void);
|
static String GetPkgDataDir();
|
||||||
static void DeclarePkgDataDir(const String& path);
|
static void DeclarePkgDataDir(const String& path);
|
||||||
|
|
||||||
static String GetIncludeConfDir(void);
|
static String GetIncludeConfDir();
|
||||||
static void DeclareIncludeConfDir(const String& path);
|
static void DeclareIncludeConfDir(const String& path);
|
||||||
|
|
||||||
static String GetStatePath(void);
|
static String GetStatePath();
|
||||||
static void DeclareStatePath(const String& path);
|
static void DeclareStatePath(const String& path);
|
||||||
|
|
||||||
static String GetModAttrPath(void);
|
static String GetModAttrPath();
|
||||||
static void DeclareModAttrPath(const String& path);
|
static void DeclareModAttrPath(const String& path);
|
||||||
|
|
||||||
static String GetObjectsPath(void);
|
static String GetObjectsPath();
|
||||||
static void DeclareObjectsPath(const String& path);
|
static void DeclareObjectsPath(const String& path);
|
||||||
|
|
||||||
static String GetVarsPath(void);
|
static String GetVarsPath();
|
||||||
static void DeclareVarsPath(const String& path);
|
static void DeclareVarsPath(const String& path);
|
||||||
|
|
||||||
static String GetPidPath(void);
|
static String GetPidPath();
|
||||||
static void DeclarePidPath(const String& path);
|
static void DeclarePidPath(const String& path);
|
||||||
|
|
||||||
static String GetRunAsUser(void);
|
static String GetRunAsUser();
|
||||||
static void DeclareRunAsUser(const String& user);
|
static void DeclareRunAsUser(const String& user);
|
||||||
|
|
||||||
static String GetRunAsGroup(void);
|
static String GetRunAsGroup();
|
||||||
static void DeclareRunAsGroup(const String& group);
|
static void DeclareRunAsGroup(const String& group);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static bool IsProcessElevated(void);
|
static bool IsProcessElevated();
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
static int GetRLimitFiles(void);
|
static int GetRLimitFiles();
|
||||||
static int GetDefaultRLimitFiles(void);
|
static int GetDefaultRLimitFiles();
|
||||||
static void DeclareRLimitFiles(int limit);
|
static void DeclareRLimitFiles(int limit);
|
||||||
|
|
||||||
static int GetRLimitProcesses(void);
|
static int GetRLimitProcesses();
|
||||||
static int GetDefaultRLimitProcesses(void);
|
static int GetDefaultRLimitProcesses();
|
||||||
static void DeclareRLimitProcesses(int limit);
|
static void DeclareRLimitProcesses(int limit);
|
||||||
|
|
||||||
static int GetRLimitStack(void);
|
static int GetRLimitStack();
|
||||||
static int GetDefaultRLimitStack(void);
|
static int GetDefaultRLimitStack();
|
||||||
static void DeclareRLimitStack(int limit);
|
static void DeclareRLimitStack(int limit);
|
||||||
|
|
||||||
static int GetConcurrency(void);
|
static int GetConcurrency();
|
||||||
static void DeclareConcurrency(int ncpus);
|
static void DeclareConcurrency(int ncpus);
|
||||||
|
|
||||||
static ThreadPool& GetTP(void);
|
static ThreadPool& GetTP();
|
||||||
|
|
||||||
static String GetAppVersion(void);
|
static String GetAppVersion();
|
||||||
static String GetAppSpecVersion(void);
|
static String GetAppSpecVersion();
|
||||||
|
|
||||||
static double GetStartTime(void);
|
static double GetStartTime();
|
||||||
static void SetStartTime(double ts);
|
static void SetStartTime(double ts);
|
||||||
|
|
||||||
static double GetMainTime(void);
|
static double GetMainTime();
|
||||||
static void SetMainTime(double ts);
|
static void SetMainTime(double ts);
|
||||||
|
|
||||||
static bool GetScriptDebuggerEnabled(void);
|
static bool GetScriptDebuggerEnabled();
|
||||||
static void SetScriptDebuggerEnabled(bool enabled);
|
static void SetScriptDebuggerEnabled(bool enabled);
|
||||||
|
|
||||||
static double GetLastReloadFailed(void);
|
static double GetLastReloadFailed();
|
||||||
static void SetLastReloadFailed(double ts);
|
static void SetLastReloadFailed(double ts);
|
||||||
|
|
||||||
static void DisplayInfoMessage(std::ostream& os, bool skipVersion = false);
|
static void DisplayInfoMessage(std::ostream& os, bool skipVersion = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnConfigLoaded(void) override;
|
virtual void OnConfigLoaded() override;
|
||||||
virtual void Stop(bool runtimeRemoved) override;
|
virtual void Stop(bool runtimeRemoved) override;
|
||||||
|
|
||||||
void RunEventLoop(void);
|
void RunEventLoop();
|
||||||
|
|
||||||
pid_t StartReloadProcess(void);
|
pid_t StartReloadProcess();
|
||||||
|
|
||||||
virtual void OnShutdown(void);
|
virtual void OnShutdown();
|
||||||
|
|
||||||
virtual void ValidateName(const String& value, const ValidationUtils& utils) override final;
|
virtual void ValidateName(const String& value, const ValidationUtils& utils) override final;
|
||||||
|
|
||||||
@ -205,9 +205,9 @@ private:
|
|||||||
|
|
||||||
static void SigAbrtHandler(int signum);
|
static void SigAbrtHandler(int signum);
|
||||||
static void SigUsr1Handler(int signum);
|
static void SigUsr1Handler(int signum);
|
||||||
static void ExceptionHandler(void);
|
static void ExceptionHandler();
|
||||||
|
|
||||||
static String GetCrashReportFilename(void);
|
static String GetCrashReportFilename();
|
||||||
|
|
||||||
static void AttachDebugger(const String& filename, bool interactive);
|
static void AttachDebugger(const String& filename, bool interactive);
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
static double ArrayLen(void)
|
static double ArrayLen()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
|
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
|
||||||
@ -68,7 +68,7 @@ static bool ArrayContains(const Value& value)
|
|||||||
return self->Contains(value);
|
return self->Contains(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ArrayClear(void)
|
static void ArrayClear()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
|
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
|
||||||
@ -103,7 +103,7 @@ static Array::Ptr ArraySort(const std::vector<Value>& args)
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Array::Ptr ArrayShallowClone(void)
|
static Array::Ptr ArrayShallowClone()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
|
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
|
||||||
@ -132,7 +132,7 @@ static Value ArrayJoin(const Value& separator)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Array::Ptr ArrayReverse(void)
|
static Array::Ptr ArrayReverse()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
|
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
|
||||||
@ -230,7 +230,7 @@ static bool ArrayAll(const Function::Ptr& function)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
static Array::Ptr ArrayUnique(void)
|
static Array::Ptr ArrayUnique()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
|
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
|
||||||
@ -245,7 +245,7 @@ static Array::Ptr ArrayUnique(void)
|
|||||||
return Array::FromSet(result);
|
return Array::FromSet(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Ptr Array::GetPrototype(void)
|
Object::Ptr Array::GetPrototype()
|
||||||
{
|
{
|
||||||
static Dictionary::Ptr prototype;
|
static Dictionary::Ptr prototype;
|
||||||
|
|
||||||
|
@ -32,14 +32,14 @@ template class std::vector<Value>;
|
|||||||
|
|
||||||
REGISTER_PRIMITIVE_TYPE(Array, Object, Array::GetPrototype());
|
REGISTER_PRIMITIVE_TYPE(Array, Object, Array::GetPrototype());
|
||||||
|
|
||||||
Array::Array(void)
|
Array::Array()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Array::Array(std::initializer_list<Value> init)
|
Array::Array(std::initializer_list<Value> init)
|
||||||
: m_Data(init)
|
: m_Data(init)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Array::~Array(void)
|
Array::~Array()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,7 +112,7 @@ void Array::Add(Value&& value)
|
|||||||
*
|
*
|
||||||
* @returns An iterator.
|
* @returns An iterator.
|
||||||
*/
|
*/
|
||||||
Array::Iterator Array::Begin(void)
|
Array::Iterator Array::Begin()
|
||||||
{
|
{
|
||||||
ASSERT(OwnsLock());
|
ASSERT(OwnsLock());
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ Array::Iterator Array::Begin(void)
|
|||||||
*
|
*
|
||||||
* @returns An iterator.
|
* @returns An iterator.
|
||||||
*/
|
*/
|
||||||
Array::Iterator Array::End(void)
|
Array::Iterator Array::End()
|
||||||
{
|
{
|
||||||
ASSERT(OwnsLock());
|
ASSERT(OwnsLock());
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ Array::Iterator Array::End(void)
|
|||||||
*
|
*
|
||||||
* @returns Number of elements.
|
* @returns Number of elements.
|
||||||
*/
|
*/
|
||||||
size_t Array::GetLength(void) const
|
size_t Array::GetLength() const
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ void Array::Resize(SizeType newSize)
|
|||||||
m_Data.resize(newSize);
|
m_Data.resize(newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Array::Clear(void)
|
void Array::Clear()
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ void Array::CopyTo(const Array::Ptr& dest) const
|
|||||||
*
|
*
|
||||||
* @returns a copy of the array.
|
* @returns a copy of the array.
|
||||||
*/
|
*/
|
||||||
Array::Ptr Array::ShallowClone(void) const
|
Array::Ptr Array::ShallowClone() const
|
||||||
{
|
{
|
||||||
Array::Ptr clone = new Array();
|
Array::Ptr clone = new Array();
|
||||||
CopyTo(clone);
|
CopyTo(clone);
|
||||||
@ -244,7 +244,7 @@ Array::Ptr Array::ShallowClone(void) const
|
|||||||
*
|
*
|
||||||
* @returns a copy of the array.
|
* @returns a copy of the array.
|
||||||
*/
|
*/
|
||||||
Object::Ptr Array::Clone(void) const
|
Object::Ptr Array::Clone() const
|
||||||
{
|
{
|
||||||
Array::Ptr arr = new Array();
|
Array::Ptr arr = new Array();
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ Object::Ptr Array::Clone(void) const
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array::Ptr Array::Reverse(void) const
|
Array::Ptr Array::Reverse() const
|
||||||
{
|
{
|
||||||
Array::Ptr result = new Array();
|
Array::Ptr result = new Array();
|
||||||
|
|
||||||
@ -268,13 +268,13 @@ Array::Ptr Array::Reverse(void) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Array::Sort(void)
|
void Array::Sort()
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
std::sort(m_Data.begin(), m_Data.end());
|
std::sort(m_Data.begin(), m_Data.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
String Array::ToString(void) const
|
String Array::ToString() const
|
||||||
{
|
{
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
ConfigWriter::EmitArray(msgbuf, 1, const_cast<Array *>(this));
|
ConfigWriter::EmitArray(msgbuf, 1, const_cast<Array *>(this));
|
||||||
|
@ -47,10 +47,10 @@ public:
|
|||||||
|
|
||||||
typedef std::vector<Value>::size_type SizeType;
|
typedef std::vector<Value>::size_type SizeType;
|
||||||
|
|
||||||
Array(void);
|
Array();
|
||||||
Array(std::initializer_list<Value> init);
|
Array(std::initializer_list<Value> init);
|
||||||
|
|
||||||
~Array(void);
|
~Array();
|
||||||
|
|
||||||
Value Get(SizeType index) const;
|
Value Get(SizeType index) const;
|
||||||
void Set(SizeType index, const Value& value);
|
void Set(SizeType index, const Value& value);
|
||||||
@ -58,10 +58,10 @@ public:
|
|||||||
void Add(const Value& value);
|
void Add(const Value& value);
|
||||||
void Add(Value&& value);
|
void Add(Value&& value);
|
||||||
|
|
||||||
Iterator Begin(void);
|
Iterator Begin();
|
||||||
Iterator End(void);
|
Iterator End();
|
||||||
|
|
||||||
size_t GetLength(void) const;
|
size_t GetLength() const;
|
||||||
bool Contains(const Value& value) const;
|
bool Contains(const Value& value) const;
|
||||||
|
|
||||||
void Insert(SizeType index, const Value& value);
|
void Insert(SizeType index, const Value& value);
|
||||||
@ -69,14 +69,14 @@ public:
|
|||||||
void Remove(Iterator it);
|
void Remove(Iterator it);
|
||||||
|
|
||||||
void Resize(SizeType newSize);
|
void Resize(SizeType newSize);
|
||||||
void Clear(void);
|
void Clear();
|
||||||
|
|
||||||
void Reserve(SizeType newSize);
|
void Reserve(SizeType newSize);
|
||||||
|
|
||||||
void CopyTo(const Array::Ptr& dest) const;
|
void CopyTo(const Array::Ptr& dest) const;
|
||||||
Array::Ptr ShallowClone(void) const;
|
Array::Ptr ShallowClone() const;
|
||||||
|
|
||||||
static Object::Ptr GetPrototype(void);
|
static Object::Ptr GetPrototype();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static Array::Ptr FromVector(const std::vector<T>& v)
|
static Array::Ptr FromVector(const std::vector<T>& v)
|
||||||
@ -88,7 +88,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::set<T> ToSet(void)
|
std::set<T> ToSet()
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
return std::set<T>(Begin(), End());
|
return std::set<T>(Begin(), End());
|
||||||
@ -103,13 +103,13 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Object::Ptr Clone(void) const override;
|
virtual Object::Ptr Clone() const override;
|
||||||
|
|
||||||
Array::Ptr Reverse(void) const;
|
Array::Ptr Reverse() const;
|
||||||
|
|
||||||
void Sort(void);
|
void Sort();
|
||||||
|
|
||||||
virtual String ToString(void) const override;
|
virtual String ToString() const override;
|
||||||
|
|
||||||
virtual Value GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const override;
|
virtual Value GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const override;
|
||||||
virtual void SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo) override;
|
virtual void SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo) override;
|
||||||
|
@ -25,14 +25,14 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
static String BooleanToString(void)
|
static String BooleanToString()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
bool self = vframe->Self;
|
bool self = vframe->Self;
|
||||||
return self ? "true" : "false";
|
return self ? "true" : "false";
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Ptr Boolean::GetPrototype(void)
|
Object::Ptr Boolean::GetPrototype()
|
||||||
{
|
{
|
||||||
static Dictionary::Ptr prototype;
|
static Dictionary::Ptr prototype;
|
||||||
|
|
||||||
|
@ -33,10 +33,10 @@ class Value;
|
|||||||
class Boolean
|
class Boolean
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Object::Ptr GetPrototype(void);
|
static Object::Ptr GetPrototype();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Boolean(void);
|
Boolean();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ static void ConfigObjectRestoreAttribute(const String& attr)
|
|||||||
return self->RestoreAttribute(attr);
|
return self->RestoreAttribute(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Ptr ConfigObject::GetPrototype(void)
|
Object::Ptr ConfigObject::GetPrototype()
|
||||||
{
|
{
|
||||||
static Dictionary::Ptr prototype;
|
static Dictionary::Ptr prototype;
|
||||||
|
|
||||||
|
@ -46,15 +46,15 @@ REGISTER_TYPE_WITH_PROTOTYPE(ConfigObject, ConfigObject::GetPrototype());
|
|||||||
|
|
||||||
boost::signals2::signal<void (const ConfigObject::Ptr&)> ConfigObject::OnStateChanged;
|
boost::signals2::signal<void (const ConfigObject::Ptr&)> ConfigObject::OnStateChanged;
|
||||||
|
|
||||||
ConfigObject::ConfigObject(void)
|
ConfigObject::ConfigObject()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool ConfigObject::IsActive(void) const
|
bool ConfigObject::IsActive() const
|
||||||
{
|
{
|
||||||
return GetActive();
|
return GetActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigObject::IsPaused(void) const
|
bool ConfigObject::IsPaused() const
|
||||||
{
|
{
|
||||||
return GetPaused();
|
return GetPaused();
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ bool ConfigObject::IsAttributeModified(const String& attr) const
|
|||||||
return original_attributes->Contains(attr);
|
return original_attributes->Contains(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigObject::Register(void)
|
void ConfigObject::Register()
|
||||||
{
|
{
|
||||||
ASSERT(!OwnsLock());
|
ASSERT(!OwnsLock());
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ void ConfigObject::Register(void)
|
|||||||
type->RegisterObject(this);
|
type->RegisterObject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigObject::Unregister(void)
|
void ConfigObject::Unregister()
|
||||||
{
|
{
|
||||||
ASSERT(!OwnsLock());
|
ASSERT(!OwnsLock());
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ void ConfigObject::Start(bool runtimeCreated)
|
|||||||
SetStartCalled(true);
|
SetStartCalled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigObject::PreActivate(void)
|
void ConfigObject::PreActivate()
|
||||||
{
|
{
|
||||||
CONTEXT("Setting 'active' to true for object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'");
|
CONTEXT("Setting 'active' to true for object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'");
|
||||||
|
|
||||||
@ -431,12 +431,12 @@ void ConfigObject::Deactivate(bool runtimeRemoved)
|
|||||||
NotifyActive();
|
NotifyActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigObject::OnConfigLoaded(void)
|
void ConfigObject::OnConfigLoaded()
|
||||||
{
|
{
|
||||||
/* Nothing to do here. */
|
/* Nothing to do here. */
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigObject::OnAllConfigLoaded(void)
|
void ConfigObject::OnAllConfigLoaded()
|
||||||
{
|
{
|
||||||
static ConfigType *ctype;
|
static ConfigType *ctype;
|
||||||
|
|
||||||
@ -456,17 +456,17 @@ void ConfigObject::CreateChildObjects(const Type::Ptr& childType)
|
|||||||
/* Nothing to do here. */
|
/* Nothing to do here. */
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigObject::OnStateLoaded(void)
|
void ConfigObject::OnStateLoaded()
|
||||||
{
|
{
|
||||||
/* Nothing to do here. */
|
/* Nothing to do here. */
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigObject::Pause(void)
|
void ConfigObject::Pause()
|
||||||
{
|
{
|
||||||
SetPauseCalled(true);
|
SetPauseCalled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigObject::Resume(void)
|
void ConfigObject::Resume()
|
||||||
{
|
{
|
||||||
SetResumeCalled(true);
|
SetResumeCalled(true);
|
||||||
}
|
}
|
||||||
@ -624,7 +624,7 @@ void ConfigObject::RestoreObjects(const String& filename, int attributeTypes)
|
|||||||
<< "Restored " << restored << " objects. Loaded " << no_state << " new objects without state.";
|
<< "Restored " << restored << " objects. Loaded " << no_state << " new objects without state.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigObject::StopObjects(void)
|
void ConfigObject::StopObjects()
|
||||||
{
|
{
|
||||||
for (const Type::Ptr& type : Type::GetAllTypes()) {
|
for (const Type::Ptr& type : Type::GetAllTypes()) {
|
||||||
ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
|
ConfigType *dtype = dynamic_cast<ConfigType *>(type.get());
|
||||||
@ -711,12 +711,12 @@ ConfigObject::Ptr ConfigObject::GetObject(const String& type, const String& name
|
|||||||
return ctype->GetObject(name);
|
return ctype->GetObject(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigObject::Ptr ConfigObject::GetZone(void) const
|
ConfigObject::Ptr ConfigObject::GetZone() const
|
||||||
{
|
{
|
||||||
return m_Zone;
|
return m_Zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr ConfigObject::GetSourceLocation(void) const
|
Dictionary::Ptr ConfigObject::GetSourceLocation() const
|
||||||
{
|
{
|
||||||
DebugInfo di = GetDebugInfo();
|
DebugInfo di = GetDebugInfo();
|
||||||
|
|
||||||
@ -729,5 +729,5 @@ Dictionary::Ptr ConfigObject::GetSourceLocation(void) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
NameComposer::~NameComposer(void)
|
NameComposer::~NameComposer()
|
||||||
{ }
|
{ }
|
||||||
|
@ -44,23 +44,23 @@ public:
|
|||||||
|
|
||||||
static boost::signals2::signal<void (const ConfigObject::Ptr&)> OnStateChanged;
|
static boost::signals2::signal<void (const ConfigObject::Ptr&)> OnStateChanged;
|
||||||
|
|
||||||
bool IsActive(void) const;
|
bool IsActive() const;
|
||||||
bool IsPaused(void) const;
|
bool IsPaused() const;
|
||||||
|
|
||||||
void SetExtension(const String& key, const Value& value);
|
void SetExtension(const String& key, const Value& value);
|
||||||
Value GetExtension(const String& key);
|
Value GetExtension(const String& key);
|
||||||
void ClearExtension(const String& key);
|
void ClearExtension(const String& key);
|
||||||
|
|
||||||
ConfigObject::Ptr GetZone(void) const;
|
ConfigObject::Ptr GetZone() const;
|
||||||
|
|
||||||
void ModifyAttribute(const String& attr, const Value& value, bool updateVersion = true);
|
void ModifyAttribute(const String& attr, const Value& value, bool updateVersion = true);
|
||||||
void RestoreAttribute(const String& attr, bool updateVersion = true);
|
void RestoreAttribute(const String& attr, bool updateVersion = true);
|
||||||
bool IsAttributeModified(const String& attr) const;
|
bool IsAttributeModified(const String& attr) const;
|
||||||
|
|
||||||
void Register(void);
|
void Register();
|
||||||
void Unregister(void);
|
void Unregister();
|
||||||
|
|
||||||
void PreActivate(void);
|
void PreActivate();
|
||||||
void Activate(bool runtimeCreated = false);
|
void Activate(bool runtimeCreated = false);
|
||||||
void Deactivate(bool runtimeRemoved = false);
|
void Deactivate(bool runtimeRemoved = false);
|
||||||
void SetAuthority(bool authority);
|
void SetAuthority(bool authority);
|
||||||
@ -68,15 +68,15 @@ public:
|
|||||||
virtual void Start(bool runtimeCreated = false) override;
|
virtual void Start(bool runtimeCreated = false) override;
|
||||||
virtual void Stop(bool runtimeRemoved = false) override;
|
virtual void Stop(bool runtimeRemoved = false) override;
|
||||||
|
|
||||||
virtual void Pause(void);
|
virtual void Pause();
|
||||||
virtual void Resume(void);
|
virtual void Resume();
|
||||||
|
|
||||||
virtual void OnConfigLoaded(void);
|
virtual void OnConfigLoaded();
|
||||||
virtual void CreateChildObjects(const Type::Ptr& childType);
|
virtual void CreateChildObjects(const Type::Ptr& childType);
|
||||||
virtual void OnAllConfigLoaded(void);
|
virtual void OnAllConfigLoaded();
|
||||||
virtual void OnStateLoaded(void);
|
virtual void OnStateLoaded();
|
||||||
|
|
||||||
virtual Dictionary::Ptr GetSourceLocation(void) const override;
|
virtual Dictionary::Ptr GetSourceLocation() const override;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static intrusive_ptr<T> GetObject(const String& name)
|
static intrusive_ptr<T> GetObject(const String& name)
|
||||||
@ -90,14 +90,14 @@ public:
|
|||||||
|
|
||||||
static void DumpObjects(const String& filename, int attributeTypes = FAState);
|
static void DumpObjects(const String& filename, int attributeTypes = FAState);
|
||||||
static void RestoreObjects(const String& filename, int attributeTypes = FAState);
|
static void RestoreObjects(const String& filename, int attributeTypes = FAState);
|
||||||
static void StopObjects(void);
|
static void StopObjects();
|
||||||
|
|
||||||
static void DumpModifiedAttributes(const std::function<void(const ConfigObject::Ptr&, const String&, const Value&)>& callback);
|
static void DumpModifiedAttributes(const std::function<void(const ConfigObject::Ptr&, const String&, const Value&)>& callback);
|
||||||
|
|
||||||
static Object::Ptr GetPrototype(void);
|
static Object::Ptr GetPrototype();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit ConfigObject(void);
|
explicit ConfigObject();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConfigObject::Ptr m_Zone;
|
ConfigObject::Ptr m_Zone;
|
||||||
@ -106,7 +106,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define DECLARE_OBJECTNAME(klass) \
|
#define DECLARE_OBJECTNAME(klass) \
|
||||||
inline static String GetTypeName(void) \
|
inline static String GetTypeName() \
|
||||||
{ \
|
{ \
|
||||||
return #klass; \
|
return #klass; \
|
||||||
} \
|
} \
|
||||||
|
@ -35,7 +35,7 @@ enum HAMode
|
|||||||
class NameComposer
|
class NameComposer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~NameComposer(void);
|
virtual ~NameComposer();
|
||||||
|
|
||||||
virtual String MakeName(const String& shortName, const Object::Ptr& context) const = 0;
|
virtual String MakeName(const String& shortName, const Object::Ptr& context) const = 0;
|
||||||
virtual Dictionary::Ptr ParseName(const String& name) const = 0;
|
virtual Dictionary::Ptr ParseName(const String& name) const = 0;
|
||||||
@ -49,7 +49,7 @@ code {{{
|
|||||||
class ConfigObjectBase : public ObjectImpl<ConfigObjectBase>
|
class ConfigObjectBase : public ObjectImpl<ConfigObjectBase>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline DebugInfo GetDebugInfo(void) const
|
inline DebugInfo GetDebugInfo() const
|
||||||
{
|
{
|
||||||
return m_DebugInfo;
|
return m_DebugInfo;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
ConfigType::~ConfigType(void)
|
ConfigType::~ConfigType()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
ConfigObject::Ptr ConfigType::GetObject(const String& name) const
|
ConfigObject::Ptr ConfigType::GetObject(const String& name) const
|
||||||
@ -75,7 +75,7 @@ void ConfigType::UnregisterObject(const ConfigObject::Ptr& object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ConfigObject::Ptr> ConfigType::GetObjects(void) const
|
std::vector<ConfigObject::Ptr> ConfigType::GetObjects() const
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_Mutex);
|
boost::mutex::scoped_lock lock(m_Mutex);
|
||||||
return m_ObjectVector;
|
return m_ObjectVector;
|
||||||
@ -86,7 +86,7 @@ std::vector<ConfigObject::Ptr> ConfigType::GetObjectsHelper(Type *type)
|
|||||||
return static_cast<TypeImpl<ConfigObject> *>(type)->GetObjects();
|
return static_cast<TypeImpl<ConfigObject> *>(type)->GetObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConfigType::GetObjectCount(void) const
|
int ConfigType::GetObjectCount() const
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_Mutex);
|
boost::mutex::scoped_lock lock(m_Mutex);
|
||||||
return m_ObjectVector.size();
|
return m_ObjectVector.size();
|
||||||
|
@ -33,24 +33,24 @@ class ConfigObject;
|
|||||||
class ConfigType
|
class ConfigType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ConfigType(void);
|
virtual ~ConfigType();
|
||||||
|
|
||||||
intrusive_ptr<ConfigObject> GetObject(const String& name) const;
|
intrusive_ptr<ConfigObject> GetObject(const String& name) const;
|
||||||
|
|
||||||
void RegisterObject(const intrusive_ptr<ConfigObject>& object);
|
void RegisterObject(const intrusive_ptr<ConfigObject>& object);
|
||||||
void UnregisterObject(const intrusive_ptr<ConfigObject>& object);
|
void UnregisterObject(const intrusive_ptr<ConfigObject>& object);
|
||||||
|
|
||||||
std::vector<intrusive_ptr<ConfigObject> > GetObjects(void) const;
|
std::vector<intrusive_ptr<ConfigObject> > GetObjects() const;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static TypeImpl<T> *Get(void)
|
static TypeImpl<T> *Get()
|
||||||
{
|
{
|
||||||
typedef TypeImpl<T> ObjType;
|
typedef TypeImpl<T> ObjType;
|
||||||
return static_cast<ObjType *>(T::TypeInstance.get());
|
return static_cast<ObjType *>(T::TypeInstance.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static std::vector<intrusive_ptr<T> > GetObjectsByType(void)
|
static std::vector<intrusive_ptr<T> > GetObjectsByType()
|
||||||
{
|
{
|
||||||
std::vector<intrusive_ptr<ConfigObject> > objects = GetObjectsHelper(T::TypeInstance.get());
|
std::vector<intrusive_ptr<ConfigObject> > objects = GetObjectsHelper(T::TypeInstance.get());
|
||||||
std::vector<intrusive_ptr<T> > result;
|
std::vector<intrusive_ptr<T> > result;
|
||||||
@ -60,7 +60,7 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetObjectCount(void) const;
|
int GetObjectCount() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<String, intrusive_ptr<ConfigObject> > ObjectMap;
|
typedef std::map<String, intrusive_ptr<ConfigObject> > ObjectMap;
|
||||||
|
@ -220,7 +220,7 @@ String ConfigWriter::EscapeIcingaString(const String& str)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<String>& ConfigWriter::GetKeywords(void)
|
const std::vector<String>& ConfigWriter::GetKeywords()
|
||||||
{
|
{
|
||||||
static std::vector<String> keywords;
|
static std::vector<String> keywords;
|
||||||
static boost::mutex mutex;
|
static boost::mutex mutex;
|
||||||
@ -273,7 +273,7 @@ ConfigIdentifier::ConfigIdentifier(const String& identifier)
|
|||||||
: m_Name(identifier)
|
: m_Name(identifier)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
String ConfigIdentifier::GetName(void) const
|
String ConfigIdentifier::GetName() const
|
||||||
{
|
{
|
||||||
return m_Name;
|
return m_Name;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
|
|
||||||
ConfigIdentifier(const String& name);
|
ConfigIdentifier(const String& name);
|
||||||
|
|
||||||
String GetName(void) const;
|
String GetName() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_Name;
|
String m_Name;
|
||||||
@ -73,10 +73,10 @@ public:
|
|||||||
static void EmitComment(std::ostream& fp, const String& text);
|
static void EmitComment(std::ostream& fp, const String& text);
|
||||||
static void EmitFunctionCall(std::ostream& fp, const String& name, const Array::Ptr& arguments);
|
static void EmitFunctionCall(std::ostream& fp, const String& name, const Array::Ptr& arguments);
|
||||||
|
|
||||||
static const std::vector<String>& GetKeywords(void);
|
static const std::vector<String>& GetKeywords();
|
||||||
private:
|
private:
|
||||||
static String EscapeIcingaString(const String& str);
|
static String EscapeIcingaString(const String& str);
|
||||||
ConfigWriter(void);
|
ConfigWriter();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ using namespace icinga;
|
|||||||
|
|
||||||
static ConsoleType l_ConsoleType = Console_Dumb;
|
static ConsoleType l_ConsoleType = Console_Dumb;
|
||||||
|
|
||||||
static void InitializeConsole(void)
|
static void InitializeConsole()
|
||||||
{
|
{
|
||||||
l_ConsoleType = Console_Dumb;
|
l_ConsoleType = Console_Dumb;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ std::ostream& operator<<(std::ostream& fp, const ConsoleColorTag& cct);
|
|||||||
class Console
|
class Console
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void DetectType(void);
|
static void DetectType();
|
||||||
|
|
||||||
static void SetType(std::ostream& fp, ConsoleType type);
|
static void SetType(std::ostream& fp, ConsoleType type);
|
||||||
static ConsoleType GetType(std::ostream& fp);
|
static ConsoleType GetType(std::ostream& fp);
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Console(void);
|
Console();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ ContextFrame::ContextFrame(const String& message)
|
|||||||
GetFrames().push_front(message);
|
GetFrames().push_front(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextFrame::~ContextFrame(void)
|
ContextFrame::~ContextFrame()
|
||||||
{
|
{
|
||||||
GetFrames().pop_front();
|
GetFrames().pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<String>& ContextFrame::GetFrames(void)
|
std::list<String>& ContextFrame::GetFrames()
|
||||||
{
|
{
|
||||||
if (!l_Frames.get())
|
if (!l_Frames.get())
|
||||||
l_Frames.reset(new std::list<String>());
|
l_Frames.reset(new std::list<String>());
|
||||||
@ -42,7 +42,7 @@ std::list<String>& ContextFrame::GetFrames(void)
|
|||||||
return *l_Frames;
|
return *l_Frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextTrace::ContextTrace(void)
|
ContextTrace::ContextTrace()
|
||||||
: m_Frames(ContextFrame::GetFrames())
|
: m_Frames(ContextFrame::GetFrames())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ void ContextTrace::Print(std::ostream& fp) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ContextTrace::GetLength(void) const
|
size_t ContextTrace::GetLength() const
|
||||||
{
|
{
|
||||||
return m_Frames.size();
|
return m_Frames.size();
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,11 @@ namespace icinga
|
|||||||
class ContextTrace
|
class ContextTrace
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ContextTrace(void);
|
ContextTrace();
|
||||||
|
|
||||||
void Print(std::ostream& fp) const;
|
void Print(std::ostream& fp) const;
|
||||||
|
|
||||||
size_t GetLength(void) const;
|
size_t GetLength() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<String> m_Frames;
|
std::list<String> m_Frames;
|
||||||
@ -51,10 +51,10 @@ class ContextFrame
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ContextFrame(const String& message);
|
ContextFrame(const String& message);
|
||||||
~ContextFrame(void);
|
~ContextFrame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::list<String>& GetFrames(void);
|
static std::list<String>& GetFrames();
|
||||||
|
|
||||||
friend class ContextTrace;
|
friend class ContextTrace;
|
||||||
};
|
};
|
||||||
|
@ -88,7 +88,7 @@ public:
|
|||||||
static double ToDateTimeValue(const Value& val);
|
static double ToDateTimeValue(const Value& val);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Convert(void);
|
Convert();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ static String DateTimeFormat(const String& format)
|
|||||||
return self->Format(format);
|
return self->Format(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Ptr DateTime::GetPrototype(void)
|
Object::Ptr DateTime::GetPrototype()
|
||||||
{
|
{
|
||||||
static Dictionary::Ptr prototype;
|
static Dictionary::Ptr prototype;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ DateTime::DateTime(const std::vector<Value>& args)
|
|||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid number of arguments for the DateTime constructor."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid number of arguments for the DateTime constructor."));
|
||||||
}
|
}
|
||||||
|
|
||||||
double DateTime::GetValue(void) const
|
double DateTime::GetValue() const
|
||||||
{
|
{
|
||||||
return m_Value;
|
return m_Value;
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ String DateTime::Format(const String& format) const
|
|||||||
return Utility::FormatDateTime(format.CStr(), m_Value);
|
return Utility::FormatDateTime(format.CStr(), m_Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
String DateTime::ToString(void) const
|
String DateTime::ToString() const
|
||||||
{
|
{
|
||||||
return Format("%Y-%m-%d %H:%M:%S %z");
|
return Format("%Y-%m-%d %H:%M:%S %z");
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,10 @@ public:
|
|||||||
|
|
||||||
String Format(const String& format) const;
|
String Format(const String& format) const;
|
||||||
|
|
||||||
virtual double GetValue(void) const override;
|
virtual double GetValue() const override;
|
||||||
virtual String ToString(void) const override;
|
virtual String ToString() const override;
|
||||||
|
|
||||||
static Object::Ptr GetPrototype(void);
|
static Object::Ptr GetPrototype();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_Value;
|
double m_Value;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
DebugInfo::DebugInfo(void)
|
DebugInfo::DebugInfo()
|
||||||
: FirstLine(0), FirstColumn(0), LastLine(0), LastColumn(0)
|
: FirstLine(0), FirstColumn(0), LastLine(0), LastColumn(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ struct DebugInfo
|
|||||||
int LastLine;
|
int LastLine;
|
||||||
int LastColumn;
|
int LastColumn;
|
||||||
|
|
||||||
DebugInfo(void);
|
DebugInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, const DebugInfo& val);
|
std::ostream& operator<<(std::ostream& out, const DebugInfo& val);
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
static std::vector<Object::Ptr> GetParents(const Object::Ptr& child);
|
static std::vector<Object::Ptr> GetParents(const Object::Ptr& child);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DependencyGraph(void);
|
DependencyGraph();
|
||||||
|
|
||||||
static boost::mutex m_Mutex;
|
static boost::mutex m_Mutex;
|
||||||
static std::map<Object *, std::map<Object *, int> > m_Dependencies;
|
static std::map<Object *, std::map<Object *, int> > m_Dependencies;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
static double DictionaryLen(void)
|
static double DictionaryLen()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
|
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
|
||||||
@ -60,14 +60,14 @@ static bool DictionaryContains(const String& key)
|
|||||||
return self->Contains(key);
|
return self->Contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Dictionary::Ptr DictionaryShallowClone(void)
|
static Dictionary::Ptr DictionaryShallowClone()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
|
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
|
||||||
return self->ShallowClone();
|
return self->ShallowClone();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Array::Ptr DictionaryKeys(void)
|
static Array::Ptr DictionaryKeys()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
|
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
|
||||||
@ -79,7 +79,7 @@ static Array::Ptr DictionaryKeys(void)
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Array::Ptr DictionaryValues(void)
|
static Array::Ptr DictionaryValues()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
|
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
|
||||||
@ -91,7 +91,7 @@ static Array::Ptr DictionaryValues(void)
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Ptr Dictionary::GetPrototype(void)
|
Object::Ptr Dictionary::GetPrototype()
|
||||||
{
|
{
|
||||||
static Dictionary::Ptr prototype;
|
static Dictionary::Ptr prototype;
|
||||||
|
|
||||||
|
@ -29,10 +29,10 @@ template class std::map<String, Value>;
|
|||||||
|
|
||||||
REGISTER_PRIMITIVE_TYPE(Dictionary, Object, Dictionary::GetPrototype());
|
REGISTER_PRIMITIVE_TYPE(Dictionary, Object, Dictionary::GetPrototype());
|
||||||
|
|
||||||
Dictionary::Dictionary(void)
|
Dictionary::Dictionary()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Dictionary::~Dictionary(void)
|
Dictionary::~Dictionary()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,7 +104,7 @@ void Dictionary::Set(const String& key, Value&& value)
|
|||||||
*
|
*
|
||||||
* @returns Number of elements.
|
* @returns Number of elements.
|
||||||
*/
|
*/
|
||||||
size_t Dictionary::GetLength(void) const
|
size_t Dictionary::GetLength() const
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ bool Dictionary::Contains(const String& key) const
|
|||||||
*
|
*
|
||||||
* @returns An iterator.
|
* @returns An iterator.
|
||||||
*/
|
*/
|
||||||
Dictionary::Iterator Dictionary::Begin(void)
|
Dictionary::Iterator Dictionary::Begin()
|
||||||
{
|
{
|
||||||
ASSERT(OwnsLock());
|
ASSERT(OwnsLock());
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ Dictionary::Iterator Dictionary::Begin(void)
|
|||||||
*
|
*
|
||||||
* @returns An iterator.
|
* @returns An iterator.
|
||||||
*/
|
*/
|
||||||
Dictionary::Iterator Dictionary::End(void)
|
Dictionary::Iterator Dictionary::End()
|
||||||
{
|
{
|
||||||
ASSERT(OwnsLock());
|
ASSERT(OwnsLock());
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ void Dictionary::Remove(const String& key)
|
|||||||
/**
|
/**
|
||||||
* Removes all dictionary items.
|
* Removes all dictionary items.
|
||||||
*/
|
*/
|
||||||
void Dictionary::Clear(void)
|
void Dictionary::Clear()
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ void Dictionary::CopyTo(const Dictionary::Ptr& dest) const
|
|||||||
*
|
*
|
||||||
* @returns a copy of the dictionary.
|
* @returns a copy of the dictionary.
|
||||||
*/
|
*/
|
||||||
Dictionary::Ptr Dictionary::ShallowClone(void) const
|
Dictionary::Ptr Dictionary::ShallowClone() const
|
||||||
{
|
{
|
||||||
Dictionary::Ptr clone = new Dictionary();
|
Dictionary::Ptr clone = new Dictionary();
|
||||||
CopyTo(clone);
|
CopyTo(clone);
|
||||||
@ -219,7 +219,7 @@ Dictionary::Ptr Dictionary::ShallowClone(void) const
|
|||||||
*
|
*
|
||||||
* @returns a copy of the dictionary.
|
* @returns a copy of the dictionary.
|
||||||
*/
|
*/
|
||||||
Object::Ptr Dictionary::Clone(void) const
|
Object::Ptr Dictionary::Clone() const
|
||||||
{
|
{
|
||||||
Dictionary::Ptr dict = new Dictionary();
|
Dictionary::Ptr dict = new Dictionary();
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ Object::Ptr Dictionary::Clone(void) const
|
|||||||
*
|
*
|
||||||
* @returns an array of key names
|
* @returns an array of key names
|
||||||
*/
|
*/
|
||||||
std::vector<String> Dictionary::GetKeys(void) const
|
std::vector<String> Dictionary::GetKeys() const
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ std::vector<String> Dictionary::GetKeys(void) const
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Dictionary::ToString(void) const
|
String Dictionary::ToString() const
|
||||||
{
|
{
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
ConfigWriter::EmitScope(msgbuf, 1, const_cast<Dictionary *>(this));
|
ConfigWriter::EmitScope(msgbuf, 1, const_cast<Dictionary *>(this));
|
||||||
|
@ -49,9 +49,9 @@ public:
|
|||||||
|
|
||||||
typedef std::map<String, Value>::value_type Pair;
|
typedef std::map<String, Value>::value_type Pair;
|
||||||
|
|
||||||
Dictionary(void);
|
Dictionary();
|
||||||
|
|
||||||
~Dictionary(void);
|
~Dictionary();
|
||||||
|
|
||||||
Value Get(const String& key) const;
|
Value Get(const String& key) const;
|
||||||
bool Get(const String& key, Value *result) const;
|
bool Get(const String& key, Value *result) const;
|
||||||
@ -59,27 +59,27 @@ public:
|
|||||||
void Set(const String& key, Value&& value);
|
void Set(const String& key, Value&& value);
|
||||||
bool Contains(const String& key) const;
|
bool Contains(const String& key) const;
|
||||||
|
|
||||||
Iterator Begin(void);
|
Iterator Begin();
|
||||||
Iterator End(void);
|
Iterator End();
|
||||||
|
|
||||||
size_t GetLength(void) const;
|
size_t GetLength() const;
|
||||||
|
|
||||||
void Remove(const String& key);
|
void Remove(const String& key);
|
||||||
|
|
||||||
void Remove(Iterator it);
|
void Remove(Iterator it);
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
|
|
||||||
void CopyTo(const Dictionary::Ptr& dest) const;
|
void CopyTo(const Dictionary::Ptr& dest) const;
|
||||||
Dictionary::Ptr ShallowClone(void) const;
|
Dictionary::Ptr ShallowClone() const;
|
||||||
|
|
||||||
std::vector<String> GetKeys(void) const;
|
std::vector<String> GetKeys() const;
|
||||||
|
|
||||||
static Object::Ptr GetPrototype(void);
|
static Object::Ptr GetPrototype();
|
||||||
|
|
||||||
virtual Object::Ptr Clone(void) const override;
|
virtual Object::Ptr Clone() const override;
|
||||||
|
|
||||||
virtual String ToString(void) const override;
|
virtual String ToString() const override;
|
||||||
|
|
||||||
virtual Value GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const override;
|
virtual Value GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const override;
|
||||||
virtual void SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo) override;
|
virtual void SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo) override;
|
||||||
|
@ -91,7 +91,7 @@ static boost::thread_specific_ptr<DestCallback> l_LastExceptionDest;
|
|||||||
extern "C" void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *));
|
extern "C" void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *));
|
||||||
#endif /* HAVE_CXXABI_H */
|
#endif /* HAVE_CXXABI_H */
|
||||||
|
|
||||||
void icinga::RethrowUncaughtException(void)
|
void icinga::RethrowUncaughtException()
|
||||||
{
|
{
|
||||||
#if defined(__GLIBCXX__) || !defined(HAVE_CXXABI_H)
|
#if defined(__GLIBCXX__) || !defined(HAVE_CXXABI_H)
|
||||||
throw;
|
throw;
|
||||||
@ -145,7 +145,7 @@ void __cxa_throw(void *obj, TYPEINFO_TYPE *pvtinfo, void (*dest)(void *))
|
|||||||
}
|
}
|
||||||
#endif /* HAVE_CXXABI_H */
|
#endif /* HAVE_CXXABI_H */
|
||||||
|
|
||||||
StackTrace *icinga::GetLastExceptionStack(void)
|
StackTrace *icinga::GetLastExceptionStack()
|
||||||
{
|
{
|
||||||
return l_LastExceptionStack.get();
|
return l_LastExceptionStack.get();
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ void icinga::SetLastExceptionStack(const StackTrace& trace)
|
|||||||
l_LastExceptionStack.reset(new StackTrace(trace));
|
l_LastExceptionStack.reset(new StackTrace(trace));
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextTrace *icinga::GetLastExceptionContext(void)
|
ContextTrace *icinga::GetLastExceptionContext()
|
||||||
{
|
{
|
||||||
return l_LastExceptionContext.get();
|
return l_LastExceptionContext.get();
|
||||||
}
|
}
|
||||||
@ -291,25 +291,25 @@ ScriptError::ScriptError(const String& message, const DebugInfo& di, bool incomp
|
|||||||
: m_Message(message), m_DebugInfo(di), m_IncompleteExpr(incompleteExpr), m_HandledByDebugger(false)
|
: m_Message(message), m_DebugInfo(di), m_IncompleteExpr(incompleteExpr), m_HandledByDebugger(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
ScriptError::~ScriptError(void) throw()
|
ScriptError::~ScriptError() throw()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
const char *ScriptError::what(void) const throw()
|
const char *ScriptError::what() const throw()
|
||||||
{
|
{
|
||||||
return m_Message.CStr();
|
return m_Message.CStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugInfo ScriptError::GetDebugInfo(void) const
|
DebugInfo ScriptError::GetDebugInfo() const
|
||||||
{
|
{
|
||||||
return m_DebugInfo;
|
return m_DebugInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptError::IsIncompleteExpression(void) const
|
bool ScriptError::IsIncompleteExpression() const
|
||||||
{
|
{
|
||||||
return m_IncompleteExpr;;
|
return m_IncompleteExpr;;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptError::IsHandledByDebugger(void) const
|
bool ScriptError::IsHandledByDebugger() const
|
||||||
{
|
{
|
||||||
return m_HandledByDebugger;
|
return m_HandledByDebugger;
|
||||||
}
|
}
|
||||||
@ -319,16 +319,16 @@ void ScriptError::SetHandledByDebugger(bool handled)
|
|||||||
m_HandledByDebugger = handled;
|
m_HandledByDebugger = handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
posix_error::posix_error(void)
|
posix_error::posix_error()
|
||||||
: m_Message(nullptr)
|
: m_Message(nullptr)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
posix_error::~posix_error(void) throw()
|
posix_error::~posix_error() throw()
|
||||||
{
|
{
|
||||||
free(m_Message);
|
free(m_Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *posix_error::what(void) const throw()
|
const char *posix_error::what() const throw()
|
||||||
{
|
{
|
||||||
if (!m_Message) {
|
if (!m_Message) {
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
@ -380,25 +380,25 @@ ValidationError::ValidationError(const ConfigObject::Ptr& object, const std::vec
|
|||||||
m_What += ": " + message;
|
m_What += ": " + message;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidationError::~ValidationError(void) throw()
|
ValidationError::~ValidationError() throw()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
const char *ValidationError::what(void) const throw()
|
const char *ValidationError::what() const throw()
|
||||||
{
|
{
|
||||||
return m_What.CStr();
|
return m_What.CStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigObject::Ptr ValidationError::GetObject(void) const
|
ConfigObject::Ptr ValidationError::GetObject() const
|
||||||
{
|
{
|
||||||
return m_Object;
|
return m_Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<String> ValidationError::GetAttributePath(void) const
|
std::vector<String> ValidationError::GetAttributePath() const
|
||||||
{
|
{
|
||||||
return m_AttributePath;
|
return m_AttributePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ValidationError::GetMessage(void) const
|
String ValidationError::GetMessage() const
|
||||||
{
|
{
|
||||||
return m_Message;
|
return m_Message;
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ void ValidationError::SetDebugHint(const Dictionary::Ptr& dhint)
|
|||||||
m_DebugHint = dhint;
|
m_DebugHint = dhint;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr ValidationError::GetDebugHint(void) const
|
Dictionary::Ptr ValidationError::GetDebugHint() const
|
||||||
{
|
{
|
||||||
return m_DebugHint;
|
return m_DebugHint;
|
||||||
}
|
}
|
||||||
|
@ -53,14 +53,14 @@ class ScriptError : virtual public user_error
|
|||||||
public:
|
public:
|
||||||
ScriptError(const String& message);
|
ScriptError(const String& message);
|
||||||
ScriptError(const String& message, const DebugInfo& di, bool incompleteExpr = false);
|
ScriptError(const String& message, const DebugInfo& di, bool incompleteExpr = false);
|
||||||
~ScriptError(void) throw();
|
~ScriptError() throw();
|
||||||
|
|
||||||
virtual const char *what(void) const throw() override final;
|
virtual const char *what(void) const throw() override final;
|
||||||
|
|
||||||
DebugInfo GetDebugInfo(void) const;
|
DebugInfo GetDebugInfo() const;
|
||||||
bool IsIncompleteExpression(void) const;
|
bool IsIncompleteExpression() const;
|
||||||
|
|
||||||
bool IsHandledByDebugger(void) const;
|
bool IsHandledByDebugger() const;
|
||||||
void SetHandledByDebugger(bool handled);
|
void SetHandledByDebugger(bool handled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -77,16 +77,16 @@ class ValidationError : virtual public user_error
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ValidationError(const ConfigObject::Ptr& object, const std::vector<String>& attributePath, const String& message);
|
ValidationError(const ConfigObject::Ptr& object, const std::vector<String>& attributePath, const String& message);
|
||||||
~ValidationError(void) throw();
|
~ValidationError() throw();
|
||||||
|
|
||||||
virtual const char *what(void) const throw() override final;
|
virtual const char *what(void) const throw() override final;
|
||||||
|
|
||||||
ConfigObject::Ptr GetObject(void) const;
|
ConfigObject::Ptr GetObject() const;
|
||||||
std::vector<String> GetAttributePath(void) const;
|
std::vector<String> GetAttributePath() const;
|
||||||
String GetMessage(void) const;
|
String GetMessage() const;
|
||||||
|
|
||||||
void SetDebugHint(const Dictionary::Ptr& dhint);
|
void SetDebugHint(const Dictionary::Ptr& dhint);
|
||||||
Dictionary::Ptr GetDebugHint(void) const;
|
Dictionary::Ptr GetDebugHint() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConfigObject::Ptr m_Object;
|
ConfigObject::Ptr m_Object;
|
||||||
@ -96,13 +96,13 @@ private:
|
|||||||
Dictionary::Ptr m_DebugHint;
|
Dictionary::Ptr m_DebugHint;
|
||||||
};
|
};
|
||||||
|
|
||||||
StackTrace *GetLastExceptionStack(void);
|
StackTrace *GetLastExceptionStack();
|
||||||
void SetLastExceptionStack(const StackTrace& trace);
|
void SetLastExceptionStack(const StackTrace& trace);
|
||||||
|
|
||||||
ContextTrace *GetLastExceptionContext(void);
|
ContextTrace *GetLastExceptionContext();
|
||||||
void SetLastExceptionContext(const ContextTrace& context);
|
void SetLastExceptionContext(const ContextTrace& context);
|
||||||
|
|
||||||
void RethrowUncaughtException(void);
|
void RethrowUncaughtException();
|
||||||
|
|
||||||
typedef boost::error_info<StackTrace, StackTrace> StackTraceErrorInfo;
|
typedef boost::error_info<StackTrace, StackTrace> StackTraceErrorInfo;
|
||||||
|
|
||||||
@ -125,8 +125,8 @@ String DiagnosticInformation(boost::exception_ptr eptr, bool verbose = true);
|
|||||||
|
|
||||||
class posix_error : virtual public std::exception, virtual public boost::exception {
|
class posix_error : virtual public std::exception, virtual public boost::exception {
|
||||||
public:
|
public:
|
||||||
posix_error(void);
|
posix_error();
|
||||||
virtual ~posix_error(void) throw();
|
virtual ~posix_error() throw();
|
||||||
|
|
||||||
virtual const char *what(void) const throw() override final;
|
virtual const char *what(void) const throw() override final;
|
||||||
|
|
||||||
|
@ -24,14 +24,14 @@ using namespace icinga;
|
|||||||
/**
|
/**
|
||||||
* Constructor for the FIFO class.
|
* Constructor for the FIFO class.
|
||||||
*/
|
*/
|
||||||
FIFO::FIFO(void)
|
FIFO::FIFO()
|
||||||
: m_Buffer(nullptr), m_DataSize(0), m_AllocSize(0), m_Offset(0)
|
: m_Buffer(nullptr), m_DataSize(0), m_AllocSize(0), m_Offset(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor for the FIFO class.
|
* Destructor for the FIFO class.
|
||||||
*/
|
*/
|
||||||
FIFO::~FIFO(void)
|
FIFO::~FIFO()
|
||||||
{
|
{
|
||||||
free(m_Buffer);
|
free(m_Buffer);
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ void FIFO::ResizeBuffer(size_t newSize, bool decrease)
|
|||||||
* Optimizes memory usage of the FIFO buffer by reallocating
|
* Optimizes memory usage of the FIFO buffer by reallocating
|
||||||
* and moving the buffer.
|
* and moving the buffer.
|
||||||
*/
|
*/
|
||||||
void FIFO::Optimize(void)
|
void FIFO::Optimize()
|
||||||
{
|
{
|
||||||
if (m_Offset > m_DataSize / 10 && m_Offset - m_DataSize > 1024) {
|
if (m_Offset > m_DataSize / 10 && m_Offset - m_DataSize > 1024) {
|
||||||
std::memmove(m_Buffer, m_Buffer + m_Offset, m_DataSize);
|
std::memmove(m_Buffer, m_Buffer + m_Offset, m_DataSize);
|
||||||
@ -124,25 +124,25 @@ void FIFO::Write(const void *buffer, size_t count)
|
|||||||
SignalDataAvailable();
|
SignalDataAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIFO::Close(void)
|
void FIFO::Close()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool FIFO::IsEof(void) const
|
bool FIFO::IsEof() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t FIFO::GetAvailableBytes(void) const
|
size_t FIFO::GetAvailableBytes() const
|
||||||
{
|
{
|
||||||
return m_DataSize;
|
return m_DataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FIFO::SupportsWaiting(void) const
|
bool FIFO::SupportsWaiting() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FIFO::IsDataAvailable(void) const
|
bool FIFO::IsDataAvailable() const
|
||||||
{
|
{
|
||||||
return m_DataSize > 0;
|
return m_DataSize > 0;
|
||||||
}
|
}
|
||||||
|
@ -38,18 +38,18 @@ public:
|
|||||||
|
|
||||||
static const size_t BlockSize = 512;
|
static const size_t BlockSize = 512;
|
||||||
|
|
||||||
FIFO(void);
|
FIFO();
|
||||||
~FIFO(void);
|
~FIFO();
|
||||||
|
|
||||||
virtual size_t Peek(void *buffer, size_t count, bool allow_partial = false) override;
|
virtual size_t Peek(void *buffer, size_t count, bool allow_partial = false) override;
|
||||||
virtual size_t Read(void *buffer, size_t count, bool allow_partial = false) override;
|
virtual size_t Read(void *buffer, size_t count, bool allow_partial = false) override;
|
||||||
virtual void Write(const void *buffer, size_t count) override;
|
virtual void Write(const void *buffer, size_t count) override;
|
||||||
virtual void Close(void) override;
|
virtual void Close() override;
|
||||||
virtual bool IsEof(void) const override;
|
virtual bool IsEof() const override;
|
||||||
virtual bool SupportsWaiting(void) const override;
|
virtual bool SupportsWaiting() const override;
|
||||||
virtual bool IsDataAvailable(void) const override;
|
virtual bool IsDataAvailable() const override;
|
||||||
|
|
||||||
size_t GetAvailableBytes(void) const;
|
size_t GetAvailableBytes() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char *m_Buffer;
|
char *m_Buffer;
|
||||||
@ -58,7 +58,7 @@ private:
|
|||||||
size_t m_Offset;
|
size_t m_Offset;
|
||||||
|
|
||||||
void ResizeBuffer(size_t newSize, bool decrease);
|
void ResizeBuffer(size_t newSize, bool decrease);
|
||||||
void Optimize(void);
|
void Optimize();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ void FileLogger::Start(bool runtimeCreated)
|
|||||||
ObjectImpl<FileLogger>::Start(runtimeCreated);
|
ObjectImpl<FileLogger>::Start(runtimeCreated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileLogger::ReopenLogFile(void)
|
void FileLogger::ReopenLogFile()
|
||||||
{
|
{
|
||||||
std::ofstream *stream = new std::ofstream();
|
std::ofstream *stream = new std::ofstream();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
virtual void Start(bool runtimeCreated) override;
|
virtual void Start(bool runtimeCreated) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ReopenLogFile(void);
|
void ReopenLogFile();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ static Value FunctionCallV(const Value& thisArg, const Array::Ptr& args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Object::Ptr Function::GetPrototype(void)
|
Object::Ptr Function::GetPrototype()
|
||||||
{
|
{
|
||||||
static Dictionary::Ptr prototype;
|
static Dictionary::Ptr prototype;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ Value Function::InvokeThis(const Value& otherThis, const std::vector<Value>& arg
|
|||||||
return m_Callback(arguments);
|
return m_Callback(arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Ptr Function::Clone(void) const
|
Object::Ptr Function::Clone() const
|
||||||
{
|
{
|
||||||
return const_cast<Function *>(this);
|
return const_cast<Function *>(this);
|
||||||
}
|
}
|
||||||
|
@ -51,19 +51,19 @@ public:
|
|||||||
Value Invoke(const std::vector<Value>& arguments = std::vector<Value>());
|
Value Invoke(const std::vector<Value>& arguments = std::vector<Value>());
|
||||||
Value InvokeThis(const Value& otherThis, const std::vector<Value>& arguments = std::vector<Value>());
|
Value InvokeThis(const Value& otherThis, const std::vector<Value>& arguments = std::vector<Value>());
|
||||||
|
|
||||||
bool IsSideEffectFree(void) const
|
bool IsSideEffectFree() const
|
||||||
{
|
{
|
||||||
return GetSideEffectFree();
|
return GetSideEffectFree();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsDeprecated(void) const
|
bool IsDeprecated() const
|
||||||
{
|
{
|
||||||
return GetDeprecated();
|
return GetDeprecated();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Object::Ptr GetPrototype(void);
|
static Object::Ptr GetPrototype();
|
||||||
|
|
||||||
virtual Object::Ptr Clone(void) const override;
|
virtual Object::Ptr Clone() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Callback m_Callback;
|
Callback m_Callback;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
bool icinga::InitializeOnceHelper(void (*func)(void), int priority)
|
bool icinga::InitializeOnceHelper(void (*func)(), int priority)
|
||||||
{
|
{
|
||||||
Loader::AddDeferredInitializer(func, priority);
|
Loader::AddDeferredInitializer(func, priority);
|
||||||
return true;
|
return true;
|
||||||
|
@ -30,7 +30,7 @@ namespace icinga
|
|||||||
|
|
||||||
#define I2_UNIQUE_NAME(prefix) I2_TOKENPASTE2(prefix, __COUNTER__)
|
#define I2_UNIQUE_NAME(prefix) I2_TOKENPASTE2(prefix, __COUNTER__)
|
||||||
|
|
||||||
bool InitializeOnceHelper(void (*func)(void), int priority = 0);
|
bool InitializeOnceHelper(void (*func)(), int priority = 0);
|
||||||
|
|
||||||
#define INITIALIZE_ONCE(func) \
|
#define INITIALIZE_ONCE(func) \
|
||||||
namespace { namespace I2_UNIQUE_NAME(io) { \
|
namespace { namespace I2_UNIQUE_NAME(io) { \
|
||||||
|
@ -129,7 +129,7 @@ struct JsonElement
|
|||||||
bool KeySet;
|
bool KeySet;
|
||||||
Value EValue;
|
Value EValue;
|
||||||
|
|
||||||
JsonElement(void)
|
JsonElement()
|
||||||
: KeySet(false)
|
: KeySet(false)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
@ -145,7 +145,7 @@ public:
|
|||||||
m_Stack.push(element);
|
m_Stack.push(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonElement Pop(void)
|
JsonElement Pop()
|
||||||
{
|
{
|
||||||
JsonElement value = m_Stack.top();
|
JsonElement value = m_Stack.top();
|
||||||
m_Stack.pop();
|
m_Stack.pop();
|
||||||
@ -180,18 +180,18 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Value GetValue(void) const
|
Value GetValue() const
|
||||||
{
|
{
|
||||||
ASSERT(m_Stack.size() == 1);
|
ASSERT(m_Stack.size() == 1);
|
||||||
return m_Stack.top().EValue;
|
return m_Stack.top().EValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveException(void)
|
void SaveException()
|
||||||
{
|
{
|
||||||
m_Exception = boost::current_exception();
|
m_Exception = boost::current_exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThrowException(void) const
|
void ThrowException() const
|
||||||
{
|
{
|
||||||
if (m_Exception)
|
if (m_Exception)
|
||||||
boost::rethrow_exception(m_Exception);
|
boost::rethrow_exception(m_Exception);
|
||||||
|
@ -36,7 +36,7 @@ typedef HMODULE LibraryHandle;
|
|||||||
class Library
|
class Library
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Library(void) = default;
|
Library() = default;
|
||||||
Library(const String& name);
|
Library(const String& name);
|
||||||
|
|
||||||
void *GetSymbolAddress(const String& name) const;
|
void *GetSymbolAddress(const String& name) const;
|
||||||
|
@ -24,13 +24,13 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
boost::thread_specific_ptr<std::priority_queue<DeferredInitializer> >& Loader::GetDeferredInitializers(void)
|
boost::thread_specific_ptr<std::priority_queue<DeferredInitializer> >& Loader::GetDeferredInitializers()
|
||||||
{
|
{
|
||||||
static boost::thread_specific_ptr<std::priority_queue<DeferredInitializer> > initializers;
|
static boost::thread_specific_ptr<std::priority_queue<DeferredInitializer> > initializers;
|
||||||
return initializers;
|
return initializers;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loader::ExecuteDeferredInitializers(void)
|
void Loader::ExecuteDeferredInitializers()
|
||||||
{
|
{
|
||||||
if (!GetDeferredInitializers().get())
|
if (!GetDeferredInitializers().get())
|
||||||
return;
|
return;
|
||||||
@ -42,7 +42,7 @@ void Loader::ExecuteDeferredInitializers(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loader::AddDeferredInitializer(const std::function<void(void)>& callback, int priority)
|
void Loader::AddDeferredInitializer(const std::function<void()>& callback, int priority)
|
||||||
{
|
{
|
||||||
if (!GetDeferredInitializers().get())
|
if (!GetDeferredInitializers().get())
|
||||||
GetDeferredInitializers().reset(new std::priority_queue<DeferredInitializer>());
|
GetDeferredInitializers().reset(new std::priority_queue<DeferredInitializer>());
|
||||||
|
@ -31,7 +31,7 @@ namespace icinga
|
|||||||
struct DeferredInitializer
|
struct DeferredInitializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeferredInitializer(const std::function<void (void)>& callback, int priority)
|
DeferredInitializer(const std::function<void ()>& callback, int priority)
|
||||||
: m_Callback(callback), m_Priority(priority)
|
: m_Callback(callback), m_Priority(priority)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -40,13 +40,13 @@ public:
|
|||||||
return m_Priority < other.m_Priority;
|
return m_Priority < other.m_Priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(void)
|
void operator()()
|
||||||
{
|
{
|
||||||
m_Callback();
|
m_Callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::function<void (void)> m_Callback;
|
std::function<void ()> m_Callback;
|
||||||
int m_Priority;
|
int m_Priority;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,13 +58,13 @@ private:
|
|||||||
class Loader
|
class Loader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void AddDeferredInitializer(const std::function<void(void)>& callback, int priority = 0);
|
static void AddDeferredInitializer(const std::function<void ()>& callback, int priority = 0);
|
||||||
static void ExecuteDeferredInitializers(void);
|
static void ExecuteDeferredInitializers();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Loader(void);
|
Loader();
|
||||||
|
|
||||||
static boost::thread_specific_ptr<std::priority_queue<DeferredInitializer> >& GetDeferredInitializers(void);
|
static boost::thread_specific_ptr<std::priority_queue<DeferredInitializer> >& GetDeferredInitializers();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ void Logger::Stop(bool runtimeRemoved)
|
|||||||
ObjectImpl<Logger>::Stop(runtimeRemoved);
|
ObjectImpl<Logger>::Stop(runtimeRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<Logger::Ptr> Logger::GetLoggers(void)
|
std::set<Logger::Ptr> Logger::GetLoggers()
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_Mutex);
|
boost::mutex::scoped_lock lock(m_Mutex);
|
||||||
return m_Loggers;
|
return m_Loggers;
|
||||||
@ -88,7 +88,7 @@ std::set<Logger::Ptr> Logger::GetLoggers(void)
|
|||||||
*
|
*
|
||||||
* @returns The minimum severity.
|
* @returns The minimum severity.
|
||||||
*/
|
*/
|
||||||
LogSeverity Logger::GetMinSeverity(void) const
|
LogSeverity Logger::GetMinSeverity() const
|
||||||
{
|
{
|
||||||
String severity = GetSeverity();
|
String severity = GetSeverity();
|
||||||
if (severity.IsEmpty())
|
if (severity.IsEmpty())
|
||||||
@ -148,17 +148,17 @@ LogSeverity Logger::StringToSeverity(const String& severity)
|
|||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid severity: " + severity));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid severity: " + severity));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::DisableConsoleLog(void)
|
void Logger::DisableConsoleLog()
|
||||||
{
|
{
|
||||||
m_ConsoleLogEnabled = false;
|
m_ConsoleLogEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::EnableConsoleLog(void)
|
void Logger::EnableConsoleLog()
|
||||||
{
|
{
|
||||||
m_ConsoleLogEnabled = true;
|
m_ConsoleLogEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Logger::IsConsoleLogEnabled(void)
|
bool Logger::IsConsoleLogEnabled()
|
||||||
{
|
{
|
||||||
return m_ConsoleLogEnabled;
|
return m_ConsoleLogEnabled;
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ void Logger::SetConsoleLogSeverity(LogSeverity logSeverity)
|
|||||||
m_ConsoleLogSeverity = logSeverity;
|
m_ConsoleLogSeverity = logSeverity;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogSeverity Logger::GetConsoleLogSeverity(void)
|
LogSeverity Logger::GetConsoleLogSeverity()
|
||||||
{
|
{
|
||||||
return m_ConsoleLogSeverity;
|
return m_ConsoleLogSeverity;
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ void Logger::DisableTimestamp(bool disable)
|
|||||||
m_TimestampEnabled = !disable;
|
m_TimestampEnabled = !disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Logger::IsTimestampEnabled(void)
|
bool Logger::IsTimestampEnabled()
|
||||||
{
|
{
|
||||||
return m_TimestampEnabled;
|
return m_TimestampEnabled;
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ Log::Log(LogSeverity severity, const String& facility)
|
|||||||
/**
|
/**
|
||||||
* Writes the message to the application's log.
|
* Writes the message to the application's log.
|
||||||
*/
|
*/
|
||||||
Log::~Log(void)
|
Log::~Log()
|
||||||
{
|
{
|
||||||
LogEntry entry;
|
LogEntry entry;
|
||||||
entry.Timestamp = Utility::GetTime();
|
entry.Timestamp = Utility::GetTime();
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
static String SeverityToString(LogSeverity severity);
|
static String SeverityToString(LogSeverity severity);
|
||||||
static LogSeverity StringToSeverity(const String& severity);
|
static LogSeverity StringToSeverity(const String& severity);
|
||||||
|
|
||||||
LogSeverity GetMinSeverity(void) const;
|
LogSeverity GetMinSeverity() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the log entry and writes it to the log that is
|
* Processes the log entry and writes it to the log that is
|
||||||
@ -77,18 +77,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void ProcessLogEntry(const LogEntry& entry) = 0;
|
virtual void ProcessLogEntry(const LogEntry& entry) = 0;
|
||||||
|
|
||||||
virtual void Flush(void) = 0;
|
virtual void Flush() = 0;
|
||||||
|
|
||||||
static std::set<Logger::Ptr> GetLoggers(void);
|
static std::set<Logger::Ptr> GetLoggers();
|
||||||
|
|
||||||
static void DisableConsoleLog(void);
|
static void DisableConsoleLog();
|
||||||
static void EnableConsoleLog(void);
|
static void EnableConsoleLog();
|
||||||
static bool IsConsoleLogEnabled(void);
|
static bool IsConsoleLogEnabled();
|
||||||
static void DisableTimestamp(bool);
|
static void DisableTimestamp(bool);
|
||||||
static bool IsTimestampEnabled(void);
|
static bool IsTimestampEnabled();
|
||||||
|
|
||||||
static void SetConsoleLogSeverity(LogSeverity logSeverity);
|
static void SetConsoleLogSeverity(LogSeverity logSeverity);
|
||||||
static LogSeverity GetConsoleLogSeverity(void);
|
static LogSeverity GetConsoleLogSeverity();
|
||||||
|
|
||||||
virtual void ValidateSeverity(const String& value, const ValidationUtils& utils) override final;
|
virtual void ValidateSeverity(const String& value, const ValidationUtils& utils) override final;
|
||||||
|
|
||||||
@ -107,14 +107,14 @@ private:
|
|||||||
class Log
|
class Log
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Log(void) = delete;
|
Log() = delete;
|
||||||
Log(const Log& other) = delete;
|
Log(const Log& other) = delete;
|
||||||
Log& operator=(const Log& rhs) = delete;
|
Log& operator=(const Log& rhs) = delete;
|
||||||
|
|
||||||
Log(LogSeverity severity, const String& facility, const String& message);
|
Log(LogSeverity severity, const String& facility, const String& message);
|
||||||
Log(LogSeverity severity, const String& facility);
|
Log(LogSeverity severity, const String& facility);
|
||||||
|
|
||||||
~Log(void);
|
~Log();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Log& operator<<(const T& val)
|
Log& operator<<(const T& val)
|
||||||
|
@ -112,7 +112,7 @@ static double MathPow(double x, double y)
|
|||||||
return std::pow(x, y);
|
return std::pow(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static double MathRandom(void)
|
static double MathRandom()
|
||||||
{
|
{
|
||||||
return (double)std::rand() / RAND_MAX;
|
return (double)std::rand() / RAND_MAX;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
static void WriteStringToStream(std::ostream& stream, const String& message);
|
static void WriteStringToStream(std::ostream& stream, const String& message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NetString(void);
|
NetString();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ NetworkStream::NetworkStream(const Socket::Ptr& socket)
|
|||||||
: m_Socket(socket), m_Eof(false)
|
: m_Socket(socket), m_Eof(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void NetworkStream::Close(void)
|
void NetworkStream::Close()
|
||||||
{
|
{
|
||||||
Stream::Close();
|
Stream::Close();
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ void NetworkStream::Write(const void *buffer, size_t count)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkStream::IsEof(void) const
|
bool NetworkStream::IsEof() const
|
||||||
{
|
{
|
||||||
return m_Eof;
|
return m_Eof;
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,9 @@ public:
|
|||||||
virtual size_t Read(void *buffer, size_t count, bool allow_partial = false) override;
|
virtual size_t Read(void *buffer, size_t count, bool allow_partial = false) override;
|
||||||
virtual void Write(const void *buffer, size_t count) override;
|
virtual void Write(const void *buffer, size_t count) override;
|
||||||
|
|
||||||
virtual void Close(void) override;
|
virtual void Close() override;
|
||||||
|
|
||||||
virtual bool IsEof(void) const override;
|
virtual bool IsEof() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Socket::Ptr m_Socket;
|
Socket::Ptr m_Socket;
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
static String NumberToString(void)
|
static String NumberToString()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
return vframe->Self;
|
return vframe->Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Ptr Number::GetPrototype(void)
|
Object::Ptr Number::GetPrototype()
|
||||||
{
|
{
|
||||||
static Dictionary::Ptr prototype;
|
static Dictionary::Ptr prototype;
|
||||||
|
|
||||||
|
@ -33,10 +33,10 @@ class Value;
|
|||||||
class Number
|
class Number
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Object::Ptr GetPrototype(void);
|
static Object::Ptr GetPrototype();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Number(void);
|
Number();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
static String ObjectToString(void)
|
static String ObjectToString()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
|
Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
|
||||||
@ -39,14 +39,14 @@ static void ObjectNotifyAttribute(const String& attribute)
|
|||||||
self->NotifyField(self->GetReflectionType()->GetFieldId(attribute));
|
self->NotifyField(self->GetReflectionType()->GetFieldId(attribute));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Object::Ptr ObjectClone(void)
|
static Object::Ptr ObjectClone()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
|
Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
|
||||||
return self->Clone();
|
return self->Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Ptr Object::GetPrototype(void)
|
Object::Ptr Object::GetPrototype()
|
||||||
{
|
{
|
||||||
static Dictionary::Ptr prototype;
|
static Dictionary::Ptr prototype;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ static Timer::Ptr l_ObjectCountTimer;
|
|||||||
/**
|
/**
|
||||||
* Default constructor for the Object class.
|
* Default constructor for the Object class.
|
||||||
*/
|
*/
|
||||||
Object::Object(void)
|
Object::Object()
|
||||||
: m_References(0), m_Mutex(0)
|
: m_References(0), m_Mutex(0)
|
||||||
#ifdef I2_DEBUG
|
#ifdef I2_DEBUG
|
||||||
, m_LockOwner(0)
|
, m_LockOwner(0)
|
||||||
@ -51,7 +51,7 @@ Object::Object(void)
|
|||||||
/**
|
/**
|
||||||
* Destructor for the Object class.
|
* Destructor for the Object class.
|
||||||
*/
|
*/
|
||||||
Object::~Object(void)
|
Object::~Object()
|
||||||
{
|
{
|
||||||
delete reinterpret_cast<boost::recursive_mutex *>(m_Mutex);
|
delete reinterpret_cast<boost::recursive_mutex *>(m_Mutex);
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ Object::~Object(void)
|
|||||||
/**
|
/**
|
||||||
* Returns a string representation for the object.
|
* Returns a string representation for the object.
|
||||||
*/
|
*/
|
||||||
String Object::ToString(void) const
|
String Object::ToString() const
|
||||||
{
|
{
|
||||||
return "Object of type '" + GetReflectionType()->GetName() + "'";
|
return "Object of type '" + GetReflectionType()->GetName() + "'";
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ String Object::ToString(void) const
|
|||||||
*
|
*
|
||||||
* @returns True if the calling thread owns the lock, false otherwise.
|
* @returns True if the calling thread owns the lock, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool Object::OwnsLock(void) const
|
bool Object::OwnsLock() const
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD tid = InterlockedExchangeAdd(&m_LockOwner, 0);
|
DWORD tid = InterlockedExchangeAdd(&m_LockOwner, 0);
|
||||||
@ -193,12 +193,12 @@ Object::Ptr Object::NavigateField(int id) const
|
|||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Ptr Object::Clone(void) const
|
Object::Ptr Object::Clone() const
|
||||||
{
|
{
|
||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Object cannot be cloned."));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Object cannot be cloned."));
|
||||||
}
|
}
|
||||||
|
|
||||||
Type::Ptr Object::GetReflectionType(void) const
|
Type::Ptr Object::GetReflectionType() const
|
||||||
{
|
{
|
||||||
return Object::TypeInstance;
|
return Object::TypeInstance;
|
||||||
}
|
}
|
||||||
@ -238,7 +238,7 @@ void icinga::TypeRemoveObject(Object *object)
|
|||||||
l_ObjectCounts[typeName]--;
|
l_ObjectCounts[typeName]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TypeInfoTimerHandler(void)
|
static void TypeInfoTimerHandler()
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(l_ObjectCountLock);
|
boost::mutex::scoped_lock lock(l_ObjectCountLock);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ extern Value Empty;
|
|||||||
|
|
||||||
#define IMPL_TYPE_LOOKUP() \
|
#define IMPL_TYPE_LOOKUP() \
|
||||||
static intrusive_ptr<Type> TypeInstance; \
|
static intrusive_ptr<Type> TypeInstance; \
|
||||||
virtual intrusive_ptr<Type> GetReflectionType(void) const override \
|
virtual intrusive_ptr<Type> GetReflectionType() const override \
|
||||||
{ \
|
{ \
|
||||||
return TypeInstance; \
|
return TypeInstance; \
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ struct TypeHelper
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
struct TypeHelper<T, false>
|
struct TypeHelper<T, false>
|
||||||
{
|
{
|
||||||
static ObjectFactory GetFactory(void)
|
static ObjectFactory GetFactory()
|
||||||
{
|
{
|
||||||
return DefaultObjectFactory<T>;
|
return DefaultObjectFactory<T>;
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ struct TypeHelper<T, false>
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
struct TypeHelper<T, true>
|
struct TypeHelper<T, true>
|
||||||
{
|
{
|
||||||
static ObjectFactory GetFactory(void)
|
static ObjectFactory GetFactory()
|
||||||
{
|
{
|
||||||
return DefaultObjectFactoryVA<T>;
|
return DefaultObjectFactoryVA<T>;
|
||||||
}
|
}
|
||||||
@ -109,12 +109,12 @@ class Object
|
|||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Object);
|
DECLARE_PTR_TYPEDEFS(Object);
|
||||||
|
|
||||||
Object(void);
|
Object();
|
||||||
virtual ~Object(void);
|
virtual ~Object();
|
||||||
|
|
||||||
virtual String ToString(void) const;
|
virtual String ToString() const;
|
||||||
|
|
||||||
virtual intrusive_ptr<Type> GetReflectionType(void) const;
|
virtual intrusive_ptr<Type> GetReflectionType() const;
|
||||||
|
|
||||||
virtual void Validate(int types, const ValidationUtils& utils);
|
virtual void Validate(int types, const ValidationUtils& utils);
|
||||||
|
|
||||||
@ -129,12 +129,12 @@ public:
|
|||||||
virtual Object::Ptr NavigateField(int id) const;
|
virtual Object::Ptr NavigateField(int id) const;
|
||||||
|
|
||||||
#ifdef I2_DEBUG
|
#ifdef I2_DEBUG
|
||||||
bool OwnsLock(void) const;
|
bool OwnsLock() const;
|
||||||
#endif /* I2_DEBUG */
|
#endif /* I2_DEBUG */
|
||||||
|
|
||||||
static Object::Ptr GetPrototype(void);
|
static Object::Ptr GetPrototype();
|
||||||
|
|
||||||
virtual Object::Ptr Clone(void) const;
|
virtual Object::Ptr Clone() const;
|
||||||
|
|
||||||
static intrusive_ptr<Type> TypeInstance;
|
static intrusive_ptr<Type> TypeInstance;
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ using namespace icinga;
|
|||||||
#define I2MUTEX_UNLOCKED 0
|
#define I2MUTEX_UNLOCKED 0
|
||||||
#define I2MUTEX_LOCKED 1
|
#define I2MUTEX_LOCKED 1
|
||||||
|
|
||||||
ObjectLock::ObjectLock(void)
|
ObjectLock::ObjectLock()
|
||||||
: m_Object(nullptr), m_Locked(false)
|
: m_Object(nullptr), m_Locked(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
ObjectLock::~ObjectLock(void)
|
ObjectLock::~ObjectLock()
|
||||||
{
|
{
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ void ObjectLock::LockMutex(const Object *object)
|
|||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectLock::Lock(void)
|
void ObjectLock::Lock()
|
||||||
{
|
{
|
||||||
ASSERT(!m_Locked && m_Object);
|
ASSERT(!m_Locked && m_Object);
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ void ObjectLock::Spin(unsigned int it)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectLock::Unlock(void)
|
void ObjectLock::Unlock()
|
||||||
{
|
{
|
||||||
#ifdef I2_DEBUG
|
#ifdef I2_DEBUG
|
||||||
if (m_Locked) {
|
if (m_Locked) {
|
||||||
|
@ -31,19 +31,19 @@ namespace icinga
|
|||||||
struct ObjectLock
|
struct ObjectLock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ObjectLock(void);
|
ObjectLock();
|
||||||
ObjectLock(const Object::Ptr& object);
|
ObjectLock(const Object::Ptr& object);
|
||||||
ObjectLock(const Object *object);
|
ObjectLock(const Object *object);
|
||||||
|
|
||||||
~ObjectLock(void);
|
~ObjectLock();
|
||||||
|
|
||||||
static void LockMutex(const Object *object);
|
static void LockMutex(const Object *object);
|
||||||
|
|
||||||
void Lock(void);
|
void Lock();
|
||||||
|
|
||||||
static void Spin(unsigned int it);
|
static void Spin(unsigned int it);
|
||||||
|
|
||||||
void Unlock(void);
|
void Unlock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Object *m_Object;
|
const Object *m_Object;
|
||||||
|
@ -29,20 +29,20 @@ INITIALIZE_ONCE_WITH_PRIORITY([]() {
|
|||||||
Object::TypeInstance = type;
|
Object::TypeInstance = type;
|
||||||
}, 20);
|
}, 20);
|
||||||
|
|
||||||
ObjectType::ObjectType(void)
|
ObjectType::ObjectType()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
String ObjectType::GetName(void) const
|
String ObjectType::GetName() const
|
||||||
{
|
{
|
||||||
return "Object";
|
return "Object";
|
||||||
}
|
}
|
||||||
|
|
||||||
Type::Ptr ObjectType::GetBaseType(void) const
|
Type::Ptr ObjectType::GetBaseType() const
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObjectType::GetAttributes(void) const
|
int ObjectType::GetAttributes() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -63,12 +63,12 @@ Field ObjectType::GetFieldInfo(int id) const
|
|||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObjectType::GetFieldCount(void) const
|
int ObjectType::GetFieldCount() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectFactory ObjectType::GetFactory(void) const
|
ObjectFactory ObjectType::GetFactory() const
|
||||||
{
|
{
|
||||||
return DefaultObjectFactory<Object>;
|
return DefaultObjectFactory<Object>;
|
||||||
}
|
}
|
||||||
|
@ -30,17 +30,17 @@ namespace icinga
|
|||||||
class ObjectType final : public Type
|
class ObjectType final : public Type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ObjectType(void);
|
ObjectType();
|
||||||
|
|
||||||
virtual String GetName(void) const override;
|
virtual String GetName() const override;
|
||||||
virtual Type::Ptr GetBaseType(void) const override;
|
virtual Type::Ptr GetBaseType() const override;
|
||||||
virtual int GetAttributes(void) const override;
|
virtual int GetAttributes() const override;
|
||||||
virtual int GetFieldId(const String& name) const override;
|
virtual int GetFieldId(const String& name) const override;
|
||||||
virtual Field GetFieldInfo(int id) const override;
|
virtual Field GetFieldInfo(int id) const override;
|
||||||
virtual int GetFieldCount(void) const override;
|
virtual int GetFieldCount() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ObjectFactory GetFactory(void) const override;
|
virtual ObjectFactory GetFactory() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ using namespace icinga;
|
|||||||
REGISTER_TYPE(PerfdataValue);
|
REGISTER_TYPE(PerfdataValue);
|
||||||
REGISTER_SCRIPTFUNCTION_NS(System, parse_performance_data, PerfdataValue::Parse, "perfdata");
|
REGISTER_SCRIPTFUNCTION_NS(System, parse_performance_data, PerfdataValue::Parse, "perfdata");
|
||||||
|
|
||||||
PerfdataValue::PerfdataValue(void)
|
PerfdataValue::PerfdataValue()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
PerfdataValue::PerfdataValue(String label, double value, bool counter,
|
PerfdataValue::PerfdataValue(String label, double value, bool counter,
|
||||||
@ -139,7 +139,7 @@ PerfdataValue::Ptr PerfdataValue::Parse(const String& perfdata)
|
|||||||
return new PerfdataValue(label, value, counter, unit, warn, crit, min, max);
|
return new PerfdataValue(label, value, counter, unit, warn, crit, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
String PerfdataValue::Format(void) const
|
String PerfdataValue::Format() const
|
||||||
{
|
{
|
||||||
std::ostringstream result;
|
std::ostringstream result;
|
||||||
|
|
||||||
|
@ -36,14 +36,14 @@ class PerfdataValue final : public ObjectImpl<PerfdataValue>
|
|||||||
public:
|
public:
|
||||||
DECLARE_OBJECT(PerfdataValue);
|
DECLARE_OBJECT(PerfdataValue);
|
||||||
|
|
||||||
PerfdataValue(void);
|
PerfdataValue();
|
||||||
|
|
||||||
PerfdataValue(String label, double value, bool counter = false, const String& unit = "",
|
PerfdataValue(String label, double value, bool counter = false, const String& unit = "",
|
||||||
const Value& warn = Empty, const Value& crit = Empty,
|
const Value& warn = Empty, const Value& crit = Empty,
|
||||||
const Value& min = Empty, const Value& max = Empty);
|
const Value& min = Empty, const Value& max = Empty);
|
||||||
|
|
||||||
static PerfdataValue::Ptr Parse(const String& perfdata);
|
static PerfdataValue::Ptr Parse(const String& perfdata);
|
||||||
String Format(void) const;
|
String Format() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Value ParseWarnCritMinMaxToken(const std::vector<String>& tokens,
|
static Value ParseWarnCritMinMaxToken(const std::vector<String>& tokens,
|
||||||
|
@ -26,12 +26,12 @@ PrimitiveType::PrimitiveType(const String& name, const String& base, const Objec
|
|||||||
: m_Name(name), m_Base(base), m_Factory(factory)
|
: m_Name(name), m_Base(base), m_Factory(factory)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
String PrimitiveType::GetName(void) const
|
String PrimitiveType::GetName() const
|
||||||
{
|
{
|
||||||
return m_Name;
|
return m_Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type::Ptr PrimitiveType::GetBaseType(void) const
|
Type::Ptr PrimitiveType::GetBaseType() const
|
||||||
{
|
{
|
||||||
if (m_Base == "None")
|
if (m_Base == "None")
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -39,7 +39,7 @@ Type::Ptr PrimitiveType::GetBaseType(void) const
|
|||||||
return Type::GetByName(m_Base);
|
return Type::GetByName(m_Base);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PrimitiveType::GetAttributes(void) const
|
int PrimitiveType::GetAttributes() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ Field PrimitiveType::GetFieldInfo(int id) const
|
|||||||
throw std::runtime_error("Invalid field ID.");
|
throw std::runtime_error("Invalid field ID.");
|
||||||
}
|
}
|
||||||
|
|
||||||
int PrimitiveType::GetFieldCount(void) const
|
int PrimitiveType::GetFieldCount() const
|
||||||
{
|
{
|
||||||
Type::Ptr base = GetBaseType();
|
Type::Ptr base = GetBaseType();
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ int PrimitiveType::GetFieldCount(void) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectFactory PrimitiveType::GetFactory(void) const
|
ObjectFactory PrimitiveType::GetFactory() const
|
||||||
{
|
{
|
||||||
return m_Factory;
|
return m_Factory;
|
||||||
}
|
}
|
||||||
|
@ -32,15 +32,15 @@ class PrimitiveType final : public Type
|
|||||||
public:
|
public:
|
||||||
PrimitiveType(const String& name, const String& base, const ObjectFactory& factory = ObjectFactory());
|
PrimitiveType(const String& name, const String& base, const ObjectFactory& factory = ObjectFactory());
|
||||||
|
|
||||||
virtual String GetName(void) const override;
|
virtual String GetName() const override;
|
||||||
virtual Type::Ptr GetBaseType(void) const override;
|
virtual Type::Ptr GetBaseType() const override;
|
||||||
virtual int GetAttributes(void) const override;
|
virtual int GetAttributes() const override;
|
||||||
virtual int GetFieldId(const String& name) const override;
|
virtual int GetFieldId(const String& name) const override;
|
||||||
virtual Field GetFieldInfo(int id) const override;
|
virtual Field GetFieldInfo(int id) const override;
|
||||||
virtual int GetFieldCount(void) const override;
|
virtual int GetFieldCount() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ObjectFactory GetFactory(void) const override;
|
virtual ObjectFactory GetFactory() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_Name;
|
String m_Name;
|
||||||
|
@ -76,7 +76,7 @@ Process::Process(const Process::Arguments& arguments, const Dictionary::Ptr& ext
|
|||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
Process::~Process(void)
|
Process::~Process()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
CloseHandle(m_Overlapped.hEvent);
|
CloseHandle(m_Overlapped.hEvent);
|
||||||
@ -237,7 +237,7 @@ static Value ProcessWaitPIDImpl(struct msghdr *msgh, const Dictionary::Ptr& requ
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessHandler(void)
|
static void ProcessHandler()
|
||||||
{
|
{
|
||||||
sigset_t mask;
|
sigset_t mask;
|
||||||
sigfillset(&mask);
|
sigfillset(&mask);
|
||||||
@ -333,7 +333,7 @@ static void ProcessHandler(void)
|
|||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StartSpawnProcessHelper(void)
|
static void StartSpawnProcessHelper()
|
||||||
{
|
{
|
||||||
if (l_ProcessControlFD != -1) {
|
if (l_ProcessControlFD != -1) {
|
||||||
(void)close(l_ProcessControlFD);
|
(void)close(l_ProcessControlFD);
|
||||||
@ -497,14 +497,14 @@ send_message:
|
|||||||
return response->Get("rc");
|
return response->Get("rc");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process::InitializeSpawnHelper(void)
|
void Process::InitializeSpawnHelper()
|
||||||
{
|
{
|
||||||
if (l_ProcessControlFD == -1)
|
if (l_ProcessControlFD == -1)
|
||||||
StartSpawnProcessHelper();
|
StartSpawnProcessHelper();
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
static void InitializeProcess(void)
|
static void InitializeProcess()
|
||||||
{
|
{
|
||||||
for (int tid = 0; tid < IOTHREADS; tid++) {
|
for (int tid = 0; tid < IOTHREADS; tid++) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -536,7 +536,7 @@ static void InitializeProcess(void)
|
|||||||
|
|
||||||
INITIALIZE_ONCE(InitializeProcess);
|
INITIALIZE_ONCE(InitializeProcess);
|
||||||
|
|
||||||
void Process::ThreadInitialize(void)
|
void Process::ThreadInitialize()
|
||||||
{
|
{
|
||||||
/* Note to self: Make sure this runs _after_ we've daemonized. */
|
/* Note to self: Make sure this runs _after_ we've daemonized. */
|
||||||
for (int tid = 0; tid < IOTHREADS; tid++) {
|
for (int tid = 0; tid < IOTHREADS; tid++) {
|
||||||
@ -583,7 +583,7 @@ void Process::SetTimeout(double timeout)
|
|||||||
m_Timeout = timeout;
|
m_Timeout = timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Process::GetTimeout(void) const
|
double Process::GetTimeout() const
|
||||||
{
|
{
|
||||||
return m_Timeout;
|
return m_Timeout;
|
||||||
}
|
}
|
||||||
@ -593,7 +593,7 @@ void Process::SetAdjustPriority(bool adjust)
|
|||||||
m_AdjustPriority = adjust;
|
m_AdjustPriority = adjust;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Process::GetAdjustPriority(void) const
|
bool Process::GetAdjustPriority() const
|
||||||
{
|
{
|
||||||
return m_AdjustPriority;
|
return m_AdjustPriority;
|
||||||
}
|
}
|
||||||
@ -1016,7 +1016,7 @@ void Process::Run(const std::function<void(const ProcessResult&)>& callback)
|
|||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Process::DoEvents(void)
|
bool Process::DoEvents()
|
||||||
{
|
{
|
||||||
bool is_timeout = false;
|
bool is_timeout = false;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@ -1134,13 +1134,13 @@ bool Process::DoEvents(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t Process::GetPID(void) const
|
pid_t Process::GetPID() const
|
||||||
{
|
{
|
||||||
return m_PID;
|
return m_PID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Process::GetTID(void) const
|
int Process::GetTID() const
|
||||||
{
|
{
|
||||||
return (reinterpret_cast<uintptr_t>(this) / sizeof(void *)) % IOTHREADS;
|
return (reinterpret_cast<uintptr_t>(this) / sizeof(void *)) % IOTHREADS;
|
||||||
}
|
}
|
||||||
|
@ -67,26 +67,26 @@ public:
|
|||||||
static const std::deque<Process::Ptr>::size_type MaxTasksPerThread = 512;
|
static const std::deque<Process::Ptr>::size_type MaxTasksPerThread = 512;
|
||||||
|
|
||||||
Process(const Arguments& arguments, const Dictionary::Ptr& extraEnvironment = nullptr);
|
Process(const Arguments& arguments, const Dictionary::Ptr& extraEnvironment = nullptr);
|
||||||
~Process(void);
|
~Process();
|
||||||
|
|
||||||
void SetTimeout(double timeout);
|
void SetTimeout(double timeout);
|
||||||
double GetTimeout(void) const;
|
double GetTimeout() const;
|
||||||
|
|
||||||
void SetAdjustPriority(bool adjust);
|
void SetAdjustPriority(bool adjust);
|
||||||
bool GetAdjustPriority(void) const;
|
bool GetAdjustPriority() const;
|
||||||
|
|
||||||
void Run(const std::function<void (const ProcessResult&)>& callback = std::function<void (const ProcessResult&)>());
|
void Run(const std::function<void (const ProcessResult&)>& callback = std::function<void (const ProcessResult&)>());
|
||||||
|
|
||||||
pid_t GetPID(void) const;
|
pid_t GetPID() const;
|
||||||
|
|
||||||
static Arguments PrepareCommand(const Value& command);
|
static Arguments PrepareCommand(const Value& command);
|
||||||
|
|
||||||
static void ThreadInitialize(void);
|
static void ThreadInitialize();
|
||||||
|
|
||||||
static String PrettyPrintArguments(const Arguments& arguments);
|
static String PrettyPrintArguments(const Arguments& arguments);
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static void InitializeSpawnHelper(void);
|
static void InitializeSpawnHelper();
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -112,8 +112,8 @@ private:
|
|||||||
ProcessResult m_Result;
|
ProcessResult m_Result;
|
||||||
|
|
||||||
static void IOThreadProc(int tid);
|
static void IOThreadProc(int tid);
|
||||||
bool DoEvents(void);
|
bool DoEvents();
|
||||||
int GetTID(void) const;
|
int GetTID() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public:
|
|||||||
OnUnregistered(name);
|
OnUnregistered(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear(void)
|
void Clear()
|
||||||
{
|
{
|
||||||
typename Registry<U, T>::ItemMap items;
|
typename Registry<U, T>::ItemMap items;
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ public:
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemMap GetItems(void) const
|
ItemMap GetItems() const
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_Mutex);
|
boost::mutex::scoped_lock lock(m_Mutex);
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ RingBuffer::RingBuffer(RingBuffer::SizeType slots)
|
|||||||
: Object(), m_Slots(slots, 0), m_TimeValue(0), m_InsertedValues(0)
|
: Object(), m_Slots(slots, 0), m_TimeValue(0), m_InsertedValues(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
RingBuffer::SizeType RingBuffer::GetLength(void) const
|
RingBuffer::SizeType RingBuffer::GetLength() const
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
RingBuffer(SizeType slots);
|
RingBuffer(SizeType slots);
|
||||||
|
|
||||||
SizeType GetLength(void) const;
|
SizeType GetLength() const;
|
||||||
void InsertValue(SizeType tv, int num);
|
void InsertValue(SizeType tv, int num);
|
||||||
int UpdateAndGetValues(SizeType tv, SizeType span);
|
int UpdateAndGetValues(SizeType tv, SizeType span);
|
||||||
double CalculateRate(SizeType tv, SizeType span);
|
double CalculateRate(SizeType tv, SizeType span);
|
||||||
|
@ -52,7 +52,7 @@ ScriptFrame::ScriptFrame(bool allocLocals, const Value& self)
|
|||||||
InitializeFrame();
|
InitializeFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFrame::InitializeFrame(void)
|
void ScriptFrame::InitializeFrame()
|
||||||
{
|
{
|
||||||
std::stack<ScriptFrame *> *frames = m_ScriptFrames.get();
|
std::stack<ScriptFrame *> *frames = m_ScriptFrames.get();
|
||||||
|
|
||||||
@ -65,13 +65,13 @@ void ScriptFrame::InitializeFrame(void)
|
|||||||
PushFrame(this);
|
PushFrame(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptFrame::~ScriptFrame(void)
|
ScriptFrame::~ScriptFrame()
|
||||||
{
|
{
|
||||||
ScriptFrame *frame = PopFrame();
|
ScriptFrame *frame = PopFrame();
|
||||||
ASSERT(frame == this);
|
ASSERT(frame == this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFrame::IncreaseStackDepth(void)
|
void ScriptFrame::IncreaseStackDepth()
|
||||||
{
|
{
|
||||||
if (Depth + 1 > 300)
|
if (Depth + 1 > 300)
|
||||||
BOOST_THROW_EXCEPTION(ScriptError("Stack overflow while evaluating expression: Recursion level too deep."));
|
BOOST_THROW_EXCEPTION(ScriptError("Stack overflow while evaluating expression: Recursion level too deep."));
|
||||||
@ -79,12 +79,12 @@ void ScriptFrame::IncreaseStackDepth(void)
|
|||||||
Depth++;
|
Depth++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptFrame::DecreaseStackDepth(void)
|
void ScriptFrame::DecreaseStackDepth()
|
||||||
{
|
{
|
||||||
Depth--;
|
Depth--;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptFrame *ScriptFrame::GetCurrentFrame(void)
|
ScriptFrame *ScriptFrame::GetCurrentFrame()
|
||||||
{
|
{
|
||||||
std::stack<ScriptFrame *> *frames = m_ScriptFrames.get();
|
std::stack<ScriptFrame *> *frames = m_ScriptFrames.get();
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ ScriptFrame *ScriptFrame::GetCurrentFrame(void)
|
|||||||
return frames->top();
|
return frames->top();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptFrame *ScriptFrame::PopFrame(void)
|
ScriptFrame *ScriptFrame::PopFrame()
|
||||||
{
|
{
|
||||||
std::stack<ScriptFrame *> *frames = m_ScriptFrames.get();
|
std::stack<ScriptFrame *> *frames = m_ScriptFrames.get();
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ void ScriptFrame::PushFrame(ScriptFrame *frame)
|
|||||||
frames->push(frame);
|
frames->push(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array::Ptr ScriptFrame::GetImports(void)
|
Array::Ptr ScriptFrame::GetImports()
|
||||||
{
|
{
|
||||||
return m_Imports;
|
return m_Imports;
|
||||||
}
|
}
|
||||||
|
@ -38,14 +38,14 @@ struct ScriptFrame
|
|||||||
|
|
||||||
ScriptFrame(bool allocLocals);
|
ScriptFrame(bool allocLocals);
|
||||||
ScriptFrame(bool allocLocals, const Value& self);
|
ScriptFrame(bool allocLocals, const Value& self);
|
||||||
~ScriptFrame(void);
|
~ScriptFrame();
|
||||||
|
|
||||||
void IncreaseStackDepth(void);
|
void IncreaseStackDepth();
|
||||||
void DecreaseStackDepth(void);
|
void DecreaseStackDepth();
|
||||||
|
|
||||||
static ScriptFrame *GetCurrentFrame(void);
|
static ScriptFrame *GetCurrentFrame();
|
||||||
|
|
||||||
static Array::Ptr GetImports(void);
|
static Array::Ptr GetImports();
|
||||||
static void AddImport(const Object::Ptr& import);
|
static void AddImport(const Object::Ptr& import);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -53,9 +53,9 @@ private:
|
|||||||
static Array::Ptr m_Imports;
|
static Array::Ptr m_Imports;
|
||||||
|
|
||||||
static void PushFrame(ScriptFrame *frame);
|
static void PushFrame(ScriptFrame *frame);
|
||||||
static ScriptFrame *PopFrame(void);
|
static ScriptFrame *PopFrame();
|
||||||
|
|
||||||
void InitializeFrame(void);
|
void InitializeFrame();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ bool ScriptGlobal::Exists(const String& name)
|
|||||||
return m_Globals->Contains(name);
|
return m_Globals->Contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr ScriptGlobal::GetGlobals(void)
|
Dictionary::Ptr ScriptGlobal::GetGlobals()
|
||||||
{
|
{
|
||||||
return m_Globals;
|
return m_Globals;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
|
|
||||||
static void WriteToFile(const String& filename);
|
static void WriteToFile(const String& filename);
|
||||||
|
|
||||||
static Dictionary::Ptr GetGlobals(void);
|
static Dictionary::Ptr GetGlobals();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Dictionary::Ptr m_Globals;
|
static Dictionary::Ptr m_Globals;
|
||||||
|
@ -81,7 +81,7 @@ enum MatchType
|
|||||||
MatchAny
|
MatchAny
|
||||||
};
|
};
|
||||||
|
|
||||||
void ScriptUtils::StaticInitialize(void)
|
void ScriptUtils::StaticInitialize()
|
||||||
{
|
{
|
||||||
ScriptGlobal::Set("MatchAll", MatchAll);
|
ScriptGlobal::Set("MatchAll", MatchAll);
|
||||||
ScriptGlobal::Set("MatchAny", MatchAny);
|
ScriptGlobal::Set("MatchAny", MatchAny);
|
||||||
|
@ -36,7 +36,7 @@ namespace icinga
|
|||||||
class ScriptUtils
|
class ScriptUtils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void StaticInitialize(void);
|
static void StaticInitialize();
|
||||||
static String CastString(const Value& value);
|
static String CastString(const Value& value);
|
||||||
static double CastNumber(const Value& value);
|
static double CastNumber(const Value& value);
|
||||||
static bool CastBool(const Value& value);
|
static bool CastBool(const Value& value);
|
||||||
@ -60,7 +60,7 @@ public:
|
|||||||
static Value GlobRecursive(const std::vector<Value>& args);
|
static Value GlobRecursive(const std::vector<Value>& args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScriptUtils(void);
|
ScriptUtils();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ template<typename T>
|
|||||||
class Singleton
|
class Singleton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static T *GetInstance(void)
|
static T *GetInstance()
|
||||||
{
|
{
|
||||||
/* FIXME: This relies on static initializers being atomic. */
|
/* FIXME: This relies on static initializers being atomic. */
|
||||||
static boost::mutex mutex;
|
static boost::mutex mutex;
|
||||||
|
@ -37,7 +37,7 @@ using namespace icinga;
|
|||||||
/**
|
/**
|
||||||
* Constructor for the Socket class.
|
* Constructor for the Socket class.
|
||||||
*/
|
*/
|
||||||
Socket::Socket(void)
|
Socket::Socket()
|
||||||
: m_FD(INVALID_SOCKET)
|
: m_FD(INVALID_SOCKET)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ Socket::Socket(SOCKET fd)
|
|||||||
/**
|
/**
|
||||||
* Destructor for the Socket class.
|
* Destructor for the Socket class.
|
||||||
*/
|
*/
|
||||||
Socket::~Socket(void)
|
Socket::~Socket()
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ void Socket::SetFD(SOCKET fd)
|
|||||||
*
|
*
|
||||||
* @returns The file descriptor.
|
* @returns The file descriptor.
|
||||||
*/
|
*/
|
||||||
SOCKET Socket::GetFD(void) const
|
SOCKET Socket::GetFD() const
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ SOCKET Socket::GetFD(void) const
|
|||||||
/**
|
/**
|
||||||
* Closes the socket.
|
* Closes the socket.
|
||||||
*/
|
*/
|
||||||
void Socket::Close(void)
|
void Socket::Close()
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ void Socket::Close(void)
|
|||||||
*
|
*
|
||||||
* @returns An error code.
|
* @returns An error code.
|
||||||
*/
|
*/
|
||||||
int Socket::GetError(void) const
|
int Socket::GetError() const
|
||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
socklen_t optlen = sizeof(opt);
|
socklen_t optlen = sizeof(opt);
|
||||||
@ -158,7 +158,7 @@ String Socket::GetAddressFromSockaddr(sockaddr *address, socklen_t len)
|
|||||||
*
|
*
|
||||||
* @returns A String describing the local address.
|
* @returns A String describing the local address.
|
||||||
*/
|
*/
|
||||||
String Socket::GetClientAddress(void)
|
String Socket::GetClientAddress()
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_SocketMutex);
|
boost::mutex::scoped_lock lock(m_SocketMutex);
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ String Socket::GetClientAddress(void)
|
|||||||
*
|
*
|
||||||
* @returns A String describing the peer address.
|
* @returns A String describing the peer address.
|
||||||
*/
|
*/
|
||||||
String Socket::GetPeerAddress(void)
|
String Socket::GetPeerAddress()
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_SocketMutex);
|
boost::mutex::scoped_lock lock(m_SocketMutex);
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ String Socket::GetPeerAddress(void)
|
|||||||
/**
|
/**
|
||||||
* Starts listening for incoming client connections.
|
* Starts listening for incoming client connections.
|
||||||
*/
|
*/
|
||||||
void Socket::Listen(void)
|
void Socket::Listen()
|
||||||
{
|
{
|
||||||
if (listen(GetFD(), SOMAXCONN) < 0) {
|
if (listen(GetFD(), SOMAXCONN) < 0) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@ -328,7 +328,7 @@ size_t Socket::Read(void *buffer, size_t count)
|
|||||||
/**
|
/**
|
||||||
* Accepts a new client and creates a new client object for it.
|
* Accepts a new client and creates a new client object for it.
|
||||||
*/
|
*/
|
||||||
Socket::Ptr Socket::Accept(void)
|
Socket::Ptr Socket::Accept()
|
||||||
{
|
{
|
||||||
sockaddr_storage addr;
|
sockaddr_storage addr;
|
||||||
socklen_t addrlen = sizeof(addr);
|
socklen_t addrlen = sizeof(addr);
|
||||||
@ -407,7 +407,7 @@ bool Socket::Poll(bool read, bool write, struct timeval *timeout)
|
|||||||
return (rc != 0);
|
return (rc != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::MakeNonBlocking(void)
|
void Socket::MakeNonBlocking()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
Utility::SetNonBlockingSocket(GetFD());
|
Utility::SetNonBlockingSocket(GetFD());
|
||||||
|
@ -36,33 +36,33 @@ class Socket : public Object
|
|||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Socket);
|
DECLARE_PTR_TYPEDEFS(Socket);
|
||||||
|
|
||||||
Socket(void);
|
Socket();
|
||||||
Socket(SOCKET fd);
|
Socket(SOCKET fd);
|
||||||
~Socket(void);
|
~Socket();
|
||||||
|
|
||||||
SOCKET GetFD(void) const;
|
SOCKET GetFD() const;
|
||||||
|
|
||||||
void Close(void);
|
void Close();
|
||||||
|
|
||||||
String GetClientAddress(void);
|
String GetClientAddress();
|
||||||
String GetPeerAddress(void);
|
String GetPeerAddress();
|
||||||
|
|
||||||
size_t Read(void *buffer, size_t size);
|
size_t Read(void *buffer, size_t size);
|
||||||
size_t Write(const void *buffer, size_t size);
|
size_t Write(const void *buffer, size_t size);
|
||||||
|
|
||||||
void Listen(void);
|
void Listen();
|
||||||
Socket::Ptr Accept(void);
|
Socket::Ptr Accept();
|
||||||
|
|
||||||
bool Poll(bool read, bool write, struct timeval *timeout = nullptr);
|
bool Poll(bool read, bool write, struct timeval *timeout = nullptr);
|
||||||
|
|
||||||
void MakeNonBlocking(void);
|
void MakeNonBlocking();
|
||||||
|
|
||||||
static void SocketPair(SOCKET s[2]);
|
static void SocketPair(SOCKET s[2]);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetFD(SOCKET fd);
|
void SetFD(SOCKET fd);
|
||||||
|
|
||||||
int GetError(void) const;
|
int GetError() const;
|
||||||
|
|
||||||
mutable boost::mutex m_SocketMutex;
|
mutable boost::mutex m_SocketMutex;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ static SocketEventEngine *l_SocketIOEngine;
|
|||||||
|
|
||||||
int SocketEvents::m_NextID = 0;
|
int SocketEvents::m_NextID = 0;
|
||||||
|
|
||||||
void SocketEventEngine::Start(void)
|
void SocketEventEngine::Start()
|
||||||
{
|
{
|
||||||
for (int tid = 0; tid < SOCKET_IOTHREADS; tid++) {
|
for (int tid = 0; tid < SOCKET_IOTHREADS; tid++) {
|
||||||
Socket::SocketPair(m_EventFDs[tid]);
|
Socket::SocketPair(m_EventFDs[tid]);
|
||||||
@ -77,7 +77,7 @@ void SocketEventEngine::WakeUpThread(int sid, bool wait)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SocketEvents::InitializeEngine(void)
|
void SocketEvents::InitializeEngine()
|
||||||
{
|
{
|
||||||
String eventEngine = ScriptGlobal::Get("EventEngine", &Empty);
|
String eventEngine = ScriptGlobal::Get("EventEngine", &Empty);
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ SocketEvents::SocketEvents(const Socket::Ptr& socket, Object *lifesupportObject)
|
|||||||
Register(lifesupportObject);
|
Register(lifesupportObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketEvents::~SocketEvents(void)
|
SocketEvents::~SocketEvents()
|
||||||
{
|
{
|
||||||
VERIFY(m_FD == INVALID_SOCKET);
|
VERIFY(m_FD == INVALID_SOCKET);
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ void SocketEvents::Register(Object *lifesupportObject)
|
|||||||
l_SocketIOEngine->Register(this, lifesupportObject);
|
l_SocketIOEngine->Register(this, lifesupportObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SocketEvents::Unregister(void)
|
void SocketEvents::Unregister()
|
||||||
{
|
{
|
||||||
l_SocketIOEngine->Unregister(this);
|
l_SocketIOEngine->Unregister(this);
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ boost::mutex& SocketEventEngine::GetMutex(int tid)
|
|||||||
return m_EventMutex[tid];
|
return m_EventMutex[tid];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SocketEvents::IsHandlingEvents(void) const
|
bool SocketEvents::IsHandlingEvents() const
|
||||||
{
|
{
|
||||||
int tid = m_ID % SOCKET_IOTHREADS;
|
int tid = m_ID % SOCKET_IOTHREADS;
|
||||||
boost::mutex::scoped_lock lock(l_SocketIOEngine->GetMutex(tid));
|
boost::mutex::scoped_lock lock(l_SocketIOEngine->GetMutex(tid));
|
||||||
|
@ -39,17 +39,17 @@ namespace icinga
|
|||||||
class SocketEvents
|
class SocketEvents
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~SocketEvents(void);
|
~SocketEvents();
|
||||||
|
|
||||||
virtual void OnEvent(int revents);
|
virtual void OnEvent(int revents);
|
||||||
|
|
||||||
void Unregister(void);
|
void Unregister();
|
||||||
|
|
||||||
void ChangeEvents(int events);
|
void ChangeEvents(int events);
|
||||||
|
|
||||||
bool IsHandlingEvents(void) const;
|
bool IsHandlingEvents() const;
|
||||||
|
|
||||||
void *GetEnginePrivate(void) const;
|
void *GetEnginePrivate() const;
|
||||||
void SetEnginePrivate(void *priv);
|
void SetEnginePrivate(void *priv);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -63,7 +63,7 @@ private:
|
|||||||
|
|
||||||
static int m_NextID;
|
static int m_NextID;
|
||||||
|
|
||||||
static void InitializeEngine(void);
|
static void InitializeEngine();
|
||||||
|
|
||||||
void WakeUpThread(bool wait = false);
|
void WakeUpThread(bool wait = false);
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ struct SocketEventDescriptor
|
|||||||
SocketEvents *EventInterface;
|
SocketEvents *EventInterface;
|
||||||
Object *LifesupportObject;
|
Object *LifesupportObject;
|
||||||
|
|
||||||
SocketEventDescriptor(void)
|
SocketEventDescriptor()
|
||||||
: Events(POLLIN), EventInterface(nullptr), LifesupportObject(nullptr)
|
: Events(POLLIN), EventInterface(nullptr), LifesupportObject(nullptr)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
@ -96,7 +96,7 @@ struct EventDescription
|
|||||||
class SocketEventEngine
|
class SocketEventEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Start(void);
|
void Start();
|
||||||
|
|
||||||
void WakeUpThread(int sid, bool wait);
|
void WakeUpThread(int sid, bool wait);
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ using namespace icinga;
|
|||||||
# pragma optimize("", off)
|
# pragma optimize("", off)
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
StackTrace::StackTrace(void)
|
StackTrace::StackTrace()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_BACKTRACE_SYMBOLS
|
#ifdef HAVE_BACKTRACE_SYMBOLS
|
||||||
m_Count = backtrace(m_Frames, sizeof(m_Frames) / sizeof(m_Frames[0]));
|
m_Count = backtrace(m_Frames, sizeof(m_Frames) / sizeof(m_Frames[0]));
|
||||||
|
@ -34,14 +34,14 @@ namespace icinga
|
|||||||
class StackTrace
|
class StackTrace
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StackTrace(void);
|
StackTrace();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
explicit StackTrace(PEXCEPTION_POINTERS exi);
|
explicit StackTrace(PEXCEPTION_POINTERS exi);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
void Print(std::ostream& fp, int ignoreFrames = 0) const;
|
void Print(std::ostream& fp, int ignoreFrames = 0) const;
|
||||||
|
|
||||||
static void StaticInitialize(void);
|
static void StaticInitialize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void *m_Frames[64];
|
void *m_Frames[64];
|
||||||
|
@ -33,7 +33,7 @@ StdioStream::StdioStream(std::iostream *innerStream, bool ownsStream)
|
|||||||
: m_InnerStream(innerStream), m_OwnsStream(ownsStream)
|
: m_InnerStream(innerStream), m_OwnsStream(ownsStream)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
StdioStream::~StdioStream(void)
|
StdioStream::~StdioStream()
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ void StdioStream::Write(const void *buffer, size_t size)
|
|||||||
m_InnerStream->write(static_cast<const char *>(buffer), size);
|
m_InnerStream->write(static_cast<const char *>(buffer), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StdioStream::Close(void)
|
void StdioStream::Close()
|
||||||
{
|
{
|
||||||
Stream::Close();
|
Stream::Close();
|
||||||
|
|
||||||
@ -63,12 +63,12 @@ void StdioStream::Close(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StdioStream::IsDataAvailable(void) const
|
bool StdioStream::IsDataAvailable() const
|
||||||
{
|
{
|
||||||
return !IsEof();
|
return !IsEof();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StdioStream::IsEof(void) const
|
bool StdioStream::IsEof() const
|
||||||
{
|
{
|
||||||
return !m_InnerStream->good();
|
return !m_InnerStream->good();
|
||||||
}
|
}
|
||||||
|
@ -32,15 +32,15 @@ public:
|
|||||||
DECLARE_PTR_TYPEDEFS(StdioStream);
|
DECLARE_PTR_TYPEDEFS(StdioStream);
|
||||||
|
|
||||||
StdioStream(std::iostream *innerStream, bool ownsStream);
|
StdioStream(std::iostream *innerStream, bool ownsStream);
|
||||||
~StdioStream(void);
|
~StdioStream();
|
||||||
|
|
||||||
virtual size_t Read(void *buffer, size_t size, bool allow_partial = false) override;
|
virtual size_t Read(void *buffer, size_t size, bool allow_partial = false) override;
|
||||||
virtual void Write(const void *buffer, size_t size) override;
|
virtual void Write(const void *buffer, size_t size) override;
|
||||||
|
|
||||||
virtual void Close(void) override;
|
virtual void Close() override;
|
||||||
|
|
||||||
virtual bool IsDataAvailable(void) const override;
|
virtual bool IsDataAvailable() const override;
|
||||||
virtual bool IsEof(void) const override;
|
virtual bool IsEof() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::iostream *m_InnerStream;
|
std::iostream *m_InnerStream;
|
||||||
|
@ -30,17 +30,17 @@ void Stream::RegisterDataHandler(const std::function<void(const Stream::Ptr&)>&
|
|||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Stream does not support waiting."));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Stream does not support waiting."));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Stream::SupportsWaiting(void) const
|
bool Stream::SupportsWaiting() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Stream::IsDataAvailable(void) const
|
bool Stream::IsDataAvailable() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stream::Shutdown(void)
|
void Stream::Shutdown()
|
||||||
{
|
{
|
||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Stream does not support Shutdown()."));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Stream does not support Shutdown()."));
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@ size_t Stream::Peek(void *buffer, size_t count, bool allow_partial)
|
|||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Stream does not support Peek()."));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Stream does not support Peek()."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stream::SignalDataAvailable(void)
|
void Stream::SignalDataAvailable()
|
||||||
{
|
{
|
||||||
OnDataAvailable(this);
|
OnDataAvailable(this);
|
||||||
|
|
||||||
@ -76,10 +76,10 @@ bool Stream::WaitForData(int timeout)
|
|||||||
return IsDataAvailable() || IsEof();
|
return IsDataAvailable() || IsEof();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StreamDummyCallback(void)
|
static void StreamDummyCallback()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void Stream::Close(void)
|
void Stream::Close()
|
||||||
{
|
{
|
||||||
OnDataAvailable.disconnect_all_slots();
|
OnDataAvailable.disconnect_all_slots();
|
||||||
|
|
||||||
|
@ -38,11 +38,11 @@ enum ConnectionRole
|
|||||||
|
|
||||||
struct StreamReadContext
|
struct StreamReadContext
|
||||||
{
|
{
|
||||||
StreamReadContext(void)
|
StreamReadContext()
|
||||||
: Buffer(nullptr), Size(0), MustRead(true), Eof(false)
|
: Buffer(nullptr), Size(0), MustRead(true), Eof(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
~StreamReadContext(void)
|
~StreamReadContext()
|
||||||
{
|
{
|
||||||
free(Buffer);
|
free(Buffer);
|
||||||
}
|
}
|
||||||
@ -108,35 +108,35 @@ public:
|
|||||||
* Causes the stream to be closed (via Close()) once all pending data has been
|
* Causes the stream to be closed (via Close()) once all pending data has been
|
||||||
* written.
|
* written.
|
||||||
*/
|
*/
|
||||||
virtual void Shutdown(void);
|
virtual void Shutdown();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the stream and releases resources.
|
* Closes the stream and releases resources.
|
||||||
*/
|
*/
|
||||||
virtual void Close(void);
|
virtual void Close();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether we've reached the end-of-file condition.
|
* Checks whether we've reached the end-of-file condition.
|
||||||
*
|
*
|
||||||
* @returns true if EOF.
|
* @returns true if EOF.
|
||||||
*/
|
*/
|
||||||
virtual bool IsEof(void) const = 0;
|
virtual bool IsEof() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits until data can be read from the stream.
|
* Waits until data can be read from the stream.
|
||||||
*/
|
*/
|
||||||
bool WaitForData(int timeout = -1);
|
bool WaitForData(int timeout = -1);
|
||||||
|
|
||||||
virtual bool SupportsWaiting(void) const;
|
virtual bool SupportsWaiting() const;
|
||||||
|
|
||||||
virtual bool IsDataAvailable(void) const;
|
virtual bool IsDataAvailable() const;
|
||||||
|
|
||||||
void RegisterDataHandler(const std::function<void(const Stream::Ptr&)>& handler);
|
void RegisterDataHandler(const std::function<void(const Stream::Ptr&)>& handler);
|
||||||
|
|
||||||
StreamReadStatus ReadLine(String *line, StreamReadContext& context, bool may_wait = false);
|
StreamReadStatus ReadLine(String *line, StreamReadContext& context, bool may_wait = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SignalDataAvailable(void);
|
void SignalDataAvailable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::signals2::signal<void(const Stream::Ptr&)> OnDataAvailable;
|
boost::signals2::signal<void(const Stream::Ptr&)> OnDataAvailable;
|
||||||
|
@ -33,7 +33,7 @@ boost::mutex StreamLogger::m_Mutex;
|
|||||||
/**
|
/**
|
||||||
* Constructor for the StreamLogger class.
|
* Constructor for the StreamLogger class.
|
||||||
*/
|
*/
|
||||||
StreamLogger::StreamLogger(void)
|
StreamLogger::StreamLogger()
|
||||||
: m_Stream(nullptr), m_OwnsStream(false)
|
: m_Stream(nullptr), m_OwnsStream(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ void StreamLogger::Stop(bool runtimeRemoved)
|
|||||||
/**
|
/**
|
||||||
* Destructor for the StreamLogger class.
|
* Destructor for the StreamLogger class.
|
||||||
*/
|
*/
|
||||||
StreamLogger::~StreamLogger(void)
|
StreamLogger::~StreamLogger()
|
||||||
{
|
{
|
||||||
if (m_FlushLogTimer)
|
if (m_FlushLogTimer)
|
||||||
m_FlushLogTimer->Stop();
|
m_FlushLogTimer->Stop();
|
||||||
@ -58,12 +58,12 @@ StreamLogger::~StreamLogger(void)
|
|||||||
delete m_Stream;
|
delete m_Stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamLogger::FlushLogTimerHandler(void)
|
void StreamLogger::FlushLogTimerHandler()
|
||||||
{
|
{
|
||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamLogger::Flush(void)
|
void StreamLogger::Flush()
|
||||||
{
|
{
|
||||||
if (m_Stream)
|
if (m_Stream)
|
||||||
m_Stream->flush();
|
m_Stream->flush();
|
||||||
|
@ -38,18 +38,18 @@ class StreamLogger : public ObjectImpl<StreamLogger>
|
|||||||
public:
|
public:
|
||||||
DECLARE_OBJECT(StreamLogger);
|
DECLARE_OBJECT(StreamLogger);
|
||||||
|
|
||||||
StreamLogger(void);
|
StreamLogger();
|
||||||
|
|
||||||
virtual void Stop(bool runtimeRemoved) override;
|
virtual void Stop(bool runtimeRemoved) override;
|
||||||
~StreamLogger(void);
|
~StreamLogger();
|
||||||
|
|
||||||
void BindStream(std::ostream *stream, bool ownsStream);
|
void BindStream(std::ostream *stream, bool ownsStream);
|
||||||
|
|
||||||
static void ProcessLogEntry(std::ostream& stream, const LogEntry& entry);
|
static void ProcessLogEntry(std::ostream& stream, const LogEntry& entry);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void ProcessLogEntry(const LogEntry& entry) override final;
|
void ProcessLogEntry(const LogEntry& entry) final;
|
||||||
virtual void Flush(void) override final;
|
void Flush(void) final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static boost::mutex m_Mutex;
|
static boost::mutex m_Mutex;
|
||||||
@ -58,7 +58,7 @@ private:
|
|||||||
|
|
||||||
Timer::Ptr m_FlushLogTimer;
|
Timer::Ptr m_FlushLogTimer;
|
||||||
|
|
||||||
void FlushLogTimerHandler(void);
|
void FlushLogTimerHandler();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,14 +27,14 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
static int StringLen(void)
|
static int StringLen()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
String self = vframe->Self;
|
String self = vframe->Self;
|
||||||
return self.GetLength();
|
return self.GetLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
static String StringToString(void)
|
static String StringToString()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
return vframe->Self;
|
return vframe->Self;
|
||||||
@ -57,14 +57,14 @@ static String StringSubstr(const std::vector<Value>& args)
|
|||||||
return self.SubStr(args[0]);
|
return self.SubStr(args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String StringUpper(void)
|
static String StringUpper()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
String self = vframe->Self;
|
String self = vframe->Self;
|
||||||
return boost::to_upper_copy(self);
|
return boost::to_upper_copy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String StringLower(void)
|
static String StringLower()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
String self = vframe->Self;
|
String self = vframe->Self;
|
||||||
@ -125,21 +125,21 @@ static Value StringReplace(const String& search, const String& replacement)
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String StringReverse(void)
|
static String StringReverse()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
String self = vframe->Self;
|
String self = vframe->Self;
|
||||||
return self.Reverse();
|
return self.Reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
static String StringTrim(void)
|
static String StringTrim()
|
||||||
{
|
{
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
String self = vframe->Self;
|
String self = vframe->Self;
|
||||||
return self.Trim();
|
return self.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Ptr String::GetPrototype(void)
|
Object::Ptr String::GetPrototype()
|
||||||
{
|
{
|
||||||
static Dictionary::Ptr prototype;
|
static Dictionary::Ptr prototype;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ REGISTER_BUILTIN_TYPE(String, String::GetPrototype());
|
|||||||
|
|
||||||
const String::SizeType String::NPos = std::string::npos;
|
const String::SizeType String::NPos = std::string::npos;
|
||||||
|
|
||||||
String::String(void)
|
String::String()
|
||||||
: m_Data()
|
: m_Data()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ String::String(Value&& other)
|
|||||||
}
|
}
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
String::~String(void)
|
String::~String()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
String& String::operator=(Value&& other)
|
String& String::operator=(Value&& other)
|
||||||
@ -137,7 +137,7 @@ String& String::operator+=(char rhs)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool String::IsEmpty(void) const
|
bool String::IsEmpty() const
|
||||||
{
|
{
|
||||||
return m_Data.empty();
|
return m_Data.empty();
|
||||||
}
|
}
|
||||||
@ -147,32 +147,32 @@ bool String::operator<(const String& rhs) const
|
|||||||
return m_Data < rhs.m_Data;
|
return m_Data < rhs.m_Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
String::operator const std::string&(void) const
|
String::operator const std::string&() const
|
||||||
{
|
{
|
||||||
return m_Data;
|
return m_Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *String::CStr(void) const
|
const char *String::CStr() const
|
||||||
{
|
{
|
||||||
return m_Data.c_str();
|
return m_Data.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void String::Clear(void)
|
void String::Clear()
|
||||||
{
|
{
|
||||||
m_Data.clear();
|
m_Data.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
String::SizeType String::GetLength(void) const
|
String::SizeType String::GetLength() const
|
||||||
{
|
{
|
||||||
return m_Data.size();
|
return m_Data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string& String::GetData(void)
|
std::string& String::GetData()
|
||||||
{
|
{
|
||||||
return m_Data;
|
return m_Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& String::GetData(void) const
|
const std::string& String::GetData() const
|
||||||
{
|
{
|
||||||
return m_Data;
|
return m_Data;
|
||||||
}
|
}
|
||||||
@ -234,28 +234,28 @@ void String::Replace(String::SizeType first, String::SizeType second, const Stri
|
|||||||
m_Data.replace(first, second, str);
|
m_Data.replace(first, second, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
String String::Trim(void) const
|
String String::Trim() const
|
||||||
{
|
{
|
||||||
String t = m_Data;
|
String t = m_Data;
|
||||||
boost::algorithm::trim(t);
|
boost::algorithm::trim(t);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
String String::ToLower(void) const
|
String String::ToLower() const
|
||||||
{
|
{
|
||||||
String t = m_Data;
|
String t = m_Data;
|
||||||
boost::algorithm::to_lower(t);
|
boost::algorithm::to_lower(t);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
String String::ToUpper(void) const
|
String String::ToUpper() const
|
||||||
{
|
{
|
||||||
String t = m_Data;
|
String t = m_Data;
|
||||||
boost::algorithm::to_upper(t);
|
boost::algorithm::to_upper(t);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
String String::Reverse(void) const
|
String String::Reverse() const
|
||||||
{
|
{
|
||||||
String t = m_Data;
|
String t = m_Data;
|
||||||
std::reverse(t.m_Data.begin(), t.m_Data.end());
|
std::reverse(t.m_Data.begin(), t.m_Data.end());
|
||||||
@ -282,42 +282,42 @@ String::Iterator String::erase(String::Iterator first, String::Iterator last)
|
|||||||
return m_Data.erase(first, last);
|
return m_Data.erase(first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
String::Iterator String::Begin(void)
|
String::Iterator String::Begin()
|
||||||
{
|
{
|
||||||
return m_Data.begin();
|
return m_Data.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
String::ConstIterator String::Begin(void) const
|
String::ConstIterator String::Begin() const
|
||||||
{
|
{
|
||||||
return m_Data.begin();
|
return m_Data.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
String::Iterator String::End(void)
|
String::Iterator String::End()
|
||||||
{
|
{
|
||||||
return m_Data.end();
|
return m_Data.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
String::ConstIterator String::End(void) const
|
String::ConstIterator String::End() const
|
||||||
{
|
{
|
||||||
return m_Data.end();
|
return m_Data.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
String::ReverseIterator String::RBegin(void)
|
String::ReverseIterator String::RBegin()
|
||||||
{
|
{
|
||||||
return m_Data.rbegin();
|
return m_Data.rbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
String::ConstReverseIterator String::RBegin(void) const
|
String::ConstReverseIterator String::RBegin() const
|
||||||
{
|
{
|
||||||
return m_Data.rbegin();
|
return m_Data.rbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
String::ReverseIterator String::REnd(void)
|
String::ReverseIterator String::REnd()
|
||||||
{
|
{
|
||||||
return m_Data.rend();
|
return m_Data.rend();
|
||||||
}
|
}
|
||||||
|
|
||||||
String::ConstReverseIterator String::REnd(void) const
|
String::ConstReverseIterator String::REnd() const
|
||||||
{
|
{
|
||||||
return m_Data.rend();
|
return m_Data.rend();
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
|
|
||||||
typedef std::string::size_type SizeType;
|
typedef std::string::size_type SizeType;
|
||||||
|
|
||||||
String(void);
|
String();
|
||||||
String(const char *data);
|
String(const char *data);
|
||||||
String(const std::string& data);
|
String(const std::string& data);
|
||||||
String(std::string&& data);
|
String(std::string&& data);
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
String(Value&& other);
|
String(Value&& other);
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
~String(void);
|
~String();
|
||||||
|
|
||||||
template<typename InputIterator>
|
template<typename InputIterator>
|
||||||
String(InputIterator begin, InputIterator end)
|
String(InputIterator begin, InputIterator end)
|
||||||
@ -91,20 +91,20 @@ public:
|
|||||||
String& operator+=(const Value& rhs);
|
String& operator+=(const Value& rhs);
|
||||||
String& operator+=(char rhs);
|
String& operator+=(char rhs);
|
||||||
|
|
||||||
bool IsEmpty(void) const;
|
bool IsEmpty() const;
|
||||||
|
|
||||||
bool operator<(const String& rhs) const;
|
bool operator<(const String& rhs) const;
|
||||||
|
|
||||||
operator const std::string&(void) const;
|
operator const std::string&() const;
|
||||||
|
|
||||||
const char *CStr(void) const;
|
const char *CStr() const;
|
||||||
|
|
||||||
void Clear(void);
|
void Clear();
|
||||||
|
|
||||||
SizeType GetLength(void) const;
|
SizeType GetLength() const;
|
||||||
|
|
||||||
std::string& GetData(void);
|
std::string& GetData();
|
||||||
const std::string& GetData(void) const;
|
const std::string& GetData() const;
|
||||||
|
|
||||||
SizeType Find(const String& str, SizeType pos = 0) const;
|
SizeType Find(const String& str, SizeType pos = 0) const;
|
||||||
SizeType RFind(const String& str, SizeType pos = NPos) const;
|
SizeType RFind(const String& str, SizeType pos = NPos) const;
|
||||||
@ -121,13 +121,13 @@ public:
|
|||||||
|
|
||||||
void Replace(SizeType first, SizeType second, const String& str);
|
void Replace(SizeType first, SizeType second, const String& str);
|
||||||
|
|
||||||
String Trim(void) const;
|
String Trim() const;
|
||||||
|
|
||||||
String ToLower(void) const;
|
String ToLower() const;
|
||||||
|
|
||||||
String ToUpper(void) const;
|
String ToUpper() const;
|
||||||
|
|
||||||
String Reverse(void) const;
|
String Reverse() const;
|
||||||
|
|
||||||
void Append(int count, char ch);
|
void Append(int count, char ch);
|
||||||
|
|
||||||
@ -143,18 +143,18 @@ public:
|
|||||||
m_Data.insert(p, first, last);
|
m_Data.insert(p, first, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator Begin(void);
|
Iterator Begin();
|
||||||
ConstIterator Begin(void) const;
|
ConstIterator Begin() const;
|
||||||
Iterator End(void);
|
Iterator End();
|
||||||
ConstIterator End(void) const;
|
ConstIterator End() const;
|
||||||
ReverseIterator RBegin(void);
|
ReverseIterator RBegin();
|
||||||
ConstReverseIterator RBegin(void) const;
|
ConstReverseIterator RBegin() const;
|
||||||
ReverseIterator REnd(void);
|
ReverseIterator REnd();
|
||||||
ConstReverseIterator REnd(void) const;
|
ConstReverseIterator REnd() const;
|
||||||
|
|
||||||
static const SizeType NPos;
|
static const SizeType NPos;
|
||||||
|
|
||||||
static Object::Ptr GetPrototype(void);
|
static Object::Ptr GetPrototype();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_Data;
|
std::string m_Data;
|
||||||
|
@ -33,7 +33,7 @@ INITIALIZE_ONCE(&SyslogLogger::StaticInitialize);
|
|||||||
|
|
||||||
std::map<String, int> SyslogLogger::m_FacilityMap;
|
std::map<String, int> SyslogLogger::m_FacilityMap;
|
||||||
|
|
||||||
void SyslogLogger::StaticInitialize(void)
|
void SyslogLogger::StaticInitialize()
|
||||||
{
|
{
|
||||||
ScriptGlobal::Set("FacilityAuth", "LOG_AUTH");
|
ScriptGlobal::Set("FacilityAuth", "LOG_AUTH");
|
||||||
ScriptGlobal::Set("FacilityAuthPriv", "LOG_AUTHPRIV");
|
ScriptGlobal::Set("FacilityAuthPriv", "LOG_AUTHPRIV");
|
||||||
@ -89,7 +89,7 @@ void SyslogLogger::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&)
|
|||||||
status->Set("sysloglogger", nodes);
|
status->Set("sysloglogger", nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyslogLogger::OnConfigLoaded(void)
|
void SyslogLogger::OnConfigLoaded()
|
||||||
{
|
{
|
||||||
ObjectImpl<SyslogLogger>::OnConfigLoaded();
|
ObjectImpl<SyslogLogger>::OnConfigLoaded();
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ void SyslogLogger::ProcessLogEntry(const LogEntry& entry)
|
|||||||
syslog(severity | m_Facility, "%s", entry.Message.CStr());
|
syslog(severity | m_Facility, "%s", entry.Message.CStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyslogLogger::Flush(void)
|
void SyslogLogger::Flush()
|
||||||
{
|
{
|
||||||
/* Nothing to do here. */
|
/* Nothing to do here. */
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,10 @@ public:
|
|||||||
DECLARE_OBJECT(SyslogLogger);
|
DECLARE_OBJECT(SyslogLogger);
|
||||||
DECLARE_OBJECTNAME(SyslogLogger);
|
DECLARE_OBJECTNAME(SyslogLogger);
|
||||||
|
|
||||||
static void StaticInitialize(void);
|
static void StaticInitialize();
|
||||||
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
|
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
|
||||||
|
|
||||||
virtual void OnConfigLoaded(void) override;
|
virtual void OnConfigLoaded() override;
|
||||||
virtual void ValidateFacility(const String& value, const ValidationUtils& utils) override;
|
virtual void ValidateFacility(const String& value, const ValidationUtils& utils) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -49,7 +49,7 @@ protected:
|
|||||||
int m_Facility;
|
int m_Facility;
|
||||||
|
|
||||||
virtual void ProcessLogEntry(const LogEntry& entry) override;
|
virtual void ProcessLogEntry(const LogEntry& entry) override;
|
||||||
virtual void Flush(void) override;
|
virtual void Flush() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,12 @@ ThreadPool::ThreadPool(size_t max_threads)
|
|||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadPool::~ThreadPool(void)
|
ThreadPool::~ThreadPool()
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadPool::Start(void)
|
void ThreadPool::Start()
|
||||||
{
|
{
|
||||||
if (!m_Stopped)
|
if (!m_Stopped)
|
||||||
return;
|
return;
|
||||||
@ -56,7 +56,7 @@ void ThreadPool::Start(void)
|
|||||||
m_MgmtThread = std::thread(std::bind(&ThreadPool::ManagerThreadProc, this));
|
m_MgmtThread = std::thread(std::bind(&ThreadPool::ManagerThreadProc, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadPool::Stop(void)
|
void ThreadPool::Stop()
|
||||||
{
|
{
|
||||||
if (m_Stopped)
|
if (m_Stopped)
|
||||||
return;
|
return;
|
||||||
@ -219,7 +219,7 @@ bool ThreadPool::Post(const ThreadPool::WorkFunction& callback, SchedulerPolicy
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadPool::ManagerThreadProc(void)
|
void ThreadPool::ManagerThreadProc()
|
||||||
{
|
{
|
||||||
std::ostringstream idbuf;
|
std::ostringstream idbuf;
|
||||||
idbuf << "TP #" << m_ID << " Manager";
|
idbuf << "TP #" << m_ID << " Manager";
|
||||||
|
@ -49,10 +49,10 @@ public:
|
|||||||
typedef std::function<void ()> WorkFunction;
|
typedef std::function<void ()> WorkFunction;
|
||||||
|
|
||||||
ThreadPool(size_t max_threads = UINT_MAX);
|
ThreadPool(size_t max_threads = UINT_MAX);
|
||||||
~ThreadPool(void);
|
~ThreadPool();
|
||||||
|
|
||||||
void Start(void);
|
void Start();
|
||||||
void Stop(void);
|
void Stop();
|
||||||
|
|
||||||
bool Post(const WorkFunction& callback, SchedulerPolicy policy = DefaultScheduler);
|
bool Post(const WorkFunction& callback, SchedulerPolicy policy = DefaultScheduler);
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ private:
|
|||||||
|
|
||||||
WorkerThread Threads[16];
|
WorkerThread Threads[16];
|
||||||
|
|
||||||
Queue(void)
|
Queue()
|
||||||
: WaitTime(0), ServiceTime(0), TaskCount(0), Stopped(false)
|
: WaitTime(0), ServiceTime(0), TaskCount(0), Stopped(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ private:
|
|||||||
|
|
||||||
Queue m_Queues[QUEUECOUNT];
|
Queue m_Queues[QUEUECOUNT];
|
||||||
|
|
||||||
void ManagerThreadProc(void);
|
void ManagerThreadProc();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,17 +37,17 @@ public:
|
|||||||
: m_Timer(timer)
|
: m_Timer(timer)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
inline Timer *GetObject(void) const
|
inline Timer *GetObject() const
|
||||||
{
|
{
|
||||||
return m_Timer;
|
return m_Timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double GetNextUnlocked(void) const
|
inline double GetNextUnlocked() const
|
||||||
{
|
{
|
||||||
return m_Timer->m_Next;
|
return m_Timer->m_Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator Timer *(void) const
|
operator Timer *() const
|
||||||
{
|
{
|
||||||
return m_Timer;
|
return m_Timer;
|
||||||
}
|
}
|
||||||
@ -76,19 +76,19 @@ static int l_AliveTimers;
|
|||||||
/**
|
/**
|
||||||
* Constructor for the Timer class.
|
* Constructor for the Timer class.
|
||||||
*/
|
*/
|
||||||
Timer::Timer(void)
|
Timer::Timer()
|
||||||
: m_Interval(0), m_Next(0), m_Started(false), m_Running(false)
|
: m_Interval(0), m_Next(0), m_Started(false), m_Running(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor for the Timer class.
|
* Destructor for the Timer class.
|
||||||
*/
|
*/
|
||||||
Timer::~Timer(void)
|
Timer::~Timer()
|
||||||
{
|
{
|
||||||
Stop(true);
|
Stop(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer::Uninitialize(void)
|
void Timer::Uninitialize()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(l_TimerMutex);
|
boost::mutex::scoped_lock lock(l_TimerMutex);
|
||||||
@ -103,7 +103,7 @@ void Timer::Uninitialize(void)
|
|||||||
/**
|
/**
|
||||||
* Calls this timer.
|
* Calls this timer.
|
||||||
*/
|
*/
|
||||||
void Timer::Call(void)
|
void Timer::Call()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
OnTimerExpired(Timer::Ptr(this));
|
OnTimerExpired(Timer::Ptr(this));
|
||||||
@ -132,7 +132,7 @@ void Timer::SetInterval(double interval)
|
|||||||
*
|
*
|
||||||
* @returns The interval.
|
* @returns The interval.
|
||||||
*/
|
*/
|
||||||
double Timer::GetInterval(void) const
|
double Timer::GetInterval() const
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(l_TimerMutex);
|
boost::mutex::scoped_lock lock(l_TimerMutex);
|
||||||
return m_Interval;
|
return m_Interval;
|
||||||
@ -141,7 +141,7 @@ double Timer::GetInterval(void) const
|
|||||||
/**
|
/**
|
||||||
* Registers the timer and starts processing events for it.
|
* Registers the timer and starts processing events for it.
|
||||||
*/
|
*/
|
||||||
void Timer::Start(void)
|
void Timer::Start()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(l_TimerMutex);
|
boost::mutex::scoped_lock lock(l_TimerMutex);
|
||||||
@ -232,7 +232,7 @@ void Timer::InternalReschedule(bool completed, double next)
|
|||||||
*
|
*
|
||||||
* @returns The timestamp.
|
* @returns The timestamp.
|
||||||
*/
|
*/
|
||||||
double Timer::GetNext(void) const
|
double Timer::GetNext() const
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(l_TimerMutex);
|
boost::mutex::scoped_lock lock(l_TimerMutex);
|
||||||
return m_Next;
|
return m_Next;
|
||||||
@ -275,7 +275,7 @@ void Timer::AdjustTimers(double adjustment)
|
|||||||
/**
|
/**
|
||||||
* Worker thread proc for Timer objects.
|
* Worker thread proc for Timer objects.
|
||||||
*/
|
*/
|
||||||
void Timer::TimerThreadProc(void)
|
void Timer::TimerThreadProc()
|
||||||
{
|
{
|
||||||
Utility::SetThreadName("Timer Thread");
|
Utility::SetThreadName("Timer Thread");
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user