ClockFactory.hpp
1 #pragma once
2 #include <Process/TimeValue.hpp>
3 
4 #include <score/plugins/Interface.hpp>
5 #include <score/plugins/InterfaceList.hpp>
6 
7 #include <ossia/editor/scenario/time_value.hpp>
8 
9 #include <score_plugin_engine_export.h>
10 #include <smallfun.hpp>
11 namespace score
12 {
13 struct DocumentContext;
14 }
15 namespace Execution
16 {
17 struct Context;
18 class BaseScenarioElement;
19 
38 using time_function = smallfun::function<ossia::time_value(const TimeVal&)>;
39 using reverse_time_function = smallfun::function<TimeVal(const ossia::time_value&)>;
40 class SCORE_PLUGIN_ENGINE_EXPORT Clock
41 {
42 public:
43  Clock(const Execution::Context& ctx);
44  virtual ~Clock();
45 
46  const Context& context;
47  std::shared_ptr<BaseScenarioElement> scenario;
48 
49  void play(const TimeVal& t);
50  void pause();
51  void resume();
52  void stop();
53  virtual bool paused() const;
54 
55 protected:
56  virtual void play_impl(const TimeVal& t) = 0;
57  virtual void pause_impl() = 0;
58  virtual void resume_impl() = 0;
59  virtual void stop_impl() = 0;
60 };
61 
62 class SCORE_PLUGIN_ENGINE_EXPORT ClockFactory : public score::InterfaceBase
63 {
64  SCORE_INTERFACE(ClockFactory, "fb2b3624-ee6f-4e9a-901a-a096bb5fec0a")
65 public:
66  virtual ~ClockFactory();
67 
68  virtual QString prettyName() const = 0;
69  virtual std::unique_ptr<Clock> make(const Execution::Context& ctx) = 0;
70 
71  virtual time_function makeTimeFunction(const score::DocumentContext& ctx) const = 0;
72  virtual reverse_time_function
73  makeReverseTimeFunction(const score::DocumentContext& ctx) const = 0;
74 };
75 
76 class SCORE_PLUGIN_ENGINE_EXPORT ClockFactoryList final
77  : public score::InterfaceList<ClockFactory>
78 {
79 public:
80  using object_type = Clock;
81 };
82 }
83 
84 Q_DECLARE_METATYPE(Execution::ClockFactory::ConcreteKey)
85 W_REGISTER_ARGTYPE(Execution::ClockFactory::ConcreteKey)
Definition: ClockFactory.hpp:63
Definition: ClockFactory.hpp:78
Definition: ClockFactory.hpp:41
Base class for plug-in interfaces.
Definition: Interface.hpp:52
InterfaceList Default implementation of InterfaceListBase.
Definition: InterfaceList.hpp:80
Components used for the execution of a score.
Definition: ProcessComponent.cpp:12
smallfun::function< ossia::time_value(const TimeVal &)> time_function
Sets-up and manages the main execution clock.
Definition: ExecutionContext.hpp:66
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: ExecutionContext.hpp:76
Definition: TimeValue.hpp:21
Definition: DocumentContext.hpp:18