From 40c62f28bb32c404d1130144092483908ceaf1b0 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 18 Jul 2013 15:30:17 +0200 Subject: [PATCH] timeperiods: re-add display_name --- lib/icinga/icinga-type.conf | 2 ++ lib/icinga/timeperiod.cpp | 9 +++++++++ lib/icinga/timeperiod.h | 3 +++ 3 files changed, 14 insertions(+) diff --git a/lib/icinga/icinga-type.conf b/lib/icinga/icinga-type.conf index 191981032..1ce16bec1 100644 --- a/lib/icinga/icinga-type.conf +++ b/lib/icinga/icinga-type.conf @@ -328,6 +328,8 @@ type UserGroup { } type TimePeriod { + %attribute string "display_name", + %require "methods", %attribute dictionary "methods" { %require "update", diff --git a/lib/icinga/timeperiod.cpp b/lib/icinga/timeperiod.cpp index f2d57aea1..5d6f924af 100644 --- a/lib/icinga/timeperiod.cpp +++ b/lib/icinga/timeperiod.cpp @@ -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); diff --git a/lib/icinga/timeperiod.h b/lib/icinga/timeperiod.h index 36e7403db..d41abe9b1 100644 --- a/lib/icinga/timeperiod.h +++ b/lib/icinga/timeperiod.h @@ -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 m_DisplayName; Attribute m_ValidBegin; Attribute m_ValidEnd; Attribute m_Segments; -- 2.40.0