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
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 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_APP_ACTION_PARAM_H
26 #define __SYNFIG_APP_ACTION_PARAM_H
28 /* === H E A D E R S ======================================================= */
30 #include <synfig/string.h>
31 #include <synfig/canvas.h>
33 #include <ETL/stringf>
34 #include <ETL/trivial>
39 #include <synfig/layer.h>
40 #include <synfig/canvas.h>
41 #include <synfig/valuenode.h>
42 #include <synfigapp/value_desc.h>
43 #include <synfig/value.h>
44 #include <synfig/activepoint.h>
45 #include <synfig/valuenode_animated.h>
46 #include <synfig/string.h>
47 #include <synfig/keyframe.h>
48 #include <synfig/waypoint.h>
52 /* === M A C R O S ========================================================= */
54 /* === T Y P E D E F S ===================================================== */
56 /* === C L A S S E S & S T R U C T S ======================================= */
59 class ProgressCallback;
62 }; // END of namespace synfig
66 class CanvasInterface;
102 etl::trivial<synfig::Canvas::LooseHandle> canvas;
103 etl::trivial<synfig::Layer::LooseHandle> layer;
104 etl::trivial<synfig::ValueNode::LooseHandle> value_node;
105 etl::trivial<synfig::ValueBase> value;
106 etl::trivial<synfig::Activepoint> activepoint;
107 etl::trivial<synfig::ValueNode_Animated::Waypoint> waypoint;
108 etl::trivial<synfig::ValueNode_Animated::Waypoint::Model> waypoint_model;
109 etl::trivial<synfig::String> string;
110 etl::trivial<synfig::Keyframe> keyframe;
111 etl::trivial<synfig::Time> time;
112 etl::trivial<synfigapp::ValueDesc> value_desc;
113 etl::trivial<etl::loose_handle<synfigapp::CanvasInterface> > canvas_interface;
114 etl::trivial<synfig::RendDesc> rend_desc;
123 Param():type_(TYPE_NIL) { }
124 Param(const Param &x);
125 Param(const etl::handle<synfigapp::CanvasInterface>& x);
126 Param(const etl::loose_handle<synfigapp::CanvasInterface>& x);
127 // Param(synfigapp::CanvasInterface* x);
128 Param(const synfig::Canvas::Handle& x);
129 Param(const synfig::Canvas::LooseHandle& x);
130 Param(const synfig::Layer::Handle& x);
131 Param(const synfig::Layer::LooseHandle& x);
132 Param(const synfig::ValueNode::Handle& x);
133 Param(const synfig::ValueNode::LooseHandle& x);
134 Param(const synfig::Activepoint& x);
135 Param(const synfig::Waypoint& x);
136 Param(const synfig::Waypoint::Model& x);
137 Param(const synfig::String& x);
138 Param(const synfig::RendDesc& x);
139 Param(const char * x);
140 Param(const synfig::Keyframe& x);
141 Param(const synfigapp::ValueDesc& x);
143 Param(const EditMode& x);
144 Param(const synfig::Real& x);
145 Param(const synfig::Time& x);
146 Param(const bool& x);
147 Param(const synfig::ValueBase& x);
151 Param& operator=(const Param& rhs);
155 const synfig::Canvas::LooseHandle& get_canvas()const { assert(type_==TYPE_CANVAS); return data.canvas.get(); }
156 const etl::loose_handle<synfigapp::CanvasInterface>& get_canvas_interface()const { assert(type_==TYPE_CANVASINTERFACE); return data.canvas_interface.get(); }
157 const synfig::Layer::LooseHandle& get_layer()const { assert(type_==TYPE_LAYER); return data.layer.get(); }
158 const synfig::ValueNode::LooseHandle& get_value_node()const { assert(type_==TYPE_VALUENODE); return data.value_node.get(); }
159 const synfig::ValueBase& get_value()const { assert(type_==TYPE_VALUE); return data.value.get(); }
160 const synfig::Activepoint& get_activepoint()const { assert(type_==TYPE_ACTIVEPOINT); return data.activepoint.get(); }
161 const synfig::Waypoint& get_waypoint()const { assert(type_==TYPE_WAYPOINT); return data.waypoint.get(); }
162 const synfig::Waypoint::Model& get_waypoint_model()const { assert(type_==TYPE_WAYPOINTMODEL); return data.waypoint_model.get(); }
163 const synfig::String& get_string()const { assert(type_==TYPE_STRING); return data.string.get(); }
164 const synfig::Keyframe& get_keyframe()const { assert(type_==TYPE_KEYFRAME); return data.keyframe.get(); }
165 const synfigapp::ValueDesc& get_value_desc()const { assert(type_==TYPE_VALUEDESC); return data.value_desc.get(); }
166 const synfig::Real& get_real()const { assert(type_==TYPE_REAL); return data.real; }
167 const synfig::Time& get_time()const { assert(type_==TYPE_TIME); return data.time.get(); }
168 const synfig::RendDesc& get_rend_desc()const { assert(type_==TYPE_RENDDESC); return data.rend_desc.get(); }
169 int get_integer()const { assert(type_==TYPE_INTEGER); return data.integer; }
170 EditMode get_edit_mode()const { assert(type_==TYPE_EDITMODE); return data.edit_mode; }
171 bool get_bool()const { assert(type_==TYPE_BOOL); return data.b; }
174 const Type& get_type()const { return type_; }
175 }; // END of class Param
177 class ParamList : public std::multimap<synfig::String,Param>
180 ParamList& add(const synfig::String& name, const Param &x) { insert(std::pair<synfig::String,Param>(name,x)); return *this; }
181 ParamList& add(const ParamList& x) { insert(x.begin(),x.end()); return *this; }
182 }; // END of class ParamList
187 synfig::String name_;
188 synfig::String local_name_;
189 synfig::String desc_;
190 synfig::String mutual_exclusion_;
193 bool supports_multiple_;
194 bool requires_multiple_;
198 ParamDesc(const synfig::String &name, Param::Type type):
202 user_supplied_(false),
203 supports_multiple_(false),
204 requires_multiple_(false),
208 const synfig::String& get_name()const { return name_; }
209 const synfig::String& get_desc()const { return desc_; }
210 const synfig::String& get_mutual_exclusion()const { return mutual_exclusion_; }
211 const synfig::String& get_local_name()const { return local_name_; }
212 const Param::Type& get_type()const { return type_; }
213 bool get_user_supplied()const { return user_supplied_; }
214 bool get_supports_multiple()const { return supports_multiple_||requires_multiple_; }
215 bool get_requires_multiple()const { return requires_multiple_; }
216 bool get_optional()const { return optional_; }
218 ParamDesc& set_local_name(const synfig::String& x) { local_name_=x; return *this; }
219 ParamDesc& set_desc(const synfig::String& x) { desc_=x; return *this; }
220 ParamDesc& set_mutual_exclusion(const synfig::String& x) { mutual_exclusion_=x; return *this; }
221 ParamDesc& set_user_supplied(bool x=true) { user_supplied_=x; return *this; }
222 ParamDesc& set_supports_multiple(bool x=true) { supports_multiple_=x; return *this; }
223 ParamDesc& set_requires_multiple(bool x=true) { requires_multiple_=x; if(x)supports_multiple_=true; return *this; }
224 ParamDesc& set_optional(bool x=true) { optional_=x; return *this; }
225 }; // END of class ParamDesc
227 class ParamVocab : public std::list< ParamDesc > { };
229 bool candidate_check(const ParamVocab& param_vocab, const ParamList& param_list);
231 }; // END of namespace Action
233 }; // END of namespace synfigapp
235 /* === E N D =============================================================== */