Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_03 / synfig-core / src / synfig / valuenode_reference.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file valuenode_reference.cpp
3 **      \brief Template File
4 **
5 **      $Id: valuenode_reference.cpp,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., 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 "valuenode_reference.h"
33 #include "valuenode_const.h"
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 /* === M A C R O S ========================================================= */
45
46 /* === G L O B A L S ======================================================= */
47
48 /* === P R O C E D U R E S ================================================= */
49
50 /* === M E T H O D S ======================================================= */
51
52 ValueNode_Reference::ValueNode_Reference(const ValueBase::Type &x):
53         LinkableValueNode(x)
54 {
55 }
56
57 ValueNode_Reference::ValueNode_Reference(const ValueNode::Handle &x):
58         LinkableValueNode(x->get_type())
59 {
60         set_link("link",x);
61 }
62
63 ValueNode_Reference*
64 ValueNode_Reference::create(const ValueBase &x)
65 {
66         return new ValueNode_Reference(ValueNode_Const::create(x));
67 }
68
69 LinkableValueNode*
70 ValueNode_Reference::create_new()const
71 {
72         return new ValueNode_Reference(get_type());
73 }
74
75 ValueNode_Reference::~ValueNode_Reference()
76 {
77         unlink_all();
78 }
79
80 bool
81 ValueNode_Reference::set_link_vfunc(int i,ValueNode::Handle x)
82 {
83         assert(i==0);
84         if(x->get_type()!=get_type() && !PlaceholderValueNode::Handle::cast_dynamic(x))
85                 return false;
86         link_=x;
87         signal_child_changed()(i);signal_value_changed()();
88         return true;
89 }
90         
91 ValueNode::LooseHandle
92 ValueNode_Reference::get_link_vfunc(int i)const
93 {
94         assert(i==0);
95         return link_;
96 }
97
98 int
99 ValueNode_Reference::link_count()const
100 {
101         return 1;
102 }
103
104 String
105 ValueNode_Reference::link_local_name(int i)const
106 {
107         assert(i==0);
108         return _("Link");
109 }       
110
111 String
112 ValueNode_Reference::link_name(int i)const
113 {
114         return "link";
115 }
116
117 int
118 ValueNode_Reference::get_link_index_from_name(const String &name)const
119 {
120         if(name=="link")
121                 return 0;
122
123         throw Exception::BadLinkName(name);
124 }
125
126 ValueBase
127 ValueNode_Reference::operator()(Time t)const
128 {
129         return (*link_)(t);
130 }
131
132
133 String
134 ValueNode_Reference::get_name()const
135 {
136         return "reference";
137 }
138
139 String
140 ValueNode_Reference::get_local_name()const
141 {
142         return _("Reference");
143 }
144
145 bool
146 ValueNode_Reference::check_type(ValueBase::Type type)
147 {
148         if(type)
149                 return true;
150         return false;
151 }