TimeSignatureMap.hpp
1 #pragma once
2 #include <Process/TimeValue.hpp>
3 
4 #include <score/serialization/VisitorInterface.hpp>
5 
6 #include <ossia/editor/scenario/time_signature.hpp>
7 
8 #include <score_plugin_scenario_export.h>
9 
10 #include <utility>
11 #include <vector>
12 #include <verdigris>
13 // Indirected because compile times were too high.
14 namespace Scenario
15 {
16 struct TimeSignatureMap;
17 }
18 template <>
19 struct TSerializer<DataStream, Scenario::TimeSignatureMap>;
20 template <>
21 struct TSerializer<JSONObject, Scenario::TimeSignatureMap>;
22 namespace Scenario
23 {
24 
25 struct SCORE_PLUGIN_SCENARIO_EXPORT TimeSignatureMap
26 {
29 
30 public:
31  using iterator = std::vector<std::pair<TimeVal, ossia::time_signature>>::iterator;
32  using const_iterator
33  = std::vector<std::pair<TimeVal, ossia::time_signature>>::const_iterator;
34  explicit TimeSignatureMap();
36  TimeSignatureMap(const TimeSignatureMap& other);
38  TimeSignatureMap& operator=(const TimeSignatureMap& other);
39  TimeSignatureMap& operator=(TimeSignatureMap&& other);
40 
41  void clear();
42  bool empty() const noexcept;
43  std::size_t size() const noexcept;
44  ossia::time_signature& at(const TimeVal&);
45  ossia::time_signature& operator[](const TimeVal&);
46  const_iterator find(const TimeVal&) const;
47  const_iterator last_before(const TimeVal&) const;
48  const_iterator upper_bound(const TimeVal&) const;
49  void erase(const_iterator);
50  void erase(const TimeVal& t);
51 
52  const_iterator begin() const;
53  const_iterator end() const;
54 
55  bool operator!=(const TimeSignatureMap& other) const noexcept;
56 
57 private:
58  struct impl;
59  mutable impl* map{};
60 };
61 }
62 
63 template <>
64 struct is_custom_serialized<Scenario::TimeSignatureMap> : std::true_type
65 {
66 };
67 
68 template <>
69 struct TSerializer<DataStream, Scenario::TimeSignatureMap>
70 {
71  static void
72  readFrom(DataStream::Serializer& s, const Scenario::TimeSignatureMap& path);
73  static void writeTo(DataStream::Deserializer& s, Scenario::TimeSignatureMap& path);
74 };
75 
76 template <>
77 struct TSerializer<JSONObject, Scenario::TimeSignatureMap>
78 {
79  static void
80  readFrom(JSONObject::Serializer& s, const Scenario::TimeSignatureMap& path);
81  static void writeTo(JSONObject::Deserializer& s, Scenario::TimeSignatureMap& path);
82 };
83 Q_DECLARE_METATYPE(Scenario::TimeSignatureMap)
84 W_REGISTER_ARGTYPE(Scenario::TimeSignatureMap)
Definition: VisitorInterface.hpp:53
Definition: DataStreamVisitor.hpp:27
Definition: DataStreamVisitor.hpp:202
Definition: VisitorInterface.hpp:61
Definition: JSONVisitor.hpp:52
Definition: JSONVisitor.hpp:423
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: TimeSignatureMap.cpp:22
Definition: TimeSignatureMap.hpp:26
Definition: VisitorInterface.hpp:13
Definition: TimeValue.hpp:21