• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
what #ifdef's should I use?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: what #ifdef's should I use?
      • From: Stéphane Sudre <email@hidden>
  • Prev by Date: Re: foundation kit (help i'm new to cocoa)
  • Next by Date: Re: Localization w/ parameters
  • Previous by thread: Re: porting apps from NextStep to Cocoa
  • Next by thread: Re: what #ifdef's should I use?
  • Index(es):
    • Date
    • Thread