1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_not.cpp
3 ** \brief Implementation of the "Not" valuenode conversion.
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2008 Chris Moore
10 ** Copyright (c) 2009 Nikita Kitaev
12 ** This package is free software; you can redistribute it and/or
13 ** modify it under the terms of the GNU General Public License as
14 ** published by the Free Software Foundation; either version 2 of
15 ** the License, or (at your option) any later version.
17 ** This package is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ** General Public License for more details.
23 /* ========================================================================= */
25 /* === H E A D E R S ======================================================= */
34 #include "valuenode_not.h"
35 #include "valuenode_const.h"
40 /* === U S I N G =========================================================== */
44 using namespace synfig;
46 /* === M A C R O S ========================================================= */
48 /* === G L O B A L S ======================================================= */
50 /* === P R O C E D U R E S ================================================= */
52 /* === M E T H O D S ======================================================= */
54 ValueNode_Not::ValueNode_Not(const ValueBase &x):
55 LinkableValueNode(x.get_type())
57 bool value(x.get(bool()));
59 set_link("link", ValueNode_Const::create(!value));
63 ValueNode_Not::create(const ValueBase &x)
65 return new ValueNode_Not(x);
69 ValueNode_Not::create_new()const
71 return new ValueNode_Not(get_type());
74 ValueNode_Not::~ValueNode_Not()
80 ValueNode_Not::set_link_vfunc(int i,ValueNode::Handle value)
82 assert(i>=0 && i<link_count());
86 case 0: CHECK_TYPE_AND_SET_VALUE(link_, ValueBase::TYPE_BOOL);
91 ValueNode::LooseHandle
92 ValueNode_Not::get_link_vfunc(int i)const
94 assert(i>=0 && i<link_count());
96 if(i==0) return link_;
101 ValueNode_Not::link_count()const
107 ValueNode_Not::link_local_name(int i)const
109 assert(i>=0 && i<link_count());
111 if(i==0) return _("Link");
116 ValueNode_Not::link_name(int i)const
118 assert(i>=0 && i<link_count());
120 if(i==0) return "link";
125 ValueNode_Not::get_link_index_from_name(const String &name)const
127 if(name=="link") return 0;
129 throw Exception::BadLinkName(name);
133 ValueNode_Not::operator()(Time t)const
135 if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS"))
136 printf("%s:%d operator()\n", __FILE__, __LINE__);
138 bool link = (*link_) (t).get(bool());
144 ValueNode_Not::get_name()const
150 ValueNode_Not::get_local_name()const
156 ValueNode_Not::check_type(ValueBase::Type type)
158 return type==ValueBase::TYPE_BOOL;