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"
36 /* === U S I N G =========================================================== */
40 using namespace synfig;
42 using studio::ValueBaseLink;
44 /* === M A C R O S ========================================================= */
46 /* === G L O B A L S ======================================================= */
48 /* === P R O C E D U R E S ================================================= */
50 /* === M E T H O D S ======================================================= */
52 /* === E N T R Y P O I N T ================================================= */
55 ValueBaseLink::ValueBaseLink()
59 ValueBaseLink::~ValueBaseLink()
65 ValueNode::LooseHandle ValueBaseLink::get_link_vfunc(int i)const
67 /*list_type::const_iterator it = list.begin();
69 while(it != list.end() && i-- > 0)
76 return ValueNode::LooseHandle();
81 if(i >= 0 && i < (int)list.size())
86 return ValueNode::LooseHandle();
91 int ValueBaseLink::link_count()const
96 String ValueBaseLink::link_local_name(int i)const
98 ValueNode::LooseHandle h = get_link(i);
102 return h->get_local_name();
103 }else return String();
106 String ValueBaseLink::link_name(int i)const
108 ValueNode::LooseHandle h = get_link(i);
112 return h->get_name();
113 }else return String();
116 int ValueBaseLink::get_link_index_from_name(const String &name)const
118 throw Exception::BadLinkName(name);
121 //list management stuff
122 ValueBaseLink::list_type::const_iterator ValueBaseLink::findlink(ValueNode::Handle x) const
124 for(list_type::const_iterator i = list.begin(); i != list.end(); ++i)
134 ValueBaseLink::list_type::iterator ValueBaseLink::findlink(ValueNode::Handle x)
136 for(list_type::iterator i = list.begin(); i != list.end(); ++i)
147 void ValueBaseLink::add(ValueNode::Handle v)
149 list_type::iterator i = findlink(v);
157 void ValueBaseLink::remove(ValueNode::Handle v)
159 list_type::iterator i = findlink(v);
163 if(i != list.end()-1)