1 /* === S Y N F I G ========================================================= */
2 /*! \file action_param.h
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === S T A R T =========================================================== */
26 #ifndef __SYNFIG_APP_ACTION_PARAM_H
27 #define __SYNFIG_APP_ACTION_PARAM_H
29 /* === H E A D E R S ======================================================= */
31 #include <synfig/string.h>
32 #include <synfig/canvas.h>
34 #include <ETL/stringf>
35 #include <ETL/trivial>
40 #include <synfig/layer.h>
41 #include <synfig/canvas.h>
42 #include <synfig/valuenode.h>
43 #include <synfigapp/value_desc.h>
44 #include <synfig/value.h>
45 #include <synfig/activepoint.h>
46 #include <synfig/valuenode_animated.h>
47 #include <synfig/string.h>
48 #include <synfig/keyframe.h>
49 #include <synfig/waypoint.h>
53 /* === M A C R O S ========================================================= */
55 /* === T Y P E D E F S ===================================================== */
57 /* === C L A S S E S & S T R U C T S ======================================= */
60 class ProgressCallback;
63 }; // END of namespace synfig
67 class CanvasInterface;
81 TYPE_ACTIVEPOINT, // 4
103 etl::trivial<synfig::Canvas::LooseHandle> canvas;
104 etl::trivial<synfig::Layer::LooseHandle> layer;
105 etl::trivial<synfig::ValueNode::LooseHandle> value_node;
106 etl::trivial<synfig::ValueBase> value;
107 etl::trivial<synfig::Activepoint> activepoint;
108 etl::trivial<synfig::ValueNode_Animated::Waypoint> waypoint;
109 etl::trivial<synfig::ValueNode_Animated::Waypoint::Model> waypoint_model;
110 etl::trivial<synfig::String> string;
111 etl::trivial<synfig::Keyframe> keyframe;
112 etl::trivial<synfig::Time> time;
113 etl::trivial<synfigapp::ValueDesc> value_desc;
114 etl::trivial<etl::loose_handle<synfigapp::CanvasInterface> > canvas_interface;
115 etl::trivial<synfig::RendDesc> rend_desc;
124 Param():type_(TYPE_NIL) { }
125 Param(const Param &x);
126 Param(const etl::handle<synfigapp::CanvasInterface>& x);
127 Param(const etl::loose_handle<synfigapp::CanvasInterface>& x);
128 // Param(synfigapp::CanvasInterface* x);
129 Param(const synfig::Canvas::Handle& x);
130 Param(const synfig::Canvas::LooseHandle& x);
131 Param(const synfig::Layer::Handle& x);
132 Param(const synfig::Layer::LooseHandle& x);
133 Param(const synfig::ValueNode::Handle& x);
134 Param(const synfig::ValueNode::LooseHandle& x);
135 Param(const synfig::Activepoint& x);
136 Param(const synfig::Waypoint& x);
137 Param(const synfig::Waypoint::Model& x);
138 Param(const synfig::String& x);
139 Param(const synfig::RendDesc& x);
140 Param(const char * x);
141 Param(const synfig::Keyframe& x);
142 Param(const synfigapp::ValueDesc& x);
144 Param(const EditMode& x);
145 Param(const synfig::Real& x);
146 Param(const synfig::Time& x);
147 Param(const bool& x);
148 Param(const synfig::ValueBase& x);
152 Param& operator=(const Param& rhs);
156 const synfig::Canvas::LooseHandle& get_canvas()const { assert(type_==TYPE_CANVAS); return data.canvas.get(); }
157 const etl::loose_handle<synfigapp::CanvasInterface>& get_canvas_interface()const { assert(type_==TYPE_CANVASINTERFACE); return data.canvas_interface.get(); }
158 const synfig::Layer::LooseHandle& get_layer()const { assert(type_==TYPE_LAYER); return data.layer.get(); }
159 const synfig::ValueNode::LooseHandle& get_value_node()const { assert(type_==TYPE_VALUENODE); return data.value_node.get(); }
160 const synfig::ValueBase& get_value()const { assert(type_==TYPE_VALUE); return data.value.get(); }
161 const synfig::Activepoint& get_activepoint()const { assert(type_==TYPE_ACTIVEPOINT); return data.activepoint.get(); }
162 const synfig::Waypoint& get_waypoint()const { assert(type_==TYPE_WAYPOINT); return data.waypoint.get(); }
163 const synfig::Waypoint::Model& get_waypoint_model()const { assert(type_==TYPE_WAYPOINTMODEL); return data.waypoint_model.get(); }
164 const synfig::String& get_string()const { assert(type_==TYPE_STRING); return data.string.get(); }
165 const synfig::Keyframe& get_keyframe()const { assert(type_==TYPE_KEYFRAME); return data.keyframe.get(); }
166 const synfigapp::ValueDesc& get_value_desc()const { assert(type_==TYPE_VALUEDESC); return data.value_desc.get(); }
167 const synfig::Real& get_real()const { assert(type_==TYPE_REAL); return data.real; }
168 const synfig::Time& get_time()const { assert(type_==TYPE_TIME); return data.time.get(); }
169 const synfig::RendDesc& get_rend_desc()const { assert(type_==TYPE_RENDDESC); return data.rend_desc.get(); }
170 int get_integer()const { assert(type_==TYPE_INTEGER); return data.integer; }
171 EditMode get_edit_mode()const { assert(type_==TYPE_EDITMODE); return data.edit_mode; }
172 bool get_bool()const { assert(type_==TYPE_BOOL); return data.b; }
175 const Type& get_type()const { return type_; }
176 }; // END of class Param
178 class ParamList : public std::multimap<synfig::String,Param>
181 ParamList& add(const synfig::String& name, const Param &x) { insert(std::pair<synfig::String,Param>(name,x)); return *this; }
182 ParamList& add(const ParamList& x) { insert(x.begin(),x.end()); return *this; }
183 }; // END of class ParamList
188 synfig::String name_;
189 synfig::String local_name_;
190 synfig::String desc_;
191 synfig::String mutual_exclusion_;
194 bool supports_multiple_;
195 bool requires_multiple_;
199 ParamDesc(const synfig::String &name, Param::Type type):
203 user_supplied_(false),
204 supports_multiple_(false),
205 requires_multiple_(false),
209 const synfig::String& get_name()const { return name_; }
210 const synfig::String& get_desc()const { return desc_; }
211 const synfig::String& get_mutual_exclusion()const { return mutual_exclusion_; }
212 const synfig::String& get_local_name()const { return local_name_; }
213 const Param::Type& get_type()const { return type_; }
214 bool get_user_supplied()const { return user_supplied_; }
215 bool get_supports_multiple()const { return supports_multiple_||requires_multiple_; }
216 bool get_requires_multiple()const { return requires_multiple_; }
217 bool get_optional()const { return optional_; }
219 ParamDesc& set_local_name(const synfig::String& x) { local_name_=x; return *this; }
220 ParamDesc& set_desc(const synfig::String& x) { desc_=x; return *this; }
221 ParamDesc& set_mutual_exclusion(const synfig::String& x) { mutual_exclusion_=x; return *this; }
222 ParamDesc& set_user_supplied(bool x=true) { user_supplied_=x; return *this; }
223 ParamDesc& set_supports_multiple(bool x=true) { supports_multiple_=x; return *this; }
224 ParamDesc& set_requires_multiple(bool x=true) { requires_multiple_=x; if(x)supports_multiple_=true; return *this; }
225 ParamDesc& set_optional(bool x=true) { optional_=x; return *this; }
226 }; // END of class ParamDesc
228 class ParamVocab : public std::list< ParamDesc > { };
230 bool candidate_check(const ParamVocab& param_vocab, const ParamList& param_list);
232 }; // END of namespace Action
234 }; // END of namespace synfigapp
236 /* === E N D =============================================================== */