1 // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html
2 
3 #ifndef SPECTMORPH_MORPH_OPERATOR_HH
4 #define SPECTMORPH_MORPH_OPERATOR_HH
5 
6 #include "smoutfile.hh"
7 #include "sminfile.hh"
8 #include "smsignal.hh"
9 
10 #include <map>
11 
12 namespace SpectMorph
13 {
14 
15 class MorphOperatorView;
16 class MorphPlan;
17 
18 class MorphOperator : public SignalReceiver
19 {
20 protected:
21   MorphPlan  *m_morph_plan;
22   std::string m_name;
23   std::string m_id;
24   bool        m_folded;
25 
26   typedef std::map<std::string, MorphOperator *> OpNameMap;
27 
28   void write_operator (OutFile& file, const std::string& name, MorphOperator *op);
29 
30 public:
31   enum OutputType {
32     OUTPUT_NONE,
33     OUTPUT_AUDIO,
34     OUTPUT_CONTROL
35   };
36   enum ControlType {
37     CONTROL_GUI      = 1,
38     CONTROL_SIGNAL_1 = 2,
39     CONTROL_SIGNAL_2 = 3,
40     CONTROL_OP       = 4,
41 
42     /* note: don't reorder items here, as we need to be compatible with old files */
43     CONTROL_SIGNAL_3 = 5,
44     CONTROL_SIGNAL_4 = 6
45   };
46   MorphOperator (MorphPlan *morph_plan);
47   virtual ~MorphOperator();
48 
49   virtual const char *type() = 0;
50   virtual int  insert_order() = 0;
51   virtual bool save (OutFile& out_file) = 0;
52   virtual bool load (InFile& in_file) = 0;
53   virtual void post_load (OpNameMap& op_name_map);
54   virtual OutputType output_type() = 0;
55   virtual std::vector<MorphOperator *> dependencies();
56 
57   MorphPlan *morph_plan();
58 
59   std::string type_name();
60 
61   std::string name();
62   void set_name (const std::string& name);
63 
64   bool can_rename (const std::string& name);
65 
66   std::string id();
67   void set_id (const std::string& id);
68 
69   bool folded() const;
70   void set_folded (bool folded);
71 
72   static MorphOperator *create (const std::string& type, MorphPlan *plan);
73 };
74 
75 }
76 
77 #endif
78