- Main Page
- Related Pages
- Namespaces
- Classes
- Files

# action_param.h

Go to the documentation of this file.

    00001 /* === S Y N F I G ========================================================= */
    00022 /* ========================================================================= */
    00023
    00024 /* === S T A R T =========================================================== */
    00025
    00026 #ifndef __SYNFIG_APP_ACTION_PARAM_H
    00027 #define __SYNFIG_APP_ACTION_PARAM_H
    00028
    00029 /* === H E A D E R S ======================================================= */
    00030
    00031 #include <synfig/string.h>
    00032 #include <synfig/canvas.h>
    00033 #include <ETL/handle>
    00034 #include <ETL/stringf>
    00035 #include <ETL/trivial>
    00036
    00037 #include <map>
    00038 #include <list>
    00039
    00040 #include <synfig/layer.h>
    00041 #include <synfig/canvas.h>
    00042 #include <synfig/valuenode.h>
    00043 #include <synfigapp/value_desc.h>
    00044 #include <synfig/value.h>
    00045 #include <synfig/activepoint.h>
    00046 #include <synfig/valuenode_animated.h>
    00047 #include <synfig/string.h>
    00048 #include <synfig/keyframe.h>
    00049 #include <synfig/waypoint.h>
    00050
    00051 #include "editmode.h"
    00052
    00053 /* === M A C R O S ========================================================= */
    00054
    00055 /* === T Y P E D E F S ===================================================== */
    00056
    00057 /* === C L A S S E S & S T R U C T S ======================================= */
    00058
    00059 namespace synfig {
    00060 class ProgressCallback;
    00061 class Canvas;
    00062 class RendDesc;
    00063 }; // END of namespace synfig
    00064
    00065 namespace synfigapp {
    00066
    00067 class CanvasInterface;
    00068
    00069 namespace Action {
    00070
    00072 class Param
    00073 {
    00074 public:
    00075     enum Type
    00076     {
    00077         TYPE_NIL,               // 0
    00078         TYPE_INTEGER,
    00079         TYPE_REAL,
    00080         TYPE_BOOL,
    00081         TYPE_ACTIVEPOINT,       // 4
    00082         TYPE_WAYPOINT,
    00083         TYPE_WAYPOINTMODEL,
    00084         TYPE_KEYFRAME,
    00085         TYPE_CANVAS,            // 8
    00086         TYPE_LAYER,
    00087         TYPE_VALUENODE,
    00088         TYPE_VALUEDESC,
    00089         TYPE_VALUE,             // 12
    00090         TYPE_STRING,
    00091         TYPE_TIME,
    00092         TYPE_CANVASINTERFACE,
    00093         TYPE_EDITMODE,          // 16
    00094         TYPE_RENDDESC,
    00095
    00096         TYPE_END                // 18
    00097     };
    00098 private:
    00099     Type type_;
    00100
    00101     union
    00102     {
    00103         etl::trivial<synfig::Canvas::LooseHandle> canvas;
    00104         etl::trivial<synfig::Layer::LooseHandle> layer;
    00105         etl::trivial<synfig::ValueNode::LooseHandle> value_node;
    00106         etl::trivial<synfig::ValueBase> value;
    00107         etl::trivial<synfig::Activepoint> activepoint;
    00108         etl::trivial<synfig::ValueNode_Animated::Waypoint> waypoint;
    00109         etl::trivial<synfig::ValueNode_Animated::Waypoint::Model> waypoint_model;
    00110         etl::trivial<synfig::String> string;
    00111         etl::trivial<synfig::Keyframe> keyframe;
    00112         etl::trivial<synfig::Time> time;
    00113         etl::trivial<synfigapp::ValueDesc> value_desc;
    00114         etl::trivial<etl::loose_handle<synfigapp::CanvasInterface> > canvas_interface;
    00115         etl::trivial<synfig::RendDesc> rend_desc;
    00116         int integer;
    00117         synfig::Real real;
    00118         bool b;
    00119         EditMode edit_mode;
    00120
    00121     } data;
    00122 public:
    00123
    00124     Param():type_(TYPE_NIL) { }
    00125     Param(const Param &x);
    00126     Param(const etl::handle<synfigapp::CanvasInterface>& x);
    00127     Param(const etl::loose_handle<synfigapp::CanvasInterface>& x);
    00128 //  Param(synfigapp::CanvasInterface* x);
    00129     Param(const synfig::Canvas::Handle& x);
    00130     Param(const synfig::Canvas::LooseHandle& x);
    00131     Param(const synfig::Layer::Handle& x);
    00132     Param(const synfig::Layer::LooseHandle& x);
    00133     Param(const synfig::ValueNode::Handle& x);
    00134     Param(const synfig::ValueNode::LooseHandle& x);
    00135     Param(const synfig::Activepoint& x);
    00136     Param(const synfig::Waypoint& x);
    00137     Param(const synfig::Waypoint::Model& x);
    00138     Param(const synfig::String& x);
    00139     Param(const synfig::RendDesc& x);
    00140     Param(const char * x);
    00141     Param(const synfig::Keyframe& x);
    00142     Param(const synfigapp::ValueDesc& x);
    00143     Param(const int& x);
    00144     Param(const EditMode& x);
    00145     Param(const synfig::Real& x);
    00146     Param(const synfig::Time& x);
    00147     Param(const bool& x);
    00148     Param(const synfig::ValueBase& x);
    00149
    00150     ~Param();
    00151
    00152     Param& operator=(const Param& rhs);
    00153
    00154     void clear();
    00155
    00156     const synfig::Canvas::LooseHandle& get_canvas()const { assert(type_==TYPE_CANVAS); return data.canvas.get(); }
    00157     const etl::loose_handle<synfigapp::CanvasInterface>& get_canvas_interface()const { assert(type_==TYPE_CANVASINTERFACE); return data.canvas_interface.get(); }
    00158     const synfig::Layer::LooseHandle& get_layer()const { assert(type_==TYPE_LAYER); return data.layer.get(); }
    00159     const synfig::ValueNode::LooseHandle& get_value_node()const { assert(type_==TYPE_VALUENODE); return data.value_node.get(); }
    00160     const synfig::ValueBase& get_value()const { assert(type_==TYPE_VALUE); return data.value.get(); }
    00161     const synfig::Activepoint& get_activepoint()const { assert(type_==TYPE_ACTIVEPOINT); return data.activepoint.get(); }
    00162     const synfig::Waypoint& get_waypoint()const { assert(type_==TYPE_WAYPOINT); return data.waypoint.get(); }
    00163     const synfig::Waypoint::Model& get_waypoint_model()const { assert(type_==TYPE_WAYPOINTMODEL); return data.waypoint_model.get(); }
    00164     const synfig::String& get_string()const { assert(type_==TYPE_STRING); return data.string.get(); }
    00165     const synfig::Keyframe& get_keyframe()const { assert(type_==TYPE_KEYFRAME); return data.keyframe.get(); }
    00166     const synfigapp::ValueDesc& get_value_desc()const { assert(type_==TYPE_VALUEDESC); return data.value_desc.get(); }
    00167     const synfig::Real& get_real()const { assert(type_==TYPE_REAL); return data.real; }
    00168     const synfig::Time& get_time()const { assert(type_==TYPE_TIME); return data.time.get(); }
    00169     const synfig::RendDesc& get_rend_desc()const { assert(type_==TYPE_RENDDESC); return data.rend_desc.get(); }
    00170     int get_integer()const { assert(type_==TYPE_INTEGER); return data.integer; }
    00171     EditMode get_edit_mode()const { assert(type_==TYPE_EDITMODE); return data.edit_mode; }
    00172     bool get_bool()const { assert(type_==TYPE_BOOL); return data.b; }
    00173
    00174
    00175     const Type& get_type()const { return type_; }
    00176 }; // END of class Param
    00177
    00178 class ParamList : public std::multimap<synfig::String,Param>
    00179 {
    00180 public:
    00181     ParamList& add(const synfig::String& name, const Param &x) { insert(std::pair<synfig::String,Param>(name,x)); return *this; }
    00182     ParamList& add(const ParamList& x) { insert(x.begin(),x.end()); return *this; }
    00183 }; // END of class ParamList
    00184
    00185 class ParamDesc
    00186 {
    00187 private:
    00188     synfig::String  name_;
    00189     synfig::String  local_name_;
    00190     synfig::String  desc_;
    00191     synfig::String  mutual_exclusion_;
    00192     Param::Type type_;
    00193     bool    user_supplied_;
    00194     bool    supports_multiple_;
    00195     bool    requires_multiple_;
    00196     bool    optional_;
    00197
    00198 public:
    00199     ParamDesc(const synfig::String &name, Param::Type type):
    00200         name_(name),
    00201         local_name_(name),
    00202         type_(type),
    00203         user_supplied_(false),
    00204         supports_multiple_(false),
    00205         requires_multiple_(false),
    00206         optional_(false)
    00207     { }
    00208
    00209     const synfig::String& get_name()const { return name_; }
    00210     const synfig::String& get_desc()const { return desc_; }
    00211     const synfig::String& get_mutual_exclusion()const { return mutual_exclusion_; }
    00212     const synfig::String& get_local_name()const { return local_name_; }
    00213     const Param::Type& get_type()const { return type_; }
    00214     bool get_user_supplied()const { return user_supplied_; }
    00215     bool get_supports_multiple()const { return supports_multiple_||requires_multiple_; }
    00216     bool get_requires_multiple()const { return requires_multiple_; }
    00217     bool get_optional()const { return optional_; }
    00218
    00219     ParamDesc& set_local_name(const synfig::String& x) { local_name_=x; return *this; }
    00220     ParamDesc& set_desc(const synfig::String& x) { desc_=x; return *this; }
    00221     ParamDesc& set_mutual_exclusion(const synfig::String& x) { mutual_exclusion_=x; return *this; }
    00222     ParamDesc& set_user_supplied(bool x=true) { user_supplied_=x; return *this; }
    00223     ParamDesc& set_supports_multiple(bool x=true) { supports_multiple_=x; return *this; }
    00224     ParamDesc& set_requires_multiple(bool x=true) { requires_multiple_=x; if(x)supports_multiple_=true; return *this; }
    00225     ParamDesc& set_optional(bool x=true) { optional_=x; return *this; }
    00226 }; // END of class ParamDesc
    00227
    00228 class ParamVocab : public std::list< ParamDesc > { };
    00229
    00230 bool candidate_check(const ParamVocab& param_vocab, const ParamList& param_list);
    00231
    00232 }; // END of namespace Action
    00233
    00234 }; // END of namespace synfigapp
    00235
    00236 /* === E N D =============================================================== */
    00237
    00238 #endif