swift
audiodeviceinfo.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_MISC_AUDIO_AUDIODEVICE_H
7 #define SWIFT_MISC_AUDIO_AUDIODEVICE_H
8 
9 #include <QMetaType>
10 #include <QString>
11 
12 #include "misc/identifier.h"
13 #include "misc/metaclass.h"
14 #include "misc/swiftmiscexport.h"
15 #include "misc/valueobject.h"
16 
17 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::audio, CAudioDeviceInfo)
18 
19 namespace swift::misc::audio
20 {
26  class SWIFT_MISC_EXPORT CAudioDeviceInfo : public CValueObject<CAudioDeviceInfo>
27  {
28  public:
31  {
32  IndexName = CPropertyIndexRef::GlobalIndexCAudioDeviceInfo,
33  IndexDeviceType,
34  IndexDeviceTypeAsString,
35  IndexIdentifier
36  };
37 
40  {
41  InputDevice,
42  OutputDevice,
43  Unknown
44  };
45 
48 
50  CAudioDeviceInfo(DeviceType type, const QString &name);
51 
53  const QString &getName() const { return m_deviceName; }
54 
56  const QString &getMachineName() const { return m_identifier.getMachineName(); }
57 
59  const CIdentifier &getIdentifier() const { return m_identifier; }
60 
62  DeviceType getType() const { return static_cast<DeviceType>(m_type); }
63 
65  const QString &getTypeAsString() const { return deviceTypeToString(this->getType()); }
66 
68  bool isInputDevice() const { return this->getType() == InputDevice; }
69 
71  bool isOutputDevice() const { return this->getType() == OutputDevice; }
72 
74  bool isValid() const { return !m_deviceName.isEmpty() && (m_type != Unknown); }
75 
77  bool isDefault() const;
78 
80  bool matchesNameTypeMachineName(const CAudioDeviceInfo &device) const;
81 
83  bool matchesNameTypeMachineProcess(const CAudioDeviceInfo &device) const;
84 
86  static CAudioDeviceInfo getDefaultOutputDevice();
87 
89  static CAudioDeviceInfo getDefaultInputDevice();
90 
92  QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const;
93 
95  void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant);
96 
98  QString convertToQString(bool i18n = false) const;
99 
101  int comparePropertyByIndex(CPropertyIndexRef index, const CAudioDeviceInfo &compareValue) const;
102 
104  static const QString &deviceTypeToString(DeviceType t);
105 
106  private:
107  int m_type = static_cast<int>(Unknown);
108  QString m_deviceName;
109  CIdentifier m_identifier;
111 
114  SWIFT_METAMEMBER(type),
115  SWIFT_METAMEMBER(deviceName),
116  SWIFT_METAMEMBER(identifier));
117  };
118 } // namespace swift::misc::audio
119 
120 Q_DECLARE_METATYPE(swift::misc::audio::CAudioDeviceInfo)
122 
123 #endif // SWIFT_MISC_AUDIO_AUDIODEVICE_H
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition: identifier.h:29
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Value object encapsulating information of a audio device.
const QString & getMachineName() const
Machine name.
bool isInputDevice() const
Input device.
const CIdentifier & getIdentifier() const
Identifier.
const QString & getTypeAsString() const
Type as string.
bool isOutputDevice() const
Output device.
bool isValid() const
Valid audio device object?
const QString & getName() const
Get the device name.
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition: metaclass.h:73
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition: valueobject.h:65