1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_and.cpp
3 ** \brief Implementation of the "And" 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_and.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_And::ValueNode_And(const ValueBase &x):
55 LinkableValueNode(x.get_type())
57 bool value(x.get(bool()));
59 set_link("link1", ValueNode_Const::create(bool(true)));
60 set_link("link2", ValueNode_Const::create(bool(false)));
62 set_link("link2",ValueNode_Const::create(bool(true)));
66 ValueNode_And::create(const ValueBase &x)
68 return new ValueNode_And(x);
72 ValueNode_And::create_new()const
74 return new ValueNode_And(get_type());
77 ValueNode_And::~ValueNode_And()
83 ValueNode_And::set_link_vfunc(int i,ValueNode::Handle value)
85 assert(i>=0 && i<link_count());
89 case 0: CHECK_TYPE_AND_SET_VALUE(link1_, ValueBase::TYPE_BOOL);
90 case 1: CHECK_TYPE_AND_SET_VALUE(link2_, ValueBase::TYPE_BOOL);
95 ValueNode::LooseHandle
96 ValueNode_And::get_link_vfunc(int i)const
98 assert(i>=0 && i<link_count());
100 if(i==0) return link1_;
101 if(i==1) return link2_;
106 ValueNode_And::link_count()const
112 ValueNode_And::operator()(Time t)const
114 if (getenv("SYNFIG_DEBUG_VALUENODE_OPERATORS"))
115 printf("%s:%d operator()\n", __FILE__, __LINE__);
117 bool link1 = (*link1_) (t).get(bool());
118 bool link2 = (*link2_) (t).get(bool());
120 return (link1 && link2);
124 ValueNode_And::get_name()const
130 ValueNode_And::get_local_name()const
136 ValueNode_And::check_type(ValueBase::Type type)
138 return type==ValueBase::TYPE_BOOL;
141 LinkableValueNode::Vocab
142 ValueNode_And::get_param_vocab() const
144 LinkableValueNode::Vocab ret;
146 ret.push_back(ParamDesc(ValueBase(),"link1")
147 .set_local_name(_("Link1"))
148 .set_description(_("First operand of the AND operation"))
151 ret.push_back(ParamDesc(ValueBase(),"link2")
152 .set_local_name(_("Link2"))
153 .set_description(_("Second operand of the AND operation"))