41 #if !defined(__CACFPlugIn_h__)
42 #define __CACFPlugIn_h__
49 #include <CoreAudio/CoreAudioTypes.h>
50 #include <CoreFoundation/CFPlugIn.h>
61 CACFPlugIn() : mCFPlugIn(NULL), mWillRelease(true) {}
62 CACFPlugIn(CFPlugInRef inCFPlugIn,
bool inWillRelease =
true) : mCFPlugIn(inCFPlugIn), mWillRelease(inWillRelease) {}
63 CACFPlugIn(CFURLRef inURL,
bool inWillRelease =
true) : mCFPlugIn(CFPlugInCreate(NULL, inURL)), mWillRelease(inWillRelease) {}
64 ~CACFPlugIn() { Release(); }
65 CACFPlugIn(
const CACFPlugIn& inObject) : mCFPlugIn(inObject.mCFPlugIn), mWillRelease(inObject.mWillRelease) { Retain(); }
66 CACFPlugIn& operator=(
const CACFPlugIn& inObject) { Release(); mCFPlugIn = inObject.mCFPlugIn; mWillRelease = inObject.mWillRelease; Retain();
return *
this; }
67 CACFPlugIn& operator=(CFPlugInRef inCFPlugIn) { Release(); mCFPlugIn = inCFPlugIn; mWillRelease =
true;
return *
this; }
70 void Retain() {
if(mWillRelease && (mCFPlugIn != NULL)) { CFRetain(mCFPlugIn); } }
71 void Release() {
if(mWillRelease && (mCFPlugIn != NULL)) { CFRelease(mCFPlugIn); mCFPlugIn = NULL; } }
73 CFPlugInRef mCFPlugIn;
78 void AllowRelease() { mWillRelease =
true; }
79 void DontAllowRelease() { mWillRelease =
false; }
80 bool IsValid()
const {
return mCFPlugIn != NULL; }
82 CFBundleRef GetBundle()
const { CFBundleRef theAnswer = NULL;
if(IsValid()) { theAnswer = CFPlugInGetBundle(mCFPlugIn); }
return theAnswer; }
83 CFStringRef CopyBundleID()
const { CFStringRef theAnswer = NULL; CFBundleRef theBundle = GetBundle();
if(IsValid() && (theBundle != NULL)) { theAnswer = CFBundleGetIdentifier(theBundle);
if(theAnswer != NULL) { CFRetain(theAnswer); } }
return theAnswer; }
84 UInt32 GetBundleVersion()
const { UInt32 theAnswer = 0; CFBundleRef theBundle = GetBundle();
if(IsValid() && (theBundle != NULL)) { theAnswer = CFBundleGetVersionNumber(theBundle); }
return theAnswer; }
85 CFDictionaryRef CopyBundleInfo()
const { CFDictionaryRef theAnswer = NULL; CFBundleRef theBundle = GetBundle();
if(IsValid() && (theBundle != NULL)) { theAnswer = CFBundleGetInfoDictionary(theBundle);
if(theAnswer != NULL) { CFRetain(theAnswer); } }
return theAnswer; }
86 CFArrayRef FindFactoriesForType(CFUUIDRef inTypeUUID)
const { CFArrayRef theAnswer = NULL;
if(IsValid()) { theAnswer = CFPlugInFindFactoriesForPlugInTypeInPlugIn(inTypeUUID, mCFPlugIn); }
return theAnswer; }
90 CFPlugInRef GetCFPlugIn()
const {
return mCFPlugIn; }
91 CFPlugInRef CopyCFPlugIn()
const {
if(mCFPlugIn != NULL) { CFRetain(mCFPlugIn); }
return mCFPlugIn; }