source: tags/release-1.2.2/src/Outputs/CatalogueWriter.hh

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

Starting to solve #50 - writing a number of classes to implement writing to different annotation files - have defined Karma and DS9 classes. Still to actually implement in the Duchamp code.

File size: 4.5 KB
Line 
1// -----------------------------------------------------------------------
2// CatalogueWriter.hh: Base class for writing results to output files
3// -----------------------------------------------------------------------
4// Copyright (C) 2006, Matthew Whiting, ATNF
5//
6// This program is free software; you can redistribute it and/or modify it
7// under the terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 2 of the License, or (at your
9// option) any later version.
10//
11// Duchamp is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14// for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Duchamp; if not, write to the Free Software Foundation,
18// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
19//
20// Correspondence concerning Duchamp may be directed to:
21//    Internet email: Matthew.Whiting [at] atnf.csiro.au
22//    Postal address: Dr. Matthew Whiting
23//                    Australia Telescope National Facility, CSIRO
24//                    PO Box 76
25//                    Epping NSW 1710
26//                    AUSTRALIA
27// -----------------------------------------------------------------------
28#ifndef DUCHAMP_CATALOGUE_WRITER_H_
29#define DUCHAMP_CATALOGUE_WRITER_H_
30
31#include <ios>
32#include <string>
33#include <vector>
34#include <duchamp/param.hh>
35#include <duchamp/fitsHeader.hh>
36#include <duchamp/Detection/detection.hh>
37#include <duchamp/Outputs/columns.hh>
38#include <duchamp/Utils/Statistics.hh>
39#include <duchamp/Cubes/cubes.hh>
40
41namespace duchamp {
42
43  /// @brief Base class for writing out catalogues. 
44  /// @details This class forms the basis for derived classes that
45  /// handle writing of the catalogue to different types of files. The
46  /// class makes no assumption about the type of output (eg. file or
47  /// stream etc), but it does hold pointers to all the metadata from
48  /// the cube, as well as to the object list. Implementations of the
49  /// individual writing methods is left up to the base class.
50  class CatalogueWriter
51  {
52  public:
53    CatalogueWriter();
54    CatalogueWriter(std::string name);
55    CatalogueWriter(const CatalogueWriter& other);
56    CatalogueWriter& operator= (const CatalogueWriter& other);
57    virtual ~CatalogueWriter(){};
58   
59    /// @brief open the catalogue for writing
60    virtual bool openCatalogue(std::ios_base::openmode mode = std::ios_base::out )=0;
61
62    /// @brief Write header information - not including parameters
63    virtual void writeHeader() = 0;
64
65    /// @brief Write the input parameters
66    virtual void writeParameters() = 0;
67
68    /// @brief Write out the entire catalogue
69    virtual void writeEntries();
70
71    /// @brief Write a single catalogue entry based on a detected object
72    virtual void writeEntry(Detection *object) = 0;
73   
74    /// @brief Write footer information -- stuff to come after the catalogue table
75    virtual void writeFooter() = 0;
76
77    /// @brief Close the catalogue (file/stream/whatever)
78    virtual bool closeCatalogue() = 0;
79
80    void setName(std::string s){itsName=s;};
81    std::string name(){return itsName;};
82    bool isOpen(){return itsOpenFlag;};
83    Catalogues::CatalogueSpecification columnSpec(){return *itsColumnSpecification;};
84    void setColumnSpec(Catalogues::CatalogueSpecification *cols){itsColumnSpecification = cols;};
85    void setParam(Param *par){itsParam=par;};
86    void setStats(Statistics::StatsContainer<float> *stats){itsStats=stats;};
87    void setHead(FitsHeader *head){itsHead=head;};
88    void setObjectList(std::vector<Detection> *objlist){itsObjectList=objlist;};
89
90    /// @brief Set up the pointers to point to the cube's metadata
91    void setup(Cube *cube);
92
93  protected:
94    /// @brief The name of the output file, if necessary
95    std::string itsName;
96    /// @brief Is the output open and suitable for writing
97    bool        itsOpenFlag;
98    /// @brief A pointer to the list of column specifications
99    Catalogues::CatalogueSpecification *itsColumnSpecification;
100    /// @brief A pointer to the set of input parameters
101    Param *itsParam;
102    /// @brief A pointer to the statistics used by the cube
103    Statistics::StatsContainer<float> *itsStats;
104    /// @brief A pointer to the fits header description
105    FitsHeader *itsHead;
106    /// @brief A pointer to the list of detected objects
107    std::vector<Detection> *itsObjectList;
108    /// @brief The cube dimensions
109    size_t *itsCubeDim;
110
111  };
112
113}
114
115
116#endif
Note: See TracBrowser for help on using the repository browser.