]> granicus.if.org Git - icinga2/commitdiff
timeperiods: re-add display_name
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 18 Jul 2013 13:30:17 +0000 (15:30 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 18 Jul 2013 13:30:17 +0000 (15:30 +0200)
lib/icinga/icinga-type.conf
lib/icinga/timeperiod.cpp
lib/icinga/timeperiod.h

index 191981032af9c03423171384e5e7b1a152a0bf66..1ce16bec1ece7c4df3a09ceea09edd01a8eed91e 100644 (file)
@@ -328,6 +328,8 @@ type UserGroup {
 }
 
 type TimePeriod {
+       %attribute string "display_name",
+
        %require "methods",
        %attribute dictionary "methods" {
                %require "update",
index f2d57aea1cd62230b38d7733c28934c047864691..5d6f924afb322bb87a189ad5004b9a09d1026b31 100644 (file)
@@ -39,6 +39,7 @@ static Timer::Ptr l_UpdateTimer;
 TimePeriod::TimePeriod(const Dictionary::Ptr& serializedUpdate)
        : DynamicObject(serializedUpdate)
 {
+       RegisterAttribute("display_name", Attribute_Config, &m_DisplayName);
        RegisterAttribute("valid_begin", Attribute_Replicated, &m_ValidBegin);
        RegisterAttribute("valid_end", Attribute_Replicated, &m_ValidEnd);
        RegisterAttribute("segments", Attribute_Replicated, &m_Segments);
@@ -59,6 +60,14 @@ void TimePeriod::Start(void)
        Dump();
 }
 
+String TimePeriod::GetDisplayName(void) const
+{
+        if (!m_DisplayName.IsEmpty())
+                return m_DisplayName;
+        else
+                return GetName();
+}
+
 TimePeriod::Ptr TimePeriod::GetByName(const String& name)
 {
        DynamicObject::Ptr configObject = DynamicObject::GetObject("TimePeriod", name);
index 36e7403db9f631e9c6a6710e03660c0b884eebe3..d41abe9b10e3d144a74fc7b6761b26d859b5ada6 100644 (file)
@@ -41,6 +41,8 @@ public:
 
        static TimePeriod::Ptr GetByName(const String& name);
 
+       String GetDisplayName(void) const;
+
        virtual void Start(void);
 
        void UpdateRegion(double begin, double end, bool clearExisting);
@@ -52,6 +54,7 @@ public:
        static Array::Ptr EvenMinutesTimePeriodUpdate(const TimePeriod::Ptr& tp, double begin, double end);
 
 private:
+       Attribute<String> m_DisplayName;
        Attribute<double> m_ValidBegin;
        Attribute<double> m_ValidEnd;
        Attribute<Array::Ptr> m_Segments;