Audaspace  1.3.0
A high level audio library.
DeviceManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright 2009-2016 Jörg Müller
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 #pragma once
18 
25 #include "Audaspace.h"
26 
27 #include <memory>
28 #include <vector>
29 #include <unordered_map>
30 
32 
33 class IDevice;
34 class IDeviceFactory;
35 class I3DDevice;
36 
44 {
45 private:
46  static std::unordered_map<std::string, std::shared_ptr<IDeviceFactory>> m_factories;
47 
48  static std::shared_ptr<IDevice> m_device;
49 
50  // delete copy constructor and operator=
51  DeviceManager(const DeviceManager&) = delete;
52  DeviceManager& operator=(const DeviceManager&) = delete;
53  DeviceManager() = delete;
54 
55 public:
64  static void registerDevice(std::string name, std::shared_ptr<IDeviceFactory> factory);
65 
71  static std::shared_ptr<IDeviceFactory> getDeviceFactory(std::string name);
72 
77  static std::shared_ptr<IDeviceFactory> getDefaultDeviceFactory();
78 
79 
86  static void setDevice(std::shared_ptr<IDevice> device);
87 
94  static void openDevice(std::string name);
95 
102  static void openDefaultDevice();
103 
107  static void releaseDevice();
108 
113  static std::shared_ptr<IDevice> getDevice();
114 
120  static std::shared_ptr<I3DDevice> get3DDevice();
121 
126  static std::vector<std::string> getAvailableDeviceNames();
127 };
128 
The main header file of the library defining the namespace and basic data types.
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition: Audaspace.h:119
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition: Audaspace.h:116
#define AUD_API
Used for exporting symbols in the shared library.
Definition: Audaspace.h:93
This class manages all device plugins and maintains a device if asked to do so.
Definition: DeviceManager.h:44
static void releaseDevice()
Releases the currently handled device.
static void setDevice(std::shared_ptr< IDevice > device)
Sets a device that should be handled by the manager.
static std::shared_ptr< I3DDevice > get3DDevice()
Returns the currently handled 3D device.
static std::vector< std::string > getAvailableDeviceNames()
Returns a list of available devices.
static void registerDevice(std::string name, std::shared_ptr< IDeviceFactory > factory)
Registers a device factory.
static std::shared_ptr< IDeviceFactory > getDeviceFactory(std::string name)
Returns the factory for a specific device.
static void openDefaultDevice()
Opens the default device which will then be handled by the manager.
static std::shared_ptr< IDeviceFactory > getDefaultDeviceFactory()
Returns the default device based on the priorities of the registered factories.
static std::shared_ptr< IDevice > getDevice()
Returns the currently handled device.
static void openDevice(std::string name)
Opens a device which will then be handled by the manager.
The I3DDevice interface represents an output device for 3D sound.
Definition: I3DDevice.h:53
The IDeviceFactory interface opens an output device.
Definition: IDeviceFactory.h:36
The IDevice interface represents an output device for sound sources.
Definition: IDevice.h:47