27.01.2015 Views

CCfits - HEASARC - NASA

CCfits - HEASARC - NASA

CCfits - HEASARC - NASA

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3 Implementation Notes 8<br />

3 Implementation Notes<br />

This section comments on some of the design decisions for <strong>CCfits</strong>. We note the role of<br />

cfitsio in <strong>CCfits</strong> as the underlying "engine," the use of the C++ standard library. We also<br />

explain some of the choices made for standard library containers in the implementation<br />

- all of which is hidden from the user [as it should be].<br />

Most importantly, the library wraps rather than replaces the use of cfitsio library; it<br />

does not perform direct disk I/O. The scheme is designed to retain the well-developed<br />

facilities of cfitsio (in particular, the extended file syntax), and make them available to<br />

C++ programmers in an OO framework. Some efficiency is lost over a ’pure’ C++ FI-<br />

TS library, since the internal C implementation of many functions requires processing<br />

if blocks or switch statements that could be recoded in C++ using templates. However,<br />

we believe that the current version strikes a resonable compromise between developer<br />

time, utility and efficiency.<br />

The implementation of <strong>CCfits</strong> uses the C++ Standard Library containers and algorithms<br />

[also referred to as the Standard Template Library, (STL)] and exception handling. -<br />

Here is a summary of the rationale behind the implementation decisions made.<br />

• HDUs are contained within a FITS object using a std::multimap object.<br />

1. The map object constructs new array members on first reference<br />

2. Objects stored in the map are sorted on entry and retrieved efficiently using<br />

binary search techniques.<br />

3. The pointer-to-HDU implementation allows for polymorphism: one set of<br />

operations will process all HDU objects within the FITS file<br />

4. String objects (char∗ ) are represented by the std::string class, which has a<br />

rich public interface of search and manipulation facilities.<br />

• Scalar column data [one entry per cell] are implemented using std::vector<br />

objects.<br />

• Vector column data [multiple and either fixed or variable numbers of entries per<br />

cell] are implemented using std::vector objects. The std-<br />

::valarray template is intended for optimized numeric processing. valarrays are<br />

have the following desirable features:<br />

1. they are dynamic, but designed to be allocated in full on construction rather<br />

than dynamic resizing during operation: this is, what is usually needed in<br />

FITS files.<br />

2. They have built-in vectorized transcendental functions (e.g. std::valarray sin(const std::valarray& ).<br />

3. They provide std::valarray apply(T f(const T&)) operation, to apply a<br />

function f to each element<br />

Generated on Tue Dec 6 2011 16:12:51 for <strong>CCfits</strong> by Doxygen

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!