Slight fix to comment.
[ardour2.git] / libs / appleutility / CAComponentDescription.h
bloba681902b9159817890a395e550ba4aaa222e6ba7
1 /* Copyright: © Copyright 2005 Apple Computer, Inc. All rights reserved.
3 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
4 ("Apple") in consideration of your agreement to the following terms, and your
5 use, installation, modification or redistribution of this Apple software
6 constitutes acceptance of these terms. If you do not agree with these terms,
7 please do not use, install, modify or redistribute this Apple software.
9 In consideration of your agreement to abide by the following terms, and subject
10 to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
11 copyrights in this original Apple software (the "Apple Software"), to use,
12 reproduce, modify and redistribute the Apple Software, with or without
13 modifications, in source and/or binary forms; provided that if you redistribute
14 the Apple Software in its entirety and without modifications, you must retain
15 this notice and the following text and disclaimers in all such redistributions of
16 the Apple Software. Neither the name, trademarks, service marks or logos of
17 Apple Computer, Inc. may be used to endorse or promote products derived from the
18 Apple Software without specific prior written permission from Apple. Except as
19 expressly stated in this notice, no other rights or licenses, express or implied,
20 are granted by Apple herein, including but not limited to any patent rights that
21 may be infringed by your derivative works or by other works in which the Apple
22 Software may be incorporated.
24 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
25 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
26 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
28 COMBINATION WITH YOUR PRODUCTS.
30 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
31 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
34 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
35 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
36 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 /*=============================================================================
39 CAComponentDescription.h
41 =============================================================================*/
43 #ifndef __CAComponentDescription_h__
44 #define __CAComponentDescription_h__
46 #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
47 #include <CoreServices/CoreServices.h>
48 #include <AudioUnit/AudioUnit.h>
49 #else
50 #include <ConditionalMacros.h>
51 #include <CoreServices.h>
52 #include <AudioUnit.h>
53 #endif
55 #include "CACFDictionary.h"
56 #include <stdio.h>
57 #include <string.h>
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
63 void CAShowComponentDescription(const ComponentDescription *desc);
65 #ifdef __cplusplus
67 #endif
70 // ____________________________________________________________________________
72 // CAComponentDescription
73 class CAComponentDescription : public ComponentDescription {
74 public:
75 CAComponentDescription() { memset (this, 0, sizeof (ComponentDescription)); }
77 CAComponentDescription (OSType inType, OSType inSubtype = 0, OSType inManu = 0);
79 CAComponentDescription(const ComponentDescription& desc) { memcpy (this, &desc, sizeof (ComponentDescription)); }
81 // _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
83 // interrogation
85 bool IsAU () const;
87 bool IsAUFX() const { return componentType == kAudioUnitType_Effect; }
88 bool IsAUFM() const { return componentType == kAudioUnitType_MusicEffect; }
90 bool IsEffect () const { return IsAUFX() || IsAUFM() || IsPanner(); }
92 bool IsOffline () const { return componentType == 'auol'; }
94 bool IsFConv () const { return componentType == kAudioUnitType_FormatConverter; }
96 bool IsPanner () const { return componentType == kAudioUnitType_Panner; }
98 bool IsMusicDevice () const { return componentType == kAudioUnitType_MusicDevice; }
100 #ifndef MAC_OS_X_VERSION_10_4
101 bool IsGenerator () const { return componentType =='augn'; }
102 #else
103 bool IsGenerator () const { return componentType ==kAudioUnitType_Generator; }
104 #endif
106 bool IsOutput () const { return componentType == kAudioUnitType_Output; }
108 bool IsSource () const { return IsMusicDevice() || IsGenerator(); }
110 OSType Type () const { return componentType; }
111 OSType SubType () const { return componentSubType; }
112 OSType Manu () const { return componentManufacturer; }
114 int Count() const { return CountComponents(const_cast<CAComponentDescription*>(this)); }
116 // does a semantic match where "wild card" values for type, subtype, manu will match
117 bool Matches (const ComponentDescription &desc) const;
119 // _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
121 // other
123 void Print(FILE* file = stdout) const { _CAShowComponentDescription (this, file); }
125 OSStatus Save (CFPropertyListRef *outData) const;
126 OSStatus Restore (CFPropertyListRef &inData);
128 private:
129 static void _CAShowComponentDescription (const ComponentDescription *desc, FILE* file);
130 friend void CAShowComponentDescription (const ComponentDescription *desc);
133 inline bool operator< (const ComponentDescription& x, const ComponentDescription& y)
135 return memcmp (&x, &y, offsetof (ComponentDescription, componentFlags)) < 0;
138 inline bool operator== (const ComponentDescription& x, const ComponentDescription& y)
140 return !memcmp (&x, &y, offsetof (ComponentDescription, componentFlags));
143 inline bool operator!= (const ComponentDescription& x, const ComponentDescription& y)
145 return !(x == y);
148 #endif