Mark classes that do not appear to be used
[synfig.git] / synfig-studio / src / gtkmm / valuelink.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file valuelink.cpp
3 **      \brief ValueBase Link Implementation File
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2004 Adrian Bentley
9 **
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.
14 **
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.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "valuelink.h"
33
34 #include "general.h"
35
36 #endif
37
38 /* === U S I N G =========================================================== */
39
40 using namespace std;
41 using namespace etl;
42 using namespace synfig;
43
44 using studio::ValueBaseLink;
45
46 /* === M A C R O S ========================================================= */
47
48 /* === G L O B A L S ======================================================= */
49
50 /* === P R O C E D U R E S ================================================= */
51
52 /* === M E T H O D S ======================================================= */
53
54 /* === E N T R Y P O I N T ================================================= */
55
56 //structors
57 ValueBaseLink::ValueBaseLink()
58 {
59         assert(0); //CHECK: This class does not appear to be used.
60 }
61
62 ValueBaseLink::~ValueBaseLink()
63 {
64 }
65
66 //link access
67
68 ValueNode::LooseHandle ValueBaseLink::get_link_vfunc(int i)const
69 {
70         /*list_type::const_iterator     it = list.begin();
71
72         while(it != list.end() && i-- > 0)
73         {
74                 ++it;
75         }
76
77         if(it == list.end())
78         {
79                 return ValueNode::LooseHandle();
80         }else
81         {
82                 return *it;
83         }*/
84         if(i >= 0 && i < (int)list.size())
85         {
86                 return list[i];
87         }else
88         {
89                 return ValueNode::LooseHandle();
90         }
91 }
92
93 //more link access
94 int ValueBaseLink::link_count()const
95 {
96         return list.size();
97 }
98
99 String ValueBaseLink::link_local_name(int i)const
100 {
101         ValueNode::LooseHandle h = get_link(i);
102
103         if(h)
104         {
105                 return h->get_local_name();
106         }else return String();
107 }
108
109 String ValueBaseLink::link_name(int i)const
110 {
111         ValueNode::LooseHandle h = get_link(i);
112
113         if(h)
114         {
115                 return h->get_name();
116         }else return String();
117 }
118
119 int ValueBaseLink::get_link_index_from_name(const synfig::String &name)const
120 {
121         throw Exception::BadLinkName(name);
122 }
123
124 //list management stuff
125 ValueBaseLink::list_type::const_iterator ValueBaseLink::findlink(synfig::ValueNode::Handle x) const
126 {
127         for(list_type::const_iterator i = list.begin(); i != list.end(); ++i)
128         {
129                 if(*i == x)
130                 {
131                         return i;
132                 }
133         }
134
135         return list.end();
136 }
137 ValueBaseLink::list_type::iterator ValueBaseLink::findlink(synfig::ValueNode::Handle x)
138 {
139         for(list_type::iterator i = list.begin(); i != list.end(); ++i)
140         {
141                 if(*i == x)
142                 {
143                         return i;
144                 }
145         }
146
147         return list.end();
148 }
149
150 void ValueBaseLink::add(synfig::ValueNode::Handle v)
151 {
152         list_type::iterator i = findlink(v);
153
154         if(i != list.end())
155         {
156                 list.push_back(v);
157         }
158 }
159
160 void ValueBaseLink::remove(synfig::ValueNode::Handle v)
161 {
162         list_type::iterator i = findlink(v);
163
164         if(i != list.end())
165         {
166                 if(i != list.end()-1)
167                 {
168                         *i = list.back();
169                 }
170                 list.pop_back();
171         }
172 }