PlayParameterRepository.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_PLAY_PARAMETER_REPOSITORY_H
17 #define SV_PLAY_PARAMETER_REPOSITORY_H
18 
19 #include "PlayParameters.h"
20 #include "Command.h"
21 
22 class Playable;
23 
24 #include <map>
25 #include <memory>
26 
27 #include <QObject>
28 #include <QString>
29 
30 class PlayParameterRepository : public QObject
31 {
32  Q_OBJECT
33 
34 public:
36 
37  virtual ~PlayParameterRepository();
38 
43  void addPlayable(int id, const Playable *);
44 
49  void removePlayable(int id);
50 
54  void copyParameters(int fromId, int toId);
55 
59  std::shared_ptr<PlayParameters> getPlayParameters(int id);
60 
61  void clear();
62 
63  class EditCommand : public Command
64  {
65  public:
66  EditCommand(std::shared_ptr<PlayParameters> params);
67  void setPlayMuted(bool);
68  void setPlayAudible(bool);
69  void setPlayPan(float);
70  void setPlayGain(float);
71  void setPlayClipId(QString);
72  void execute() override;
73  void unexecute() override;
74  QString getName() const override;
75 
76  protected:
77  std::shared_ptr<PlayParameters> m_params;
80  };
81 
82 signals:
83  void playParametersChanged(int playableId);
84  void playClipIdChanged(int playableId, QString);
85 
86 protected slots:
87  void playParametersChanged();
88  void playClipIdChanged(QString);
89 
90 protected:
91  typedef std::map<int, std::shared_ptr<PlayParameters>> PlayableParameterMap;
92  PlayableParameterMap m_playParameters;
93 
95 };
96 
97 #endif
std::shared_ptr< PlayParameters > getPlayParameters(int id)
Retrieve the play parameters for a playable.
static PlayParameterRepository * getInstance()
EditCommand(std::shared_ptr< PlayParameters > params)
static PlayParameterRepository * m_instance
std::map< int, std::shared_ptr< PlayParameters > > PlayableParameterMap
PlayableParameterMap m_playParameters
void removePlayable(int id)
Unregister a playable.
std::shared_ptr< PlayParameters > m_params
void copyParameters(int fromId, int toId)
Copy the play parameters from one playable to another.
void addPlayable(int id, const Playable *)
Register a playable.
void playClipIdChanged(int playableId, QString)