Re: what #ifdef's should I use?
Re: what #ifdef's should I use?
- Subject: Re: what #ifdef's should I use?
- From: Glenn Howes <email@hidden>
- Date: Mon, 6 Jan 2003 12:46:40 -0600
On Monday, January 6, 2003, at 11:34 AM, Stiphane Sudre wrote:
Potential problem:
To use C++ and Objective-C, your file extension may need to be .mm
which is not going to be recognized by the others compilers: Visual
Studio for instance.
Other potential problem:
I don't see how you expect to handle the Cocoa object in your code.
You will need to add additional ifdef in order to handle the
Objective-C mechanism (except if you're using the C API but the
problem still remains). This leads to wondering what the purpose of
MakeObject is.
First of all MyObject is not a Cocoa object, it's a generic C++ object
which needs some timer task time to work.
It's factored like this:
MyObjectFactory.h -- Contains definition of abstract base class
MyObject and MyObjectFactory
MyOjbectFactory.cp -- contains implementation shown before
MyNSView.h -- Contains definition of an an NSView with a void* where
I'll put my MyObject* reference
MyNSView.mm -- Contains implementation of my NSView subclass, #includes
"MyObjectFactory.h", calls factory method in init
MyBaseObject.h
MyBaseObject.cp -- generic implementation of MyObject which does
everything but self-idle
MyObjectCarbon.h
MyObjectCarbon.cp -- subclass of MyBaseObject which uses Carbon Timer
tasks (and may have other Carbon code later)
MyObjectCocoa.h
MyObjectCocoa.cp -- subclass of MyBaseObject which uses NSTimer
MyObjectWin.h
MyObjectWin.cp -- subclass of my MyBaseObject which uses whatever on
Windows
So when I build a project, I'll include the factory, and the
appropriate concrete object files, and when MyNSView asks for a
MyObject it'll get an appropriate one.
I should say I'm trying to keep my options open on what framework to
use, so the factory might get called by a cross platform view, such as
one from the Qt framework, or it might be called by Cocoa or Carbon, or
PowerPlant for that matter. That's why it's in C++ and not Objective-C.
And I suppose I could have a) put the object creation code in each of
my view classes, or b) used a real factory, but at least the logic in
one place, and the code compiles and runs. I just wanted to put in the
proper #ifdefs.
--glenn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.