]> granicus.if.org Git - icinga2/blob - lib/base/configobject-script.cpp
Merge pull request #7185 from Icinga/bugfix/gelfwriter-wrong-log-facility
[icinga2] / lib / base / configobject-script.cpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #include "base/configobject.hpp"
4 #include "base/dictionary.hpp"
5 #include "base/function.hpp"
6 #include "base/functionwrapper.hpp"
7 #include "base/scriptframe.hpp"
8
9 using namespace icinga;
10
11 static void ConfigObjectModifyAttribute(const String& attr, const Value& value)
12 {
13         ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
14         ConfigObject::Ptr self = vframe->Self;
15         REQUIRE_NOT_NULL(self);
16         return self->ModifyAttribute(attr, value);
17 }
18
19 static void ConfigObjectRestoreAttribute(const String& attr)
20 {
21         ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
22         ConfigObject::Ptr self = vframe->Self;
23         REQUIRE_NOT_NULL(self);
24         return self->RestoreAttribute(attr);
25 }
26
27 Object::Ptr ConfigObject::GetPrototype()
28 {
29         static Dictionary::Ptr prototype = new Dictionary({
30                 { "modify_attribute", new Function("ConfigObject#modify_attribute", ConfigObjectModifyAttribute, { "attr", "value" }, false) },
31                 { "restore_attribute", new Function("ConfigObject#restore_attribute", ConfigObjectRestoreAttribute, { "attr", "value" }, false) }
32         });
33
34         return prototype;
35 }
36