moreupdates
[synfig.git] / synfig-core / trunk / 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 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === H E A D E R S ======================================================= */
23
24 #ifdef USING_PCH
25 #       include "pch.h"
26 #else
27 #ifdef HAVE_CONFIG_H
28 #       include <config.h>
29 #endif
30
31 #include "valuenode_reference.h"
32 #include "valuenode_const.h"
33 #include "general.h"
34
35 #endif
36
37 /* === U S I N G =========================================================== */
38
39 using namespace std;
40 using namespace etl;
41 using namespace synfig;
42
43 /* === M A C R O S ========================================================= */
44
45 /* === G L O B A L S ======================================================= */
46
47 /* === P R O C E D U R E S ================================================= */
48
49 /* === M E T H O D S ======================================================= */
50
51 ValueNode_Reference::ValueNode_Reference(const ValueBase::Type &x):
52         LinkableValueNode(x)
53 {
54 }
55
56 ValueNode_Reference::ValueNode_Reference(const ValueNode::Handle &x):
57         LinkableValueNode(x->get_type())
58 {
59         set_link("link",x);
60 }
61
62 ValueNode_Reference*
63 ValueNode_Reference::create(const ValueBase &x)
64 {
65         return new ValueNode_Reference(ValueNode_Const::create(x));
66 }
67
68 LinkableValueNode*
69 ValueNode_Reference::create_new()const
70 {
71         return new ValueNode_Reference(get_type());
72 }
73
74 ValueNode_Reference::~ValueNode_Reference()
75 {
76         unlink_all();
77 }
78
79 bool
80 ValueNode_Reference::set_link_vfunc(int i,ValueNode::Handle x)
81 {
82         assert(i==0);
83         if(x->get_type()!=get_type() && !PlaceholderValueNode::Handle::cast_dynamic(x))
84                 return false;
85         link_=x;
86         signal_child_changed()(i);signal_value_changed()();
87         return true;
88 }
89         
90 ValueNode::LooseHandle
91 ValueNode_Reference::get_link_vfunc(int i)const
92 {
93         assert(i==0);
94         return link_;
95 }
96
97 int
98 ValueNode_Reference::link_count()const
99 {
100         return 1;
101 }
102
103 String
104 ValueNode_Reference::link_local_name(int i)const
105 {
106         assert(i==0);
107         return _("Link");
108 }       
109
110 String
111 ValueNode_Reference::link_name(int i)const
112 {
113         return "link";
114 }
115
116 int
117 ValueNode_Reference::get_link_index_from_name(const String &name)const
118 {
119         if(name=="link")
120                 return 0;
121
122         throw Exception::BadLinkName(name);
123 }
124
125 ValueBase
126 ValueNode_Reference::operator()(Time t)const
127 {
128         return (*link_)(t);
129 }
130
131
132 String
133 ValueNode_Reference::get_name()const
134 {
135         return "reference";
136 }
137
138 String
139 ValueNode_Reference::get_local_name()const
140 {
141         return _("Reference");
142 }
143
144 bool
145 ValueNode_Reference::check_type(ValueBase::Type type)
146 {
147         if(type)
148                 return true;
149         return false;
150 }