ObjectLocker.hpp
1 #pragma once
2 #include <score/model/path/ObjectPath.hpp>
3 
4 #include <QByteArray>
5 #include <QObject>
6 
7 #include <vector>
8 #include <verdigris>
9 namespace score
10 {
20 class SCORE_LIB_BASE_EXPORT ObjectLocker : public QObject
21 {
22  W_OBJECT(ObjectLocker)
23 public:
24  explicit ObjectLocker(QObject* parent);
25 
26  // To the network
27  void lock(QByteArray b) E_SIGNAL(SCORE_LIB_BASE_EXPORT, lock, b)
28  void unlock(QByteArray b) E_SIGNAL(SCORE_LIB_BASE_EXPORT, unlock, b)
29 
30  // From the network
31  void on_lock(QByteArray b);
32  W_INVOKABLE(on_lock)
33  void on_unlock(QByteArray);
34  W_INVOKABLE(on_unlock)
35 
36 private:
37  // In the commands
38  void lock_impl();
39  void unlock_impl();
40 
41  std::vector<ObjectPath> m_lockedObjects;
42 };
43 
50 class LockHelper
51 {
52 public:
53  LockHelper(QObject& model, ObjectLocker& locker);
54 
55  LockHelper(ObjectPath&& path, ObjectLocker& locker);
56 
57  ~LockHelper();
58 
59  void lock();
60 
61  void unlock();
62 
63 private:
64  ObjectPath m_path;
65  QByteArray m_serializedPath;
66  ObjectLocker& m_locker;
67  bool m_locked{false};
68 };
69 }
The ObjectPath class.
Definition: ObjectPath.hpp:37
The LockHelper class.
Definition: ObjectLocker.hpp:48
The ObjectLocker class.
Definition: ObjectLocker.hpp:21
Base toolkit upon which the software is built.
Definition: Application.cpp:90