[Top][All Lists]

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

[Libcdio-devel] starting a C++ wrapper

From: R. Bernstein
Subject: [Libcdio-devel] starting a C++ wrapper
Date: Sun, 6 Nov 2005 10:33:21 -0500

I've started writing a little C++ wrapper for libcdio. If you feel
strongly about C++ coding or style or have comments about this
endeavor, now would be a good time to voice them.

The overall interface in C++ should look a bit neater for example
cdio_get_devices(), cdio_get_devices_with_cap() and
cdio_get_devices_with_cap_ret() can become something like
CdIo::GetDevices(). Routines that should not have been in libcdio's C
interface won't be there in C++, e.g. all of the cdio_have_xxx() routines.

I don't know C++ all that well and its various idioms. I don't have a
C++ style (other than probably an extension of the my C style which
some find unusual). 

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++? 

Here's what I have so far, stripped down without copyleft or many
docmentation comments as to make things easier to get to the crux of
the code. Compare the below <cdio/cdio.h> and <cdio/device.h>. I've
tested this code on a simple program. 

// File CdIo.h
#ifndef __CDIO_CXX_H__
#define __CDIO_CXX_H__

#include <cdio/cdio.h>

// CdIo is still around as a #define for CdIo_t. We now want to use the
// name as a class.
#ifdef CdIo
#undef CdIo

class CdIo {
  CdIo() { p_cdio=(CdIo_t *) NULL; }
  ~CdIo() { cdio_destroy(p_cdio); };
#include "Device.h"
//#include "Disc.h" ...
  CdIo_t *p_cdio;

#endif /* __CDIO_CXX_H__ */

// File Device.h

driver_return_code_t CloseTray (const char *psz_drive, 
                                /*in/out*/ driver_id_t *p_driver_id);
driver_return_code_t EjectMedia ();
void FreeDeviceList (char * device_list[]);
char *GetDefaultDevice ();
char *GetDefaultDevice(/*in/out*/ driver_id_t *p_driver_id);

// File Device.cpp
CdIo::CloseTray (const char *psz_drive, /*in/out*/ driver_id_t *p_driver_id) 
  return cdio_close_tray(psz_drive, p_driver_id);

CdIo::EjectMedia () 
  return cdio_eject_media(&p_cdio);

CdIo::FreeDeviceList (char * device_list[]) 

reply via email to

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