SpectMorph
smmorphplan.hh
1 // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html
2 
3 #ifndef SPECTMORPH_MORPH_PLAN_HH
4 #define SPECTMORPH_MORPH_PLAN_HH
5 
6 #include "smindex.hh"
7 #include "smmorphoperator.hh"
8 #include "smobject.hh"
9 #include "smaudio.hh"
10 #include "smutils.hh"
11 #include "smsignal.hh"
12 
13 namespace SpectMorph
14 {
15 
16 class MorphPlan : public Object
17 {
18 public:
20  {
21  public:
22  virtual std::string section() = 0;
23  virtual void save (OutFile& out_file) = 0;
24  virtual void handle_event (InFile& ifile) = 0;
25  };
26 
27 protected:
28  Index m_index;
29  std::vector<MorphOperator *> m_operators;
30 
31  std::string index_filename;
32  bool in_restore;
33 
34  void clear();
35  Error load_internal (GenericIn *in, ExtraParameters *params = nullptr);
36 
37 public:
38  MorphPlan();
39  ~MorphPlan();
40 
41  bool load_index (const std::string& filename);
42  const Index *index();
43 
44  enum AddPos {
45  ADD_POS_AUTO,
46  ADD_POS_END
47  };
48 
49  void add_operator (MorphOperator *op, AddPos = ADD_POS_END, const std::string& name = "", const std::string& id = "", bool load_folded = false);
50  const std::vector<MorphOperator *>& operators();
51  void remove (MorphOperator *op);
52  void move (MorphOperator *op, MorphOperator *op_next);
53 
54  void set_plan_str (const std::string& plan_str);
55  void emit_plan_changed();
56  void emit_index_changed();
57 
58  Error save (GenericOut *file, ExtraParameters *params = nullptr) const;
59  Error load (GenericIn *in, ExtraParameters *params = nullptr);
60 
61  void load_default();
62 
63  MorphPlan *clone() const; // create a deep copy
64 
65  static std::string id_chars();
66  static std::string generate_id();
67 
68  Signal<> signal_plan_changed;
69  Signal<> signal_index_changed;
70  Signal<> signal_need_view_rebuild;
71  Signal<MorphOperator *> signal_operator_removed;
72 };
73 
75 
76 }
77 
78 #endif
Generic Input Stream.
Definition: smgenericin.hh:17
Definition: smoutfile.hh:15
Definition: smmorphplan.hh:16
Definition: smsignal.hh:16
void clear()
Definition: smmorphplan.cc:39
const std::vector< MorphOperator * > & operators()
Definition: smmorphplan.cc:371
Class to read SpectMorph binary data.
Definition: sminfile.hh:25
Definition: smmorphplan.hh:19
Definition: smmorphoperator.hh:18
Definition: smindex.hh:19
Definition: smadsrenvelope.hh:8
Generic Output Stream.
Definition: smgenericout.hh:17
Error load(GenericIn *in, ExtraParameters *params=nullptr)
Definition: smmorphplan.cc:308
Definition: smobject.hh:12
bool load_index(const std::string &filename)
Definition: smmorphplan.cc:61