MagnetismAdjuster.hpp
1 #pragma once
2 #include <Process/TimeValue.hpp>
3 
4 #include <Magnetism/MagneticInfo.hpp>
5 
6 #include <score/plugins/Interface.hpp>
7 #include <score/plugins/InterfaceList.hpp>
8 
9 #include <QObject>
10 #include <QPointer>
11 
12 #include <score_lib_process_export.h>
13 
14 #include <utility>
15 #include <vector>
16 
17 namespace Process
18 {
19 class ProcessModel;
20 
21 class SCORE_LIB_PROCESS_EXPORT MagnetismAdjuster final
22  : public QObject
24 {
25 public:
26  MagnetismAdjuster() noexcept;
27  ~MagnetismAdjuster() noexcept;
28 
29  MagneticInfo getPosition(const QObject* obj, TimeVal original) noexcept;
30 
31  // Shortcut for some classes : the API to implement must look like
32  // Position magneticPosition(Position
33  template <typename T>
34  void registerHandler(T& context) noexcept
35  {
36  registerHandler(&context, [&context](const QObject* obj, TimeVal t) {
37  return context.magneticPosition(obj, t);
38  });
39  }
40  void registerHandler(QObject* context, MagnetismHandler h) noexcept;
41  void unregisterHandler(QObject* context) noexcept;
42 
43  static score::InterfaceKey static_interfaceKey() noexcept;
44  score::InterfaceKey interfaceKey() const noexcept override;
45 
46 private:
47  void insert(std::unique_ptr<score::InterfaceBase>) override;
48  void optimize() noexcept override;
49 
50  std::vector<std::pair<QPointer<QObject>, MagnetismHandler>> m_handlers;
51 };
52 
53 }
Definition: MagnetismAdjuster.hpp:24
Definition: UuidKey.hpp:343
InterfaceListBase Interface to access factories.
Definition: InterfaceList.hpp:29
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324
Definition: MagneticInfo.hpp:11
Definition: TimeValue.hpp:21