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 <verdigris>
24 class DataStream;
25 class JSONObject;
26 
27 namespace Scenario
28 {
29 class EventModel;
30 class ScenarioInterface;
31 
32 class SCORE_PLUGIN_SCENARIO_EXPORT TimeSyncModel final
33  : public score::Entity<TimeSyncModel>
34 {
35  W_OBJECT(TimeSyncModel)
36 
37  SCORE_SERIALIZE_FRIENDS
38 
39 public:
41  Selectable selection{this};
42 
44  TimeSyncModel(const Id<TimeSyncModel>& id, const TimeVal& date, QObject* parent);
45 
46  template <typename DeserializerVisitor>
47  TimeSyncModel(DeserializerVisitor&& vis, QObject* parent)
48  : Entity{vis, parent}
49  {
50  vis.writeTo(*this);
51  }
52 
53  // Data of the TimeSync
54  const TimeVal& date() const noexcept;
55  void setDate(const TimeVal&);
56 
57  void addEvent(const Id<EventModel>&);
58  bool removeEvent(const Id<EventModel>&);
59  void clearEvents();
60 
61  using EventIdVec = ossia::small_vector<Id<EventModel>, 2>;
62  const EventIdVec& events() const noexcept;
63  void setEvents(const TimeSyncModel::EventIdVec& events);
64 
65  State::Expression expression() const noexcept { return m_expression; }
66  void setExpression(const State::Expression& expression);
67 
68  bool active() const noexcept;
69  void setActive(bool active);
70 
71  bool autotrigger() const noexcept;
72  void setAutotrigger(bool t);
73 
74  bool isStartPoint() const noexcept;
75  void setStartPoint(bool t);
76 
77  ossia::musical_sync musicalSync() const noexcept;
78  void setMusicalSync(ossia::musical_sync sig);
79 
80  void setWaiting(bool);
81  bool waiting() const noexcept;
82 
83 public:
84  void dateChanged(const TimeVal& arg_1)
85  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, dateChanged, arg_1)
86 
87  void newEvent(const Id<Scenario::EventModel>& eventId)
88  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, newEvent, eventId)
89  void eventRemoved(const Id<Scenario::EventModel>& eventId)
90  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, eventRemoved, eventId)
91 
92  void triggerChanged(const State::Expression& arg_1)
93  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, triggerChanged, arg_1)
94  void activeChanged() E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, activeChanged)
95 
96  void autotriggerChanged(bool b)
97  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, autotriggerChanged, b)
98  void startPointChanged(bool b)
99  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, startPointChanged, b)
100 
101  void triggeredByGui() const E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, triggeredByGui)
102 
103  void waitingChanged(bool b) const
104  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, waitingChanged, b)
105 
106  double musicalSyncChanged(ossia::musical_sync sync)
107  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, musicalSyncChanged, sync)
108 
109  PROPERTY(
110  ossia::musical_sync,
111  musicalSync READ musicalSync WRITE setMusicalSync NOTIFY musicalSyncChanged)
112  PROPERTY(bool, active READ active WRITE setActive NOTIFY activeChanged)
113  PROPERTY(
114  bool, autotrigger READ autotrigger WRITE setAutotrigger NOTIFY autotriggerChanged)
115  PROPERTY(
116  bool, startPoint READ isStartPoint WRITE setStartPoint NOTIFY startPointChanged)
117  PROPERTY(
118  State::Expression,
119  expression READ expression WRITE setExpression NOTIFY triggerChanged)
120 
121 private:
122  TimeVal m_date{};
123  State::Expression m_expression;
124 
125  EventIdVec m_events;
126  ossia::musical_sync m_musicalSync{-1.};
127  bool m_active{false};
128  bool m_autotrigger{false};
129  bool m_startPoint{false};
130  bool m_waiting{false};
131 };
132 }
133 
134 DEFAULT_MODEL_METADATA(Scenario::TimeSyncModel, "Sync")
135 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:34
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