CCfits
2.6
|
This section comments on some of the design decisions for CCfits. We note the role of CFITSIO in CCfits as the underlying "engine" and the use of the C++ standard library. We also explain some of the choices made for standard library containers in the implementation - all of which is hidden from the user (as it should be).
Most importantly, the library wraps rather than replaces the use of CFITSIO library; it does not perform direct disk I/O. The scheme is designed to retain the well-developed facilities of CFITSIO (in particular, the extended file syntax), and make them available to C++ programmers in an OO framework. Some efficiency is lost over a 'pure' C++ FITS library, since the internal C implementation of many functions requires processing if blocks or switch statements that could be recoded in C++ using templates. However, we believe that the current version strikes a resonable compromise between developer time, utility and efficiency.
The implementation of CCfits uses the C++ Standard Library containers and algorithms (also referred to as the Standard Template Library, STL) and exception handling. Here is a summary of the rationale behind the implementation decisions made.
HDUs are contained within a FITS object using a std::multimap<string, HDU*> object.
Scalar column data [one entry per cell] are implemented using std::vector<T> objects.
Vector column data (multiple and either fixed or variable numbers of entries per cell) are implemented using std::vector<std::valarray <T> > objects. The std::valarray template is intended for optimized numeric processing. valarrays are have the following desirable features:
Exceptions are generated by a FitsException hierarchy which prints out messages on errors and returns control to wherever the exception is caught. Non-zero status values returned by CFITSIO are caught by subclass FitsError, which prints the string corresponding to an input status flag. FitsException's other subclasses are thrown on array bounds errors and other programming errors. Rare (we hope) errors that indicate programming flaws in the library throw FitsFatal errors that suggest that the user report the bug.