globally remove all trailing whitespace from ardour code base.
[ardour.git] / libs / appleutility / CAComponent.h
1 /*      Copyright:      � Copyright 2005 Apple Computer, Inc. All rights reserved.
2
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.
8
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.
23
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.
29
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.
37 */
38 /*=============================================================================
39         CAComponent.h
40
41 =============================================================================*/
42
43 #ifndef __CAComponent_h__
44 #define __CAComponent_h__
45
46 #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
47         #include <CoreServices/CoreServices.h>
48 #else
49         #include <ConditionalMacros.h>
50         #include <CoreServices.h>
51 #endif
52
53 #include "CAComponentDescription.h"
54
55 class CAComponent
56 {
57 public:
58         CAComponent ()
59                 : mComp (0), mDesc(), mManuName(0), mAUName(0), mCompName(0), mCompInfo (0) {}
60                 
61                 // if next is specifed that is used to find the next component after that one
62         CAComponent (const ComponentDescription& inDesc, CAComponent* next = 0);
63         
64         CAComponent (const CAComponent& y)
65                 : mComp (0), mDesc(), mManuName(0), mAUName(0), mCompName(0), mCompInfo (0) { *this = y; }
66
67         CAComponent (const Component& comp);
68         
69         CAComponent (const ComponentInstance& compInst);
70
71         CAComponent (OSType inType, OSType inSubtype = 0, OSType inManu = 0);
72         
73         ~CAComponent ();
74         
75         CAComponent&    operator= (const CAComponent& y);
76         
77                 // returns true if this object references a valid component
78         bool                    IsValid () const { return Comp() != 0; }
79         
80         bool                    HasAUStrings() const {  SetCompNames (); return mManuName != 0; }
81
82                 // CFStringRef should be retained by caller if needed beyond lifetime of this object
83                 
84                 // Can return NULL if component doesn't follow AU naming conventions
85         CFStringRef             GetAUManu () const { SetCompNames (); return mManuName; }
86         CFStringRef             GetAUName () const { SetCompNames (); return mAUName ? mAUName : mCompName; }
87                 
88                 // Return value of NULL indicates a problem getting that information from the component
89         CFStringRef             GetCompName () const { SetCompNames(); return mCompName; }
90         CFStringRef             GetCompInfo () const { SetCompInfo(); return mCompInfo; }
91         
92         const CAComponentDescription&   Desc () const { return mDesc; }
93                         
94         OSStatus                Open (ComponentInstance& outInst) const
95         {
96                 return OpenAComponent (Comp(), &outInst);
97         }
98
99         OSStatus                        GetResourceVersion (UInt32 &outVersion) const;
100         
101         const Component&                Comp() const { return mComp; }
102         
103         void                    Print(FILE* file = stdout) const;
104
105         OSStatus                        Save (CFPropertyListRef *outData) const;
106                 
107         OSStatus                        Restore (CFPropertyListRef &inData);
108         
109 private:
110         Component mComp;
111         CAComponentDescription mDesc;
112         
113         CFStringRef mManuName, mAUName, mCompName, mCompInfo;
114
115         void    SetCompNames () const;
116         void    SetCompInfo () const;
117         void    Clear ();
118 };
119
120 #endif