1 /* === S Y N F I G ========================================================= */
2 /*! \file valuelink.cpp
3 ** \brief ValueBase Link Implementation File
8 ** Copyright (c) 2004 Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "valuelink.h"
38 /* === U S I N G =========================================================== */
42 using namespace synfig;
44 using studio::ValueBaseLink;
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 /* === E N T R Y P O I N T ================================================= */
57 ValueBaseLink::ValueBaseLink()
59 assert(0); //CHECK: This class does not appear to be used.
62 ValueBaseLink::~ValueBaseLink()
68 ValueNode::LooseHandle ValueBaseLink::get_link_vfunc(int i)const
70 /*list_type::const_iterator it = list.begin();
72 while(it != list.end() && i-- > 0)
79 return ValueNode::LooseHandle();
84 if(i >= 0 && i < (int)list.size())
89 return ValueNode::LooseHandle();
94 int ValueBaseLink::link_count()const
99 String ValueBaseLink::link_local_name(int i)const
101 ValueNode::LooseHandle h = get_link(i);
105 return h->get_local_name();
106 }else return String();
109 String ValueBaseLink::link_name(int i)const
111 ValueNode::LooseHandle h = get_link(i);
115 return h->get_name();
116 }else return String();
119 int ValueBaseLink::get_link_index_from_name(const synfig::String &name)const
121 throw Exception::BadLinkName(name);
124 //list management stuff
125 ValueBaseLink::list_type::const_iterator ValueBaseLink::findlink(synfig::ValueNode::Handle x) const
127 for(list_type::const_iterator i = list.begin(); i != list.end(); ++i)
137 ValueBaseLink::list_type::iterator ValueBaseLink::findlink(synfig::ValueNode::Handle x)
139 for(list_type::iterator i = list.begin(); i != list.end(); ++i)
150 void ValueBaseLink::add(synfig::ValueNode::Handle v)
152 list_type::iterator i = findlink(v);
160 void ValueBaseLink::remove(synfig::ValueNode::Handle v)
162 list_type::iterator i = findlink(v);
166 if(i != list.end()-1)