1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
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"
9 using namespace icinga;
11 static void ConfigObjectModifyAttribute(const String& attr, const Value& value)
13 ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
14 ConfigObject::Ptr self = vframe->Self;
15 REQUIRE_NOT_NULL(self);
16 return self->ModifyAttribute(attr, value);
19 static void ConfigObjectRestoreAttribute(const String& attr)
21 ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
22 ConfigObject::Ptr self = vframe->Self;
23 REQUIRE_NOT_NULL(self);
24 return self->RestoreAttribute(attr);
27 Object::Ptr ConfigObject::GetPrototype()
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) }