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 
12 namespace SpectMorph
13 {
14 
15 class MorphPlan : public Object
16 {
17  Q_OBJECT
18  Index m_index;
19  std::vector<MorphOperator *> m_operators;
20 
21  std::string index_filename;
22  bool in_restore;
23 
24  void clear();
25 
26 public:
27  MorphPlan();
28  ~MorphPlan();
29 
31  {
32  public:
33  virtual std::string section() = 0;
34  virtual void save (OutFile& out_file) = 0;
35  virtual void handle_event (InFile& ifile) = 0;
36  };
37 
38  bool load_index (const std::string& filename);
39  const Index *index();
40 
41  enum AddPos {
42  ADD_POS_AUTO,
43  ADD_POS_END
44  };
45 
46  void add_operator (MorphOperator *op, AddPos = ADD_POS_END, const std::string& name = "", const std::string& id = "", bool load_folded = false);
47  const std::vector<MorphOperator *>& operators();
48  void remove (MorphOperator *op);
49  void move (MorphOperator *op, MorphOperator *op_next);
50 
51  void set_plan_str (const std::string& plan_str);
52  void emit_plan_changed();
53  void emit_index_changed();
54 
55  Error save (GenericOut *file, ExtraParameters *params = nullptr) const;
56  Error load (GenericIn *in, ExtraParameters *params = nullptr);
57 
58  MorphPlan *clone() const; // create a deep copy
59 
60  static std::string id_chars();
61  static std::string generate_id();
62 
63 signals:
64  void plan_changed();
65  void index_changed();
66  void operator_removed (MorphOperator *op);
67  void need_view_rebuild();
68 };
69 
71 
72 }
73 
74 #endif
Generic Input Stream.
Definition: smgenericin.hh:17
Definition: smoutfile.hh:15
Definition: smmorphplan.hh:15
const std::vector< MorphOperator * > & operators()
Definition: smmorphplan.cc:308
Class to read SpectMorph binary data.
Definition: sminfile.hh:25
Definition: smmorphplan.hh:30
Definition: smmorphoperator.hh:19
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:151
Definition: smobject.hh:12
bool load_index(const std::string &filename)
Definition: smmorphplan.cc:61