libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libcdio-devel] starting a C++ wrapper


From: Peter Creath
Subject: Re: [Libcdio-devel] starting a C++ wrapper
Date: Sun, 6 Nov 2005 14:53:36 -0500

On 11/6/05, R. Bernstein <address@hidden> wrote:
> One question I have is whether to put the C++ headers alongside C
> headers.  So for example we have <cdio/cdio.h>. for C++ I've been
> using CamelCase so do I add <cdio/CdIO.h> for C++?

Definitely don't use camelcase for filenames.  Not all filesystems
(e.g. Windows, Mac) are case-senstivie, so cdio.h and CdIo.h would
collide.  Plus they're a pain to type.  You're better off either using
".hpp" for C++ header files, or simply wrapping C++ class declarations
within "#ifdef __cplusplus" statements.

As far as a class name goes, I'd recommend something that's easier to
type than CdIo.  I think I'd shoot myself if I had to type that.  :) 
Also, in terms of method names, a lot of people seem to be keen on the
Java convention, of starting classes with capitals, but methods with
lower-case.  E.g.: "MyClass::myMethod()".  I don't really have a
preference on that, though others might.

And in terms of a C++ abstraction, I'm not sure a basic wrapper really
provides much (other than a maintenance headache).  Where C++ really
shines is when you create a real object-oriented layer.

For example, instead of passing around an abstract "CdIo" object
(what's a CdIo?), maybe you have a CdDrive class that gets passed
around.  After all, you're opening and closing the tray for a
particular drive.  CdIo, if it is a class, should be a static class,
which represents the entire subsystem.  You can query it for drives,
etc.  E.g. CdDrive *drive = CdIo::GetDefaultDevice();

Is there any particular motivation for delving into a C++ wrapper if
you're not a C++ aficionado?

    -P




reply via email to

[Prev in Thread] Current Thread [Next in Thread]