comparison base/PlayParameterRepository.h @ 1751:77543124651b by-id

Overhaul PlayParameters bits
author Chris Cannam
date Thu, 04 Jul 2019 18:04:21 +0100
parents 52705a328b34
children
comparison
equal deleted inserted replaced
1750:d0ef65d8dd89 1751:77543124651b
20 #include "Command.h" 20 #include "Command.h"
21 21
22 class Playable; 22 class Playable;
23 23
24 #include <map> 24 #include <map>
25 #include <memory>
25 26
26 #include <QObject> 27 #include <QObject>
27 #include <QString> 28 #include <QString>
28 29
29 class PlayParameterRepository : public QObject 30 class PlayParameterRepository : public QObject
34 static PlayParameterRepository *getInstance(); 35 static PlayParameterRepository *getInstance();
35 36
36 virtual ~PlayParameterRepository(); 37 virtual ~PlayParameterRepository();
37 38
38 /** 39 /**
39 * Register a playable. 40 * Register a playable. The id can be anything you like, so long
40 * 41 * as it is unique among playables.
41 * The id must be of an object that is registered with the ById
42 * store and that can be dynamic_cast to Playable.
43 */ 42 */
44 void addPlayable(int playableId); 43 void addPlayable(int id, const Playable *);
45 44
46 /** 45 /**
47 * Unregister a playable. 46 * Unregister a playable. This must happen before a playable is
48 * 47 * deleted.
49 * The id must be of an object that is registered with the ById
50 * store and that can be dynamic_cast to Playable.
51 */ 48 */
52 void removePlayable(int playableId); 49 void removePlayable(int id);
53 50
54 /** 51 /**
55 * Copy the play parameters from one playable to another. 52 * Copy the play parameters from one playable to another.
56 *
57 * The ids must be of objects that are registered with the ById
58 * store and that can be dynamic_cast to Playable.
59 */ 53 */
60 void copyParameters(int fromId, int toId); 54 void copyParameters(int fromId, int toId);
61 55
62 /** 56 /**
63 * Retrieve the play parameters for a playable. 57 * Retrieve the play parameters for a playable.
64 *
65 * The id must be of an object that is registered with the ById
66 * store and that can be dynamic_cast to Playable.
67 */ 58 */
68 PlayParameters *getPlayParameters(int playableId); 59 std::shared_ptr<PlayParameters> getPlayParameters(int id);
69 60
70 void clear(); 61 void clear();
71 62
72 class EditCommand : public Command 63 class EditCommand : public Command
73 { 64 {
74 public: 65 public:
75 EditCommand(PlayParameters *params); 66 EditCommand(std::shared_ptr<PlayParameters> params);
76 void setPlayMuted(bool); 67 void setPlayMuted(bool);
77 void setPlayAudible(bool); 68 void setPlayAudible(bool);
78 void setPlayPan(float); 69 void setPlayPan(float);
79 void setPlayGain(float); 70 void setPlayGain(float);
80 void setPlayClipId(QString); 71 void setPlayClipId(QString);
81 void execute() override; 72 void execute() override;
82 void unexecute() override; 73 void unexecute() override;
83 QString getName() const override; 74 QString getName() const override;
84 75
85 protected: 76 protected:
86 PlayParameters *m_params; 77 std::shared_ptr<PlayParameters> m_params;
87 PlayParameters m_from; 78 PlayParameters m_from;
88 PlayParameters m_to; 79 PlayParameters m_to;
89 }; 80 };
90 81
91 signals: 82 signals:
92 void playParametersChanged(PlayParameters *); 83 void playParametersChanged(int playableId);
93 void playClipIdChanged(int playableId, QString); 84 void playClipIdChanged(int playableId, QString);
94 85
95 protected slots: 86 protected slots:
96 void playParametersChanged(); 87 void playParametersChanged();
97 void playClipIdChanged(QString); 88 void playClipIdChanged(QString);
98 89
99 protected: 90 protected:
100 typedef std::map<int, PlayParameters *> PlayableParameterMap; 91 typedef std::map<int, std::shared_ptr<PlayParameters>> PlayableParameterMap;
101 PlayableParameterMap m_playParameters; 92 PlayableParameterMap m_playParameters;
102 93
103 static PlayParameterRepository *m_instance; 94 static PlayParameterRepository *m_instance;
104 }; 95 };
105 96