]> granicus.if.org Git - icinga2/commitdiff
Implement source_location attribute for the ConfigObject class
authorGunnar Beutner <gunnar.beutner@icinga.com>
Wed, 19 Apr 2017 13:30:11 +0000 (15:30 +0200)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Wed, 19 Apr 2017 13:30:11 +0000 (15:30 +0200)
refs #5120

lib/base/configobject.cpp
lib/base/configobject.hpp
lib/base/configobject.ti

index 019916925baba99dde29a5cb1747816e05298eac..f155af3bab73f2caf419ae1db58443d8a7a64ef4 100644 (file)
@@ -710,5 +710,18 @@ ConfigObject::Ptr ConfigObject::GetZone(void) const
        return m_Zone;
 }
 
+Dictionary::Ptr ConfigObject::GetSourceLocation(void) const
+{
+       DebugInfo di = GetDebugInfo();
+
+       Dictionary::Ptr result = new Dictionary();
+       result->Set("path", di.Path);
+       result->Set("first_line", di.FirstLine);
+       result->Set("first_column", di.FirstColumn);
+       result->Set("last_line", di.LastLine);
+       result->Set("last_column", di.LastColumn);
+       return result;
+}
+
 NameComposer::~NameComposer(void)
 { }
index 66253d80f3bdd94b514213bf4364b5c2de5b0e19..b1f45b6f5bbaa663bc69ffcbcc848a965080f24b 100644 (file)
@@ -75,6 +75,8 @@ public:
        virtual void OnAllConfigLoaded(void);
        virtual void OnStateLoaded(void);
 
+       virtual Dictionary::Ptr GetSourceLocation(void) const override;
+
        template<typename T>
        static intrusive_ptr<T> GetObject(const String& name)
        {
index a9892417fee63595ff43eec7d08e5cfa93b346aa..9fe9af42f64cd3bc643eb0534ffea33a06adc5de 100644 (file)
@@ -85,6 +85,9 @@ abstract class ConfigObject : ConfigObjectBase < ConfigType
        [config, no_user_modify] name(Zone) zone (ZoneName);
        [config, no_user_modify] String package;
        [config, get_protected, no_user_modify] Array::Ptr templates;
+       [config, no_storage, no_user_modify] Dictionary::Ptr source_location {
+               get;
+       };
        [get_protected, no_user_modify] bool active;
        [get_protected, no_user_modify] bool paused {
                default {{{ return true; }}}