RefCountedPointer Objects


#1

I just changed a nasty class I had to a base class and subs. But now I can’t find the syntax to cast the class back to a sub-class and call a method.

I have this: ‘MeshFrameBase::Ptr deliveredFrame’ and need to call the getPixelBuffer() method of a specific sub-class (that base class doesn’t have, it’s platform specific).

I can’t do:

Or any variations, or any kind of constructor I can think of. Am I a bit outside the box here, or is there some C++ Kung Fu I can use?

Bruce


#2

OK, the only way I could find was this:

[code] MeshFrameBase* bsFrame = deliveredFrame;
MeshFrameCVPixelBufferRef* sourceFrame = dynamic_cast<MeshFrameCVPixelBufferRef*>(bsFrame);

[/code]

Is that about the size of it? Anything nicer?

Bruce


#3

What about :
dynamic_cast<MeshFrameCVPixelBufferRef*>((MeshFrameBase*)deliveredFrame);

After all, the template Ptr will return a MeshFrameBase* if you use the MeshFrameBase* cast operator, and then, it’s standard dynamic casting.


#4

Yeah, that got it, thanks.

Bruce