Async 1.8.0
AsyncAudioDeviceFactory.h
Go to the documentation of this file.
1
28#ifndef ASYNC_AUDIO_DEVICE_FACTORY_INCLUDED
29#define ASYNC_AUDIO_DEVICE_FACTORY_INCLUDED
30
31
32/****************************************************************************
33 *
34 * System Includes
35 *
36 ****************************************************************************/
37
38#include <string>
39#include <map>
40
41
42/****************************************************************************
43 *
44 * Project Includes
45 *
46 ****************************************************************************/
47
48
49
50/****************************************************************************
51 *
52 * Local Includes
53 *
54 ****************************************************************************/
55
56
57
58/****************************************************************************
59 *
60 * Forward declarations
61 *
62 ****************************************************************************/
63
64
65
66/****************************************************************************
67 *
68 * Namespace
69 *
70 ****************************************************************************/
71
72namespace Async
73{
74
75
76/****************************************************************************
77 *
78 * Forward declarations of classes inside of the declared namespace
79 *
80 ****************************************************************************/
81
82class AudioDevice;
83
84
85/****************************************************************************
86 *
87 * Defines & typedefs
88 *
89 ****************************************************************************/
90
96#define REGISTER_AUDIO_DEVICE_TYPE(_name, _class) \
97 AudioDevice *create_ ## _class(const std::string& dev_name) \
98 { return new _class(dev_name); } \
99 static bool _class ## _creator_registered = \
100 AudioDeviceFactory::instance().registerCreator(_name, \
101 create_ ## _class)
102
103
104
105/****************************************************************************
106 *
107 * Exported Global Variables
108 *
109 ****************************************************************************/
110
111
112
113/****************************************************************************
114 *
115 * Class definitions
116 *
117 ****************************************************************************/
118
129{
130 public:
131 typedef AudioDevice* (*CreatorFunc)(const std::string &dev_designator);
132
138 {
139 static AudioDeviceFactory the_factory;
140 return the_factory;
141 }
142
147
154 bool registerCreator(const std::string &name, CreatorFunc creator);
155
162 AudioDevice *create(const std::string &name, const std::string &dev_name);
163
168 std::string validDevTypes(void) const;
169
170 protected:
175
176
177 private:
178 typedef std::map<std::string, CreatorFunc> CreatorMap;
179
180 CreatorMap creator_map;
181
183 AudioDeviceFactory& operator=(const AudioDeviceFactory&);
184
185}; /* class AudioDeviceFactory */
186
187
188} /* namespace */
189
190#endif /* ASYNC_AUDIO_DEVICE_FACTORY_INCLUDED */
191
192
193
194/*
195 * This file has not been truncated
196 */
197
A factory class for audio devices.
bool registerCreator(const std::string &name, CreatorFunc creator)
Register a new audio device type.
AudioDevice *(*) CreatorFunc(const std::string &dev_designator)
AudioDevice * create(const std::string &name, const std::string &dev_name)
Create a new instance of the specified audio device type.
~AudioDeviceFactory(void)
Destructor.
static AudioDeviceFactory & instance(void)
Get the factory singleton instance.
std::string validDevTypes(void) const
List valid device types.
AudioDeviceFactory(void)
Default constuctor.
Base class for handling audio devices.
Namespace for the asynchronous programming classes.