what #ifdef's should I use?
what #ifdef's should I use?
- Subject: what #ifdef's should I use?
- From: Glenn Howes <email@hidden>
- Date: Mon, 6 Jan 2003 11:08:57 -0600
I've a C++ object factory. If I'm compiling a Cocoa application, I want
this factory to return an object which will use an NSTimer to do an
idle routine. If I'm compiling a Carbon application, I want this
factory to return an object which will use a Carbon timer task. If this
code is compiled under windows, it'll return some 3rd object which does
some Windowsy way of handing idle time.
I could have my own defines in a prefix header, but there doesn't seem
to be any reason not to make this self contained.
I'm thinking along the lines of:
MyObject* MyFactory::MakeObject()
{
#if TARGET_API_MAC_CARBON
MyCarbonObject* result = new MyCarbonObject;
#elseif something else
MyCocoaObject* result = new MyCocoaObject;
#elseif windows something
MyWindowsObject* result = new MyWindowsObject
#else
error undefined
#endif
return result;
}
So which #defines should I use in these 3 cases?
And I suppose this isn't a true factory pattern cause the factory
doesn't get installed.
_______________________________________________
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.