comparison base/PlayParameterRepository.cpp @ 30:a6ef94ecbe74

* As previous commit
author Chris Cannam
date Fri, 17 Feb 2006 18:11:08 +0000
parents 8460b3bf8f04
children 39ae3dee27b9
comparison
equal deleted inserted replaced
29:8460b3bf8f04 30:a6ef94ecbe74
7 This is experimental software. Not for distribution. 7 This is experimental software. Not for distribution.
8 */ 8 */
9 9
10 #include "PlayParameterRepository.h" 10 #include "PlayParameterRepository.h"
11 #include "PlayParameters.h" 11 #include "PlayParameters.h"
12
13 //!!! shouldn't be including this here -- restructure needed
14 #include "audioio/AudioGenerator.h"
12 15
13 #include <iostream> 16 #include <iostream>
14 17
15 PlayParameterRepository * 18 PlayParameterRepository *
16 PlayParameterRepository::m_instance = new PlayParameterRepository; 19 PlayParameterRepository::m_instance = new PlayParameterRepository;
23 26
24 PlayParameterRepository::~PlayParameterRepository() 27 PlayParameterRepository::~PlayParameterRepository()
25 { 28 {
26 } 29 }
27 30
31 void
32 PlayParameterRepository::addModel(const Model *model)
33 {
34 if (!getPlayParameters(model)) {
35
36 // Give all models the same type of play parameters for the
37 // moment, provided they can be played at all
38
39 if (AudioGenerator::canPlay(model)) {
40
41 std::cerr << "PlayParameterRepository: Adding play parameters for " << model << std::endl;
42
43 m_playParameters[model] = new PlayParameters;
44
45 connect(m_playParameters[model], SIGNAL(playParametersChanged()),
46 this, SLOT(playParametersChanged()));
47
48 } else {
49
50 std::cerr << "PlayParameterRepository: Model " << model << " not playable" << std::endl;
51 }
52 }
53 }
54
55 void
56 PlayParameterRepository::removeModel(const Model *model)
57 {
58 delete m_playParameters[model];
59 m_playParameters.erase(model);
60 }
61
28 PlayParameters * 62 PlayParameters *
29 PlayParameterRepository::getPlayParameters(const Model *model) 63 PlayParameterRepository::getPlayParameters(const Model *model) const
30 { 64 {
31 if (m_playParameters.find(model) == m_playParameters.end()) { 65 if (m_playParameters.find(model) == m_playParameters.end()) return 0;
32 // Give all models the same type of play parameters for the moment 66 return m_playParameters.find(model)->second;
33 std::cerr << "Creating new PlayParameters for model " << model << std::endl;
34 m_playParameters[model] = new PlayParameters;
35 connect(m_playParameters[model], SIGNAL(playParametersChanged()),
36 this, SLOT(playParametersChanged()));
37 }
38
39 return m_playParameters[model];
40 } 67 }
41 68
42 void 69 void
43 PlayParameterRepository::playParametersChanged() 70 PlayParameterRepository::playParametersChanged()
44 { 71 {
46 } 73 }
47 74
48 void 75 void
49 PlayParameterRepository::clear() 76 PlayParameterRepository::clear()
50 { 77 {
78 std::cerr << "PlayParameterRepository: PlayParameterRepository::clear" << std::endl;
51 while (!m_playParameters.empty()) { 79 while (!m_playParameters.empty()) {
52 delete m_playParameters.begin()->second; 80 delete m_playParameters.begin()->second;
53 m_playParameters.erase(m_playParameters.begin()); 81 m_playParameters.erase(m_playParameters.begin());
54 } 82 }
55 } 83 }