1 /* === S Y N F I G ========================================================= */
2 /*! \file action_param.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., 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 "action_param.h"
34 #include "canvasinterface.h"
42 using namespace synfig;
43 using namespace synfigapp;
44 using namespace Action;
46 /* === P R O C E D U R E S ================================================= */
49 Action::candidate_check(const ParamVocab& param_vocab, const ParamList& param_list)
51 ParamVocab::const_iterator iter;
53 for(iter=param_vocab.begin();iter!=param_vocab.end();++iter)
55 int n(param_list.count(iter->get_name()));
57 // if(n && !iter->get_mutual_exclusion().empty() && param_list.count(iter->get_mutual_exclusion()))
60 if(!n && !iter->get_mutual_exclusion().empty() && param_list.count(iter->get_mutual_exclusion()))
63 if(iter->get_user_supplied() || iter->get_optional())
68 if(n==1 && iter->get_requires_multiple())
70 if(n>1 && !iter->get_supports_multiple())
73 if(iter->get_type()!=param_list.find(iter->get_name())->second.get_type())
79 /* === S T A T I C S ======================================================= */
87 synfig::error("%d action params not yet deleted!",counter);
91 int _ParamCounter::counter(0);
93 /* === M E T H O D S ======================================================= */
95 Param::Param(const Param &rhs):
98 _ParamCounter::counter++;
101 case TYPE_ACTIVEPOINT:
102 data.activepoint.construct();
103 data.activepoint.get()=rhs.data.activepoint.get();
106 data.waypoint.construct();
107 data.waypoint.get()=rhs.data.waypoint.get();
109 case TYPE_WAYPOINTMODEL:
110 data.waypoint_model.construct();
111 data.waypoint_model.get()=rhs.data.waypoint_model.get();
114 data.keyframe.construct();
115 data.keyframe.get()=rhs.data.keyframe.get();
118 data.canvas.construct();
119 data.canvas.get()=rhs.data.canvas.get();
121 case TYPE_CANVASINTERFACE:
122 data.canvas_interface.construct();
123 data.canvas_interface.get()=rhs.data.canvas_interface.get();
126 data.layer.construct();
127 data.layer.get()=rhs.data.layer.get();
130 data.value_node.construct();
131 data.value_node.get()=rhs.data.value_node.get();
134 data.value_desc.construct();
135 data.value_desc.get()=rhs.data.value_desc.get();
138 data.value.construct();
139 data.value.get()=rhs.data.value.get();
142 data.string.construct();
143 data.string.get()=rhs.data.string.get();
146 data.rend_desc.construct();
147 data.rend_desc.get()=rhs.data.rend_desc.get();
150 data.time.construct();
151 data.time.get()=rhs.data.time.get();
155 data.integer=rhs.data.integer;
158 data.edit_mode=rhs.data.edit_mode;
161 data.real=rhs.data.real;
176 Param::Param(const etl::handle<synfigapp::CanvasInterface>& x):
178 type_(TYPE_CANVASINTERFACE)
180 _ParamCounter::counter++;
181 data.canvas_interface.construct();
182 data.canvas_interface.get()=x;
186 Param::Param(synfigapp::CanvasInterface* x):
188 type_(TYPE_CANVASINTERFACE)
190 _ParamCounter::counter++;
191 data.canvas_interface.construct();
192 data.canvas_interface=x;
196 Param::Param(const etl::loose_handle<synfigapp::CanvasInterface>& x):
198 type_(TYPE_CANVASINTERFACE)
200 _ParamCounter::counter++;
201 data.canvas_interface.construct();
202 data.canvas_interface.get()=x;
205 Param::Param(const synfig::Canvas::Handle& x):
208 _ParamCounter::counter++;
209 data.canvas.construct();
213 Param::Param(const synfig::Canvas::LooseHandle& x):
216 _ParamCounter::counter++;
217 data.canvas.construct();
221 Param::Param(const synfig::Layer::Handle& x):
225 _ParamCounter::counter++;
226 data.layer.construct();
230 Param::Param(const synfig::Layer::LooseHandle& x):
234 _ParamCounter::counter++;
235 data.layer.construct();
239 Param::Param(const synfig::ValueNode::Handle& x):
241 type_(TYPE_VALUENODE)
243 _ParamCounter::counter++;
244 data.value_node.construct();
245 data.value_node.get()=x;
248 Param::Param(const synfig::ValueNode::LooseHandle& x):
250 type_(TYPE_VALUENODE)
252 _ParamCounter::counter++;
253 data.value_node.construct();
254 data.value_node.get()=x;
257 Param::Param(const synfig::ValueBase& x):
261 _ParamCounter::counter++;
262 data.value.construct();
266 Param::Param(const synfig::RendDesc& x):
269 _ParamCounter::counter++;
270 data.rend_desc.construct();
271 data.rend_desc.get()=x;
274 Param::Param(const synfig::Time& x):
277 _ParamCounter::counter++;
278 data.time.construct();
282 Param::Param(const synfig::Activepoint& x):
284 type_(TYPE_ACTIVEPOINT)
286 _ParamCounter::counter++;
287 data.activepoint.construct();
288 data.activepoint.get()=x;
291 Param::Param(const synfig::Waypoint& x):
294 _ParamCounter::counter++;
295 data.waypoint.construct();
296 data.waypoint.get()=x;
299 Param::Param(const synfig::Waypoint::Model& x):
300 type_(TYPE_WAYPOINTMODEL)
302 _ParamCounter::counter++;
303 data.waypoint_model.construct();
304 data.waypoint_model.get()=x;
307 Param::Param(const synfig::String& x):
310 _ParamCounter::counter++;
311 data.string.construct();
315 Param::Param(const char * x):
318 _ParamCounter::counter++;
319 data.string.construct();
323 Param::Param(const synfig::Keyframe& x):
327 _ParamCounter::counter++;
328 data.keyframe.construct();
329 data.keyframe.get()=x;
332 Param::Param(const synfigapp::ValueDesc& x):
334 type_(TYPE_VALUEDESC)
336 _ParamCounter::counter++;
337 data.value_desc.construct();
338 data.value_desc.get()=x;
341 Param::Param(const int& x):
344 _ParamCounter::counter++;
348 Param::Param(const EditMode& x):
351 _ParamCounter::counter++;
355 Param::Param(const synfig::Real& x):
359 _ParamCounter::counter++;
363 Param::Param(const bool& x):
367 _ParamCounter::counter++;
374 _ParamCounter::counter--;
378 Param::operator=(const Param& rhs)
385 case TYPE_ACTIVEPOINT:
386 data.activepoint.construct();
387 data.activepoint.get()=rhs.data.activepoint.get();
390 data.waypoint.construct();
391 data.waypoint.get()=rhs.data.waypoint.get();
393 case TYPE_WAYPOINTMODEL:
394 data.waypoint_model.construct();
395 data.waypoint_model.get()=rhs.data.waypoint_model.get();
398 data.keyframe.construct();
399 data.keyframe.get()=rhs.data.keyframe.get();
402 data.canvas.construct();
403 data.canvas.get()=rhs.data.canvas.get();
405 case TYPE_CANVASINTERFACE:
406 data.canvas_interface.construct();
407 data.canvas_interface.get()=rhs.data.canvas_interface.get();
410 data.time.construct();
411 data.time.get()=rhs.data.time.get();
414 data.layer.construct();
415 data.layer.get()=rhs.data.layer.get();
418 data.value_node.construct();
419 data.value_node.get()=rhs.data.value_node.get();
422 data.value_desc.construct();
423 data.value_desc.get()=rhs.data.value_desc.get();
426 data.value.construct();
427 data.value.get()=rhs.data.value.get();
430 data.rend_desc.construct();
431 data.rend_desc.get()=rhs.data.rend_desc.get();
434 data.string.construct();
435 data.string.get()=rhs.data.string.get();
439 data.integer=rhs.data.integer;
442 data.integer=rhs.data.integer;
445 data.real=rhs.data.real;
466 case TYPE_ACTIVEPOINT:
467 data.activepoint.destruct();
470 data.waypoint.destruct();
472 case TYPE_WAYPOINTMODEL:
473 data.waypoint_model.destruct();
476 data.keyframe.destruct();
479 data.canvas.destruct();
481 case TYPE_CANVASINTERFACE:
482 data.canvas_interface.destruct();
485 data.layer.destruct();
488 data.time.destruct();
491 data.value_node.destruct();
494 data.value_desc.destruct();
497 data.value.destruct();
500 data.rend_desc.destruct();
503 data.string.destruct();