3
Copyright (C) 2000 Stefan Westerfeld
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Library General Public License
17
along with this library; see the file COPYING.LIB. If not, write to
18
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
Boston, MA 02111-1307, USA.
23
#include "midimanager_impl.h"
24
#include "midiclient_impl.h"
30
static int cleanReference(const string& reference)
32
Object test = Reference("global:"+reference);
35
Dispatcher::the()->globalComm().erase(reference);
42
MidiManager_impl::MidiManager_impl() : nextID(1)
44
cleanReference("Arts_MidiManager");
45
if(!ObjectManager::the()->addGlobalReference(Object::_from_base(_copy()),
48
arts_warning("can't register Arts::MidiManager");
52
arts_debug("Arts::MidiManager registered successfully.");
56
vector<MidiClientInfo> *MidiManager_impl::clients()
58
vector<MidiClientInfo> *result = new vector<MidiClientInfo>;
60
list<MidiClient_impl *>::iterator i;
61
for(i = _clients.begin(); i != _clients.end(); i++)
62
result->push_back((*i)->info());
67
MidiClient MidiManager_impl::addClient(MidiClientDirection direction,
68
MidiClientType type, const string& title, const string& autoRestoreID)
73
info.direction = direction;
76
info.autoRestoreID = autoRestoreID;
78
MidiClient_impl *impl = new MidiClient_impl(info, this);
79
_clients.push_back(impl);
80
return MidiClient::_from_base(impl);
83
void MidiManager_impl::removeClient(MidiClient_impl *client)
85
_clients.remove(client);
88
MidiClient_impl *MidiManager_impl::findClient(long clientID)
90
list<MidiClient_impl *>::iterator i;
92
for(i = _clients.begin(); i != _clients.end(); i++)
94
if((*i)->ID() == clientID)
101
void MidiManager_impl::connect(long clientID, long destinationID)
103
MidiClient_impl *src = findClient(clientID);
104
MidiClient_impl *dest = findClient(destinationID);
106
arts_return_if_fail(src);
107
arts_return_if_fail(dest);
111
void MidiManager_impl::disconnect(long clientID, long destinationID)
113
MidiClient_impl *src = findClient(clientID);
114
MidiClient_impl *dest = findClient(destinationID);
116
arts_return_if_fail(src);
117
arts_return_if_fail(dest);
118
src->disconnect(dest);
121
namespace Arts { REGISTER_IMPLEMENTATION(MidiManager_impl); }