libcdorganizer is a library designed to abstract control of (hopefully) all cd organizer devices in a cross-platform library. It takes the basic functionality expected of an organizer (insert, eject, id) and implements it for whatever device it knows how to communicate with.
For developers who want to interface with the library as it exists, you want to see the function list (section 1.2).
For developers who want to extend the functionality of the library to include another device, check section 2.0.
In general, if a function returns a boolean value, it's a success / failure notification. Returning true means that the operation was successful. Returning false means that the operation failed. In the case of failure, recommend outputting a reason to stderr
One thing to note: For those devices that use the USB bus (all of them for now), the client program must initialize the bus. libcdorganizer does not initialize the USB bus. To make libusb initialize the bus, do the following:
Insert a disc into the specified slot. slot should be a valid range, and should be checked for.
Eject a disc from the specified slot. slot should be a valid slot number, and should be checked for.
Gets a unique identifier for the device. This must be unique for each device, but does not necessarily need to be unique for each device type. This is used to differentiate between individual organizers. This, combined with the organizer type, should be used to uniquely identify the organizer
Turns the LEDs on on the organizer. May or may not be supported by your device.
Turns the LEDs off on the organizer. May or may not be supported by your device
Sends a reset signal to the device. May or may not be supported by your device
Sends a request for some status. Device specific, may not be supported by your device
Checks whether the cdorganizer object is attached to a device it knows it can handle
Gets a string that describes what model of cd organizer you have attached to this object
Returns the maximum number of discs this organizer supports
This is the usb device pointer for the device this object is attached to
This is the handle used to access the usb device this is attached to
Returns a comma-separated list of devices that libcdorganizer knows how to control
Tries to associate a cdorganizer with the device dev on the usb interface. If it recognizes dev as something it can control, it returns a new cdorganizer attached to dev. If not, it returns 0
Returns a vector of all cd organizers recognized and found on the USB bus. Populates container with these organizers, then returns it
To initialize a vector of available devices, eject slot 42, wait 5 seconds, then insert slot 42:
#include <cdorganizer/cdorganizerFactory.h> #include <vector> //To hold organizers in #include <usb.h> //For usb bus initialization #include <iostream> //For cout / endl #include <unistd.h> //For sleep int main(int argc, char ** argv) { usb_init(); usb_find_busses(); usb_find_devices(); std::vector <cdorganizer *> myOrganizers; cdorganizerFactory::getAllOrganizers(myOrganizers); for(int index(0); index < myOrganizers.size(); index++) { std::cout << "Found an organizer called " << myOrganizers[index]->getOrganizerType() << " with ID " << myOrganizers[index]->getId() << std::endl; myOrganizers[index]->eject(42); sleep(5); myOrganizers[index]->insert(42); delete myOrganizers[index]; //Don't leak memory... } return 0; }
To compile, just run the standard arguments to g++, and add -lusb -lcdorganizer to it