TimeSyncModel.hpp
1 #pragma once
2 #include <State/Expression.hpp>
3 
4 #include <Process/Dataflow/TimeSignature.hpp>
5 #include <Process/TimeValue.hpp>
6 
7 #include <Scenario/Document/Event/ExecutionStatus.hpp>
8 #include <Scenario/Document/Metatypes.hpp>
9 #include <Scenario/Document/VerticalExtent.hpp>
10 
11 #include <score/model/Component.hpp>
12 #include <score/model/EntityImpl.hpp>
13 #include <score/model/IdentifiedObject.hpp>
14 #include <score/model/Identifier.hpp>
15 #include <score/selection/Selectable.hpp>
16 #include <score/tools/Metadata.hpp>
17 #include <score/tools/std/Optional.hpp>
18 
19 #include <QObject>
20 
21 #include <score_plugin_scenario_export.h>
22 
23 #include <chrono>
24 #include <verdigris>
25 class DataStream;
26 class JSONObject;
27 
28 namespace Scenario
29 {
30 class EventModel;
31 class ScenarioInterface;
32 
33 class SCORE_PLUGIN_SCENARIO_EXPORT TimeSyncModel final
34  : public score::Entity<TimeSyncModel>
35 {
36  W_OBJECT(TimeSyncModel)
37 
38  SCORE_SERIALIZE_FRIENDS
39 
40 public:
42  Selectable selection{this};
43 
45  TimeSyncModel(const Id<TimeSyncModel>& id, const TimeVal& date, QObject* parent);
46 
47  template <typename DeserializerVisitor>
48  TimeSyncModel(DeserializerVisitor&& vis, QObject* parent)
49  : Entity{vis, parent}
50  {
51  vis.writeTo(*this);
52  }
53 
54  // Data of the TimeSync
55  const TimeVal& date() const noexcept;
56  void setDate(const TimeVal&);
57 
58  void addEvent(const Id<EventModel>&);
59  bool removeEvent(const Id<EventModel>&);
60  void clearEvents();
61 
62  using EventIdVec = ossia::small_vector<Id<EventModel>, 2>;
63  const EventIdVec& events() const noexcept;
64  void setEvents(const TimeSyncModel::EventIdVec& events);
65 
66  State::Expression expression() const noexcept { return m_expression; }
67  void setExpression(const State::Expression& expression);
68 
69  bool active() const noexcept;
70  void setActive(bool active);
71 
72  bool autotrigger() const noexcept;
73  void setAutotrigger(bool t);
74 
75  bool isStartPoint() const noexcept;
76  void setStartPoint(bool t);
77 
78  ossia::musical_sync musicalSync() const noexcept;
79  void setMusicalSync(ossia::musical_sync sig);
80 
81  void setWaiting(bool);
82  bool waiting() const noexcept;
83 
84 public:
85  void dateChanged(const TimeVal& arg_1)
86  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, dateChanged, arg_1)
87 
88  void newEvent(const Id<Scenario::EventModel>& eventId)
89  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, newEvent, eventId)
90  void eventRemoved(const Id<Scenario::EventModel>& eventId)
91  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, eventRemoved, eventId)
92 
93  void triggerChanged(const State::Expression& arg_1)
94  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, triggerChanged, arg_1)
95  void activeChanged() E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, activeChanged)
96 
97  void autotriggerChanged(bool b)
98  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, autotriggerChanged, b)
99  void startPointChanged(bool b)
100  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, startPointChanged, b)
101 
102  void triggeredByGui() const E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, triggeredByGui)
103 
104  void waitingChanged(bool b) const
105  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, waitingChanged, b)
106 
107  double musicalSyncChanged(ossia::musical_sync sync)
108  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, musicalSyncChanged, sync)
109 
110  PROPERTY(
111  ossia::musical_sync,
112  musicalSync READ musicalSync WRITE setMusicalSync NOTIFY musicalSyncChanged)
113  PROPERTY(
114  bool, startPoint READ isStartPoint WRITE setStartPoint NOTIFY startPointChanged)
115 
116 private:
117  TimeVal m_date{};
118  State::Expression m_expression;
119 
120  EventIdVec m_events;
121  ossia::musical_sync m_musicalSync{-1.};
122  bool m_active{false};
123  bool m_autotrigger{false};
124  bool m_startPoint{false};
125  bool m_waiting{false};
126 };
127 }
128 
129 DEFAULT_MODEL_METADATA(Scenario::TimeSyncModel, "Sync")
130 TR_TEXT_METADATA(, Scenario::TimeSyncModel, PrettyName_k, "Sync")
Definition: VisitorInterface.hpp:53
Definition: VisitorInterface.hpp:61
Metadata to get the name that will be shown in the user interface.
Definition: lib/score/tools/Metadata.hpp:42
Definition: TimeSyncModel.hpp:35
The Selectable class.
Definition: Selectable.hpp:14
The id_base_t class.
Definition: Identifier.hpp:57
Base for complex model objects.
Definition: EntityBase.hpp:24
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Utilities for OSSIA data structures.
Definition: DeviceInterface.hpp:33
Definition: TimeValue.hpp:21