source: trunk/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
RevLine 
[1069]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// -----------------------------------------------------------------------
[1046]28#ifndef DUCHAMP_CATALOGUE_WRITER_H_
29#define DUCHAMP_CATALOGUE_WRITER_H_
30
[1049]31#include <ios>
[1046]32#include <string>
[1048]33#include <vector>
[1046]34#include <duchamp/param.hh>
[1048]35#include <duchamp/fitsHeader.hh>
[1046]36#include <duchamp/Detection/detection.hh>
[1061]37#include <duchamp/Outputs/columns.hh>
[1048]38#include <duchamp/Utils/Statistics.hh>
39#include <duchamp/Cubes/cubes.hh>
[1046]40
41namespace duchamp {
42
[1050]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.
[1046]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
[1049]60    virtual bool openCatalogue(std::ios_base::openmode mode = std::ios_base::out )=0;
[1046]61
62    /// @brief Write header information - not including parameters
63    virtual void writeHeader() = 0;
64
[1050]65    /// @brief Write the input parameters
[1048]66    virtual void writeParameters() = 0;
[1046]67
[1050]68    /// @brief Write out the entire catalogue
[1072]69    virtual void writeEntries();
[1050]70
71    /// @brief Write a single catalogue entry based on a detected object
[1048]72    virtual void writeEntry(Detection *object) = 0;
[1050]73   
74    /// @brief Write footer information -- stuff to come after the catalogue table
[1046]75    virtual void writeFooter() = 0;
76
[1050]77    /// @brief Close the catalogue (file/stream/whatever)
[1046]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;};
[1064]83    Catalogues::CatalogueSpecification columnSpec(){return *itsColumnSpecification;};
84    void setColumnSpec(Catalogues::CatalogueSpecification *cols){itsColumnSpecification = cols;};
[1048]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;};
[1050]89
90    /// @brief Set up the pointers to point to the cube's metadata
[1048]91    void setup(Cube *cube);
[1046]92
93  protected:
[1050]94    /// @brief The name of the output file, if necessary
[1046]95    std::string itsName;
[1050]96    /// @brief Is the output open and suitable for writing
[1046]97    bool        itsOpenFlag;
[1050]98    /// @brief A pointer to the list of column specifications
[1064]99    Catalogues::CatalogueSpecification *itsColumnSpecification;
[1050]100    /// @brief A pointer to the set of input parameters
[1048]101    Param *itsParam;
[1050]102    /// @brief A pointer to the statistics used by the cube
[1048]103    Statistics::StatsContainer<float> *itsStats;
[1050]104    /// @brief A pointer to the fits header description
[1048]105    FitsHeader *itsHead;
[1050]106    /// @brief A pointer to the list of detected objects
[1048]107    std::vector<Detection> *itsObjectList;
[1050]108    /// @brief The cube dimensions
[1049]109    size_t *itsCubeDim;
[1046]110
111  };
112
113}
114
115
116#endif
Note: See TracBrowser for help on using the repository browser.