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()
61 ValueBaseLink::~ValueBaseLink()
67 ValueNode::LooseHandle ValueBaseLink::get_link_vfunc(int i)const
69 /*list_type::const_iterator it = list.begin();
71 while(it != list.end() && i-- > 0)
78 return ValueNode::LooseHandle();
83 if(i >= 0 && i < (int)list.size())
88 return ValueNode::LooseHandle();
93 int ValueBaseLink::link_count()const
98 String ValueBaseLink::link_local_name(int i)const
100 ValueNode::LooseHandle h = get_link(i);
104 return h->get_local_name();
105 }else return String();
108 String ValueBaseLink::link_name(int i)const
110 ValueNode::LooseHandle h = get_link(i);
114 return h->get_name();
115 }else return String();
118 int ValueBaseLink::get_link_index_from_name(const synfig::String &name)const
120 throw Exception::BadLinkName(name);
123 //list management stuff
124 ValueBaseLink::list_type::const_iterator ValueBaseLink::findlink(synfig::ValueNode::Handle x) const
126 for(list_type::const_iterator i = list.begin(); i != list.end(); ++i)
136 ValueBaseLink::list_type::iterator ValueBaseLink::findlink(synfig::ValueNode::Handle x)
138 for(list_type::iterator i = list.begin(); i != list.end(); ++i)
149 void ValueBaseLink::add(synfig::ValueNode::Handle v)
151 list_type::iterator i = findlink(v);
159 void ValueBaseLink::remove(synfig::ValueNode::Handle v)
161 list_type::iterator i = findlink(v);
165 if(i != list.end()-1)