source: trunk/src/Outputs/CatalogueWriter.hh @ 1064

Last change on this file since 1064 was 1064, checked in by MatthewWhiting, 12 years ago

Continuing Ticket #162 -- moving to the use of CatalogueSpecification?. Also fixing a bug where the VOTable column ID string was not being set (identified via the verification script!).

File size: 3.2 KB
Line 
1#ifndef DUCHAMP_CATALOGUE_WRITER_H_
2#define DUCHAMP_CATALOGUE_WRITER_H_
3
4#include <ios>
5#include <string>
6#include <vector>
7#include <duchamp/param.hh>
8#include <duchamp/fitsHeader.hh>
9#include <duchamp/Detection/detection.hh>
10#include <duchamp/Outputs/columns.hh>
11#include <duchamp/Utils/Statistics.hh>
12#include <duchamp/Cubes/cubes.hh>
13
14namespace duchamp {
15
16  /// @brief Base class for writing out catalogues. 
17  /// @details This class forms the basis for derived classes that
18  /// handle writing of the catalogue to different types of files. The
19  /// class makes no assumption about the type of output (eg. file or
20  /// stream etc), but it does hold pointers to all the metadata from
21  /// the cube, as well as to the object list. Implementations of the
22  /// individual writing methods is left up to the base class.
23  class CatalogueWriter
24  {
25  public:
26    CatalogueWriter();
27    CatalogueWriter(std::string name);
28    CatalogueWriter(const CatalogueWriter& other);
29    CatalogueWriter& operator= (const CatalogueWriter& other);
30    virtual ~CatalogueWriter(){};
31   
32    /// @brief open the catalogue for writing
33    virtual bool openCatalogue(std::ios_base::openmode mode = std::ios_base::out )=0;
34
35    /// @brief Write header information - not including parameters
36    virtual void writeHeader() = 0;
37
38    /// @brief Write the input parameters
39    virtual void writeParameters() = 0;
40
41    /// @brief Write out the entire catalogue
42    virtual void writeEntries() = 0;
43
44    /// @brief Write a single catalogue entry based on a detected object
45    virtual void writeEntry(Detection *object) = 0;
46   
47    /// @brief Write footer information -- stuff to come after the catalogue table
48    virtual void writeFooter() = 0;
49
50    /// @brief Close the catalogue (file/stream/whatever)
51    virtual bool closeCatalogue() = 0;
52
53    void setName(std::string s){itsName=s;};
54    std::string name(){return itsName;};
55    bool isOpen(){return itsOpenFlag;};
56    Catalogues::CatalogueSpecification columnSpec(){return *itsColumnSpecification;};
57    void setColumnSpec(Catalogues::CatalogueSpecification *cols){itsColumnSpecification = cols;};
58    void setParam(Param *par){itsParam=par;};
59    void setStats(Statistics::StatsContainer<float> *stats){itsStats=stats;};
60    void setHead(FitsHeader *head){itsHead=head;};
61    void setObjectList(std::vector<Detection> *objlist){itsObjectList=objlist;};
62
63    /// @brief Set up the pointers to point to the cube's metadata
64    void setup(Cube *cube);
65
66  protected:
67    /// @brief The name of the output file, if necessary
68    std::string itsName;
69    /// @brief Is the output open and suitable for writing
70    bool        itsOpenFlag;
71    /// @brief A pointer to the list of column specifications
72    Catalogues::CatalogueSpecification *itsColumnSpecification;
73    /// @brief A pointer to the set of input parameters
74    Param *itsParam;
75    /// @brief A pointer to the statistics used by the cube
76    Statistics::StatsContainer<float> *itsStats;
77    /// @brief A pointer to the fits header description
78    FitsHeader *itsHead;
79    /// @brief A pointer to the list of detected objects
80    std::vector<Detection> *itsObjectList;
81    /// @brief The cube dimensions
82    size_t *itsCubeDim;
83
84  };
85
86}
87
88
89#endif
Note: See TracBrowser for help on using the repository browser.