/[svn]/linuxsampler/trunk/src/plugins/InstrumentEditor.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/plugins/InstrumentEditor.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1374 - (show annotations) (download)
Wed Oct 3 18:37:56 2007 UTC (16 years, 6 months ago) by schoenebeck
File size: 4769 byte(s)
- code refactoring, moved the following files from
  src/engines/ -> src/plugins/ :

  InstrumentEditor.h ,
  InstrumentEditor.cpp ,
  InstrumentEditorFactory.h ,
  InstrumentEditorFactory.cpp

1 /***************************************************************************
2 * *
3 * Copyright (C) 2007 Christian Schoenebeck *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
18 * MA 02111-1307 USA *
19 ***************************************************************************/
20
21 #include "InstrumentEditor.h"
22
23 #include <algorithm>
24 #include <functional>
25
26 namespace LinuxSampler {
27
28 InstrumentEditor::InstrumentEditor() : Thread(false, false, -1, 0) {
29 pInstrument = NULL;
30 }
31
32 void InstrumentEditor::Launch(void* pInstrument, String sTypeName, String sTypeVersion) {
33 dmsg(1,("InstrumentEditor::Launch(instr=%x,type=%s,version=%s)\n", pInstrument, sTypeName.c_str(), sTypeVersion.c_str()));
34 // prepare the editor's mandatory parameters
35 this->pInstrument = pInstrument;
36 this->sTypeName = sTypeName;
37 this->sTypeVersion = sTypeVersion;
38 // start the editor in its own thread
39 StartThread();
40 }
41
42 int InstrumentEditor::Main() {
43 dmsg(1,("InstrumentEditor::Main()\n"));
44 // run the editor's main loop
45 int iResult = Main(pInstrument, sTypeName, sTypeVersion);
46 // reset editor parameters
47 this->pInstrument = NULL;
48 this->sTypeName = "";
49 this->sTypeVersion = "";
50 dmsg(1,("Instrument editor '%s' returned with exit status %d\n", Name().c_str(), iResult));
51 // notify all registered listeners
52 std::for_each(
53 listeners.begin(), listeners.end(),
54 std::bind2nd(std::mem_fun(&InstrumentEditorListener::OnInstrumentEditorQuit), this)
55 );
56 // done
57 return iResult;
58 }
59
60 void InstrumentEditor::AddListener(InstrumentEditorListener* pListener) {
61 listeners.insert(pListener);
62 }
63
64 void InstrumentEditor::RemoveListener(InstrumentEditorListener* pListener) {
65 listeners.erase(pListener);
66 }
67
68 void InstrumentEditor::NotifySamplesToBeRemoved(std::set<void*> Samples) {
69 for ( // notify all registered listeners
70 std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
71 iter != listeners.end(); iter++
72 ) (*iter)->OnSamplesToBeRemoved(Samples, this);
73 }
74
75 void InstrumentEditor::NotifySamplesRemoved() {
76 for ( // notify all registered listeners
77 std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
78 iter != listeners.end(); iter++
79 ) (*iter)->OnSamplesRemoved(this);
80 }
81
82 void InstrumentEditor::NotifyDataStructureToBeChanged(void* pStruct, String sStructType) {
83 for ( // notify all registered listeners
84 std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
85 iter != listeners.end(); iter++
86 ) (*iter)->OnDataStructureToBeChanged(pStruct, sStructType, this);
87 }
88
89 void InstrumentEditor::NotifyDataStructureChanged(void* pStruct, String sStructType) {
90 for ( // notify all registered listeners
91 std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
92 iter != listeners.end(); iter++
93 ) (*iter)->OnDataStructureChanged(pStruct, sStructType, this);
94 }
95
96 void InstrumentEditor::NotifySampleReferenceChanged(void* pOldSample, void* pNewSample) {
97 for ( // notify all registered listeners
98 std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
99 iter != listeners.end(); iter++
100 ) (*iter)->OnSampleReferenceChanged(pOldSample, pNewSample, this);
101 }
102
103 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC