2015-08-04 14:47:44 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2016-01-12 08:29:59 +01:00
|
|
|
* Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/) *
|
2015-08-04 14:47:44 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2015-08-15 20:28:05 +02:00
|
|
|
#include "base/configobject.hpp"
|
2015-08-04 14:47:44 +02:00
|
|
|
#include "base/dictionary.hpp"
|
|
|
|
#include "base/function.hpp"
|
|
|
|
#include "base/functionwrapper.hpp"
|
|
|
|
#include "base/scriptframe.hpp"
|
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2015-08-15 20:28:05 +02:00
|
|
|
static void ConfigObjectModifyAttribute(const String& attr, const Value& value)
|
2015-08-04 14:47:44 +02:00
|
|
|
{
|
|
|
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
2015-08-15 20:28:05 +02:00
|
|
|
ConfigObject::Ptr self = vframe->Self;
|
2015-08-04 14:47:44 +02:00
|
|
|
return self->ModifyAttribute(attr, value);
|
|
|
|
}
|
|
|
|
|
2015-08-15 20:28:05 +02:00
|
|
|
static void ConfigObjectRestoreAttribute(const String& attr)
|
2015-08-04 14:47:44 +02:00
|
|
|
{
|
|
|
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
2015-08-15 20:28:05 +02:00
|
|
|
ConfigObject::Ptr self = vframe->Self;
|
2015-08-04 14:47:44 +02:00
|
|
|
return self->RestoreAttribute(attr);
|
|
|
|
}
|
|
|
|
|
2015-08-15 20:28:05 +02:00
|
|
|
Object::Ptr ConfigObject::GetPrototype(void)
|
2015-08-04 14:47:44 +02:00
|
|
|
{
|
|
|
|
static Dictionary::Ptr prototype;
|
|
|
|
|
|
|
|
if (!prototype) {
|
|
|
|
prototype = new Dictionary();
|
2016-08-10 15:40:02 +02:00
|
|
|
prototype->Set("modify_attribute", new Function("ConfigObject#modify_attribute", WrapFunction(ConfigObjectModifyAttribute), false));
|
|
|
|
prototype->Set("restore_attribute", new Function("ConfigObject#restore_attribute", WrapFunction(ConfigObjectRestoreAttribute), false));
|
2015-08-04 14:47:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return prototype;
|
|
|
|
}
|
|
|
|
|