1 /* === S I N F G =========================================================== */
2 /*! \file valuenodelinkdisconnect.cpp
3 ** \brief Template File
5 ** $Id: valuenodelinkdisconnect.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
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.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "valuenodelinkdisconnect.h"
32 #include <sinfgapp/canvasinterface.h>
33 #include <sinfg/valuenode_const.h>
39 using namespace sinfg;
40 using namespace sinfgapp;
41 using namespace Action;
43 /* === M A C R O S ========================================================= */
45 ACTION_INIT(Action::ValueNodeLinkDisconnect);
46 ACTION_SET_NAME(Action::ValueNodeLinkDisconnect,"value_node_link_disconnect");
47 ACTION_SET_LOCAL_NAME(Action::ValueNodeLinkDisconnect,_("Disconnect ValueNode Link"));
48 ACTION_SET_TASK(Action::ValueNodeLinkDisconnect,"disconnect");
49 ACTION_SET_CATEGORY(Action::ValueNodeLinkDisconnect,Action::CATEGORY_VALUENODE);
50 ACTION_SET_PRIORITY(Action::ValueNodeLinkDisconnect,0);
51 ACTION_SET_VERSION(Action::ValueNodeLinkDisconnect,"0.0");
52 ACTION_SET_CVS_ID(Action::ValueNodeLinkDisconnect,"$Id: valuenodelinkdisconnect.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
54 /* === G L O B A L S ======================================================= */
56 /* === P R O C E D U R E S ================================================= */
58 /* === M E T H O D S ======================================================= */
60 Action::ValueNodeLinkDisconnect::ValueNodeLinkDisconnect():
61 index(-1), // Initially set it to negative one so that we know when it has changed
67 Action::ValueNodeLinkDisconnect::get_param_vocab()
69 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
71 ret.push_back(ParamDesc("parent_value_node",Param::TYPE_VALUENODE)
72 .set_local_name(_("Parent ValueNode"))
75 ret.push_back(ParamDesc("index",Param::TYPE_INTEGER)
76 .set_local_name(_("Index"))
79 ret.push_back(ParamDesc("time",Param::TYPE_TIME)
80 .set_local_name(_("Time"))
88 Action::ValueNodeLinkDisconnect::is_canidate(const ParamList &x)
90 return canidate_check(get_param_vocab(),x);
94 Action::ValueNodeLinkDisconnect::set_param(const sinfg::String& name, const Action::Param ¶m)
96 if(name=="parent_value_node" && param.get_type()==Param::TYPE_VALUENODE)
98 parent_value_node=LinkableValueNode::Handle::cast_dynamic(param.get_value_node());
100 return static_cast<bool>(parent_value_node);
103 if(name=="index" && param.get_type()==Param::TYPE_INTEGER)
105 index=param.get_integer();
110 if(name=="time" && param.get_type()==Param::TYPE_TIME)
112 time=param.get_time();
117 return Action::CanvasSpecific::set_param(name,param);
121 Action::ValueNodeLinkDisconnect::is_ready()const
123 if(!parent_value_node || index==-1)
125 return Action::CanvasSpecific::is_ready();
129 Action::ValueNodeLinkDisconnect::perform()
131 if(parent_value_node->link_count()<=index)
132 throw Error(_("Bad index, too big. LinkCount=%d, Index=%d"),parent_value_node->link_count(),index);
134 old_value_node=parent_value_node->get_link(index);
136 if(!parent_value_node->set_link(index,ValueNode_Const::create((*old_value_node)(time))))
137 throw Error(_("Parent would not accept link"));
140 if(get_canvas()->get_time()!=time)
145 if(get_canvas_interface())
147 get_canvas_interface()->signal_value_node_changed()(parent_value_node);
153 Action::ValueNodeLinkDisconnect::undo()
155 if(parent_value_node->link_count()<=index)
156 throw Error(_("Bad index, too big. LinkCount=%d, Index=%d"),parent_value_node->link_count(),index);
158 if(!parent_value_node->set_link(index,old_value_node))
159 throw Error(_("Parent would not accept old link"));
161 /*if(get_canvas()->get_time()!=time)
166 if(get_canvas_interface())
168 get_canvas_interface()->signal_value_node_changed()(parent_value_node);