]> granicus.if.org Git - icinga2/commitdiff
Use named variables instead of hard-coded constants.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 3 Sep 2012 10:48:20 +0000 (12:48 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 3 Sep 2012 10:48:20 +0000 (12:48 +0200)
cib/service.cpp
cib/service.h

index b0beac7b550b527344b3ba729e7a8263b78c8692..95b0ffd9216a9aa05fc977fbda5e4d544fdb753b 100644 (file)
@@ -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<void (const Service::Ptr&, const CheckResultMessage&)> Service::OnCheckResultReceived;
 boost::signal<void (const Service::Ptr&, const String&)> 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;
 }
index 7db4f62356fb12e2d047a930631c693243ff3026..56dde72fe47262637facc575d49525cee5cec0b8 100644 (file)
@@ -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;