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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3708 - (hide annotations) (download)
Wed Jan 8 22:11:30 2020 UTC (4 years, 4 months ago) by schoenebeck
File size: 5248 byte(s)
Fixed compile errors with C++17:

* std::ptr_fun was removed from STL in C++17,
  use C++11 lambda expression instead.

* std::mem_fun and std::bind2nd were removed from STL in C++17,
  use C++11 lambda expression instead.

* Bumped version (2.1.1.svn36).

1 schoenebeck 1374 /***************************************************************************
2     * *
3 schoenebeck 3708 * Copyright (C) 2007 - 2020 Christian Schoenebeck *
4 schoenebeck 1374 * *
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 schoenebeck 1425 #include "../common/global_private.h"
24    
25 schoenebeck 1374 #include <algorithm>
26     #include <functional>
27    
28     namespace LinuxSampler {
29    
30     InstrumentEditor::InstrumentEditor() : Thread(false, false, -1, 0) {
31     pInstrument = NULL;
32 schoenebeck 1876 pUserData = NULL;
33 schoenebeck 2687 pEngineChannel = NULL;
34 schoenebeck 1374 }
35    
36 schoenebeck 1653 InstrumentEditor::~InstrumentEditor() {
37     }
38    
39 schoenebeck 2687 void InstrumentEditor::Launch(EngineChannel* pEngineChannel, void* pInstrument, String sTypeName, String sTypeVersion, void* pUserData) {
40 persson 2837 dmsg(1,("InstrumentEditor::Launch(instr=%p,type=%s,version=%s)\n", pInstrument, sTypeName.c_str(), sTypeVersion.c_str()));
41 schoenebeck 1374 // prepare the editor's mandatory parameters
42     this->pInstrument = pInstrument;
43     this->sTypeName = sTypeName;
44     this->sTypeVersion = sTypeVersion;
45 schoenebeck 1876 this->pUserData = pUserData;
46 schoenebeck 2687 this->pEngineChannel = pEngineChannel;
47 schoenebeck 1374 // start the editor in its own thread
48     StartThread();
49     }
50    
51     int InstrumentEditor::Main() {
52     dmsg(1,("InstrumentEditor::Main()\n"));
53     // run the editor's main loop
54 schoenebeck 1876 int iResult = Main(pInstrument, sTypeName, sTypeVersion, pUserData);
55 schoenebeck 1374 // reset editor parameters
56     this->pInstrument = NULL;
57     this->sTypeName = "";
58     this->sTypeVersion = "";
59 schoenebeck 1876 this->pUserData = NULL;
60 schoenebeck 1374 dmsg(1,("Instrument editor '%s' returned with exit status %d\n", Name().c_str(), iResult));
61     // notify all registered listeners
62     std::for_each(
63     listeners.begin(), listeners.end(),
64 schoenebeck 3708 [this](InstrumentEditorListener* listener) {
65     listener->OnInstrumentEditorQuit(this);
66     }
67 schoenebeck 1374 );
68     // done
69 schoenebeck 3290 StopThread();
70 schoenebeck 1374 return iResult;
71     }
72    
73 schoenebeck 2687 EngineChannel* InstrumentEditor::GetEngineChannel() {
74     return pEngineChannel;
75     }
76    
77 schoenebeck 1374 void InstrumentEditor::AddListener(InstrumentEditorListener* pListener) {
78     listeners.insert(pListener);
79     }
80    
81     void InstrumentEditor::RemoveListener(InstrumentEditorListener* pListener) {
82     listeners.erase(pListener);
83     }
84    
85     void InstrumentEditor::NotifySamplesToBeRemoved(std::set<void*> Samples) {
86     for ( // notify all registered listeners
87     std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
88     iter != listeners.end(); iter++
89     ) (*iter)->OnSamplesToBeRemoved(Samples, this);
90     }
91    
92     void InstrumentEditor::NotifySamplesRemoved() {
93     for ( // notify all registered listeners
94     std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
95     iter != listeners.end(); iter++
96     ) (*iter)->OnSamplesRemoved(this);
97     }
98    
99     void InstrumentEditor::NotifyDataStructureToBeChanged(void* pStruct, String sStructType) {
100     for ( // notify all registered listeners
101     std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
102     iter != listeners.end(); iter++
103     ) (*iter)->OnDataStructureToBeChanged(pStruct, sStructType, this);
104     }
105    
106     void InstrumentEditor::NotifyDataStructureChanged(void* pStruct, String sStructType) {
107     for ( // notify all registered listeners
108     std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
109     iter != listeners.end(); iter++
110     ) (*iter)->OnDataStructureChanged(pStruct, sStructType, this);
111     }
112    
113     void InstrumentEditor::NotifySampleReferenceChanged(void* pOldSample, void* pNewSample) {
114     for ( // notify all registered listeners
115     std::set<InstrumentEditorListener*>::iterator iter = listeners.begin();
116     iter != listeners.end(); iter++
117     ) (*iter)->OnSampleReferenceChanged(pOldSample, pNewSample, this);
118     }
119    
120     } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC