In article <GY************ **@newsfe6-win.ntli.net>,
John Harrison <jo************ *@hotmail.comwr ote:
mark wrote:
In article <5b************ **@mid.individu al.net>,
Ian Collins <ia******@hotma il.comwrote:
mark wrote:
In article <5b************ *@mid.individua l.net>,
Ian Collins <ia******@hotma il.comwrote:
mark wrote:
In article <5b************ *@mid.individua l.net>,
Ian Collins <ia******@hotma il.comwrote:
mark wrote:
>class SORef {...};
>class SelectedFORef : public SORef {...};
>>
>>
>SOFORef SOCastToSOF(SOR ef sor) {
> SelectedFORef sof=nil;
What's nil?
nil == NULL.
Pascal version of NULL.
Then why hide it? You can't assign NULL to a class object, only a
pointer.
You can't apply a dynamic_cast to a class object, only a reference of a
pointer to one.
I am idiot.
Sorry.
Should be:
class SOObject {...};
typdef class SOObject * SORef;
class SelectedFileObj ect : public SOObject {...};
typedef class SelectedFileObj ect * SelectedFORef;
It's seldom, if ever, a good idea to hide pointer types behind typedefs.
Have to. The class pointer is available to plugins. And C++ doesn't like
plugins. So I typedef as a struct * for plugins and use accessor
routines.
That's not a reason that makes any sense to me, (not saying it is wrong
though).
>SOFORef SOCastToSOF(SOR ef sor) {
This is an accessor routine for plugins.
The debugger shows it to still be a SelectedFORef class instance.
> SelectedFORef sof=nil;
sof=dynamic_cas t<SelectedFORef >(sor);
return sof;
};
Why not
SelectedFORef sof = dynamic_cast<Se lectedFORef>(so r);
Did try that. Makes no difference.
Would the typedef actually screw things up?
No.
Does class SOObject have at least one virtual function? You need at
least one virtual function for dynamic_cast to work.
When you say the cast is not working, what *exactly* do you mean? How
can you tell the cast is not working?
Mac OS X gdb debugger.
Inspecting sor with XCode/gdb shows it to be a SelectedFileObj ect
underneath. It's type is listed as such and not the base class SORef.
So the dynamic_cast should work (according to the C++ book I have,
virtual
john
Here's the full class definitions.
class SelectedObject {
UInt16 refCt;
SelObjectClass objectClass;
OSType ready;
protected:
SOOwnerID ID; // need to identify where the SO belongs. An SO in one
view will have
// different select flags to an SO in another view
SelObjectType objectType; // NYI
SelectionFlag selections;
static CFMutableSetRef soCache;
static void SOCacheSetProc( const void* value, void* ctx);
friend SORef CheckSOCache(Se lObjectClass objClass, UInt16 objType,
SOOwnerID iID, void* data);
virtual OSStatus CheckCache(SelO bjectClass objClass, UInt16 dataType,
void* data,
SORef *sor);
// the arrays are used to send one select/deselect event when a whole
lot
// of objects are selected/deselected. Sending 1000+ deselected
events is not a good
// idea
static CritRgn recentSelRgn;
static CFMutableSetRef recentlySelecte d;
static CFMutableSetRef recentlyDeselec ted;
static OSStatus PostMassSelOfOw ner(SOOwnerID ID, Boolean selOrDesel,
CFArrayRef itsItems);
static OSStatus PostMassSelectE vents(SOOwnerID whichID=0); // clears
both arrays after sending
// dtEventKindObje ctsSelected & dtEventKindObje ctsSelected
// If zero is passed, all are sent (in seperate events for each ID)
OSStatus AddToSelected() ;
OSStatus AddToDeselected ();
void SOCleanup();
public:
SelectedObject( SelObjectClass theObjClass, SOOwnerID ID);
SelectedObject( const SelectedObject &obj);
virtual ~SelectedObject ();
UInt16 Retain();
UInt16 Release();
SelObjectClass GetObjectClass( );
virtual SelObjectType GetObjectType() ; // NYI. Will always return
zero.
SOOwnerID GetOwnerID();
virtual CFStringRef CopySOString();
virtual UInt64 GetSOData64(); // these two will always return zero
for the base class
virtual UInt32 GetSOData32(); // it is up to the subclasses to return
the correct values
SelectionFlag GetSelectFlags( );
void DefineSelectFla g(SelectionFlag theFlags, Boolean newValue);
void ToggleSelectFla g(SelectionFlag theFlags);
Boolean IsSelectedOr(Se lectionFlag whichFlags); // returns true if
any of the passed flags are set
Boolean IsSelectedAnd(S electionFlag whichFlags); // returns true if
all of the passed flags are set
Boolean AnySelection(); // returns true is any flag is set
void PostSelectedEve nt(Boolean selected);
virtual Boolean operator==(Sele ctedObject &obj);
virtual void DebugPrint(UInt 32 v=0); // printf
virtual CFStringRef DebugString(UIn t32 v=0); // CFStringRef -CFShow
};
//-----------------------------------------------------------------------
--------------
class SelectedFileObj ect:public SelectedObject {
OSType sfoReady;
protected:
FSRef fsr;
virtual OSStatus CheckCache(SelO bjectClass objClass, UInt16 dataType,
void* data,
SORef *sor);
void SFOCleanup();
public:
SelectedFileObj ect(const FSRef* fsrptr, SOOwnerID ID);
SelectedFileObj ect(const char* cpath, SOOwnerID ID);
SelectedFileObj ect(CFURLRef url, SOOwnerID ID);
SelectedFileObj ect(const SelectedFileObj ect &obj);
~SelectedFileOb ject();
CFStringRef CopySOString();
UInt64 GetSOData64();
UInt32 GetSOData32();
FSRef* GetFSRefPtr();
virtual CFStringRef CopyName();
Boolean operator==(Sele ctedFileObject &obj);
void DebugPrint(UInt 32 v=0); // printf
CFStringRef DebugString(UIn t32 v=0); // CFStringRef -CFShow
};
typedef class SelectedFileObj ect* SelectedFORef;
typedef SelectedFORef SOFORef;