From eba470db3e3dceeadb5fd9f8bd9ccabf7a5fe96d Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 3 Sep 2012 12:48:20 +0200 Subject: [PATCH] Use named variables instead of hard-coded constants. --- cib/service.cpp | 15 ++++++++++----- cib/service.h | 5 +++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cib/service.cpp b/cib/service.cpp index b0beac7b5..95b0ffd92 100644 --- a/cib/service.cpp +++ b/cib/service.cpp @@ -23,6 +23,11 @@ using namespace icinga; REGISTER_CLASS(Service); +const int Service::DefaultMaxAttempts = 3; +const int Service::DefaultCheckInterval = 5 * 60; +const int Service::MinCheckInterval = 15; +const int Service::CheckIntervalDivisor = 5; + boost::signal Service::OnCheckResultReceived; boost::signal Service::OnCheckerChanged; @@ -101,7 +106,7 @@ long Service::GetMaxCheckAttempts(void) const Value value = Get("max_check_attempts"); if (value.IsEmpty()) - return 3; + return DefaultMaxCheckAttempts; return value; } @@ -111,10 +116,10 @@ long Service::GetCheckInterval(void) const Value value = Get("check_interval"); if (value.IsEmpty()) - return 300; + return DefaultCheckInterval; - if (value < 15) - value = 15; + if (value < MinCheckInterval) + value = MinCheckInterval; return value; } @@ -124,7 +129,7 @@ long Service::GetRetryInterval(void) const Value value = Get("retry_interval"); if (value.IsEmpty()) - return GetCheckInterval() / 5; + return GetCheckInterval() / CheckIntervalDivisor; return value; } diff --git a/cib/service.h b/cib/service.h index 7db4f6235..56dde72fe 100644 --- a/cib/service.h +++ b/cib/service.h @@ -52,6 +52,11 @@ public: static bool Exists(const String& name); static Service::Ptr GetByName(const String& name); + static const int DefaultMaxAttempts; + static const int DefaultCheckInterval; + static const int MinCheckInterval; + static const int CheckIntervalDivisor; + String GetAlias(void) const; Host::Ptr GetHost(void) const; Dictionary::Ptr GetMacros(void) const; -- 2.40.0