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