1 #ifndef __CORE_FOUNDATION_BASICS__
2 #define __CORE_FOUNDATION_BASICS__
7 This file contains basics for supporting our objects as CoreFoundation
11 #include <CoreFoundation/CFRuntime.h>
13 #include "LinkedList.h"
15 void CoreFoundationObjectsRegister();
17 extern const CFStringRef gInternalCFObjectName
;
18 extern const CFStringRef gInternalProtectedCFObjectName
;
20 struct CoreFoundationHolder
;
22 class CoreFoundationObject
25 CoreFoundationHolder
* mHolder
;
28 CoreFoundationObject(CFStringRef objectType
);
31 CFStringRef mObjectType
;
34 virtual ~CoreFoundationObject();
36 // compares mHolder's pointer, if you override you need
37 // to also override Hash.
38 virtual Boolean
Equal(const CoreFoundationObject
* object
);
39 virtual CFHashCode
Hash();
40 virtual std::string
FormattingDescription(CFDictionaryRef options
);
41 virtual std::string
DebugDescription();
42 // default is to call delete. Complex objects with queues may wish to release the queue and use the queue finalizer to call delete.
43 virtual void Finalize();
45 // register your class with the CFRuntime. You must supply
46 // a class name for your object.
47 static void RegisterObject(CFStringRef name
, bool protectFromDelete
);
48 static CFTypeID
FindObjectType(CFStringRef name
);
49 static LinkedListHeader
* GetClassRegistryList();
51 void SetHolder(CoreFoundationHolder
* holder
) {mHolder
= holder
;}
52 CFTypeRef
GetCFObject() {return mHolder
;}
54 CFStringRef
GetTypeAsCFString();
59 struct CoreFoundationHolder
61 CFRuntimeBase mRuntimeBase
;
62 CoreFoundationObject
* mObject
;
63 // name should really be a CFStringRef, not std::string (better memory use)
64 static CoreFoundationHolder
* MakeHolder(CFStringRef name
, CoreFoundationObject
* object
);
65 static CoreFoundationObject
* ObjectFromCFType(CFTypeRef cfRef
);