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

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

Silencing some build warnings.

File size: 5.7 KB
Line 
1// -----------------------------------------------------------------------
2// columns.hh: Define the column class that formats Duchamp output.
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 COLUMNS_H
29#define COLUMNS_H
30
31#include <iostream>
32#include <iomanip>
33#include <string>
34#include <vector>
35
36namespace duchamp
37{
38
39  class Detection;
40  class FitsHeader;
41
42  /// A namespace controlling the formatting of columns of output for Duchamp.
43  namespace Catalogues
44  {
45
46    /// @brief An enumeration designed to cover the different output types
47    enum DESTINATION {FILE, SCREEN, LOG, VOTABLE};
48
49    /// @brief Enumerated precision categories
50    enum PrecType {prFLUX=3, prVEL=3, prXYZ=1, prPOS=6, prWPOS=2, prSNR=2};
51
52    /// @brief Base coordinate system reference for VOTables
53    const std::string coordRef="J2000";
54
55    ///  @brief Class to store information about a single column.
56    ///
57    ///  @details This contains information about a given column --
58    ///  its width, the precision associated with it, its title and
59    ///  the units.  Plus the usual array of accessor functions and so
60    ///  on.
61
62    class Column{
63    public:
64      Column();          ///< Basic constructor
65      Column(std::string type); //< calls the default constructor for the given type
66      Column(std::string type, std::string name, std::string units, int width, int prec, std::string ucd="", std::string datatype="", std::string colID="", std::string extraInfo=""); ///< Generic constructor
67      Column(const Column& c);///< Assignment constructor
68      Column& operator=(const Column& c); ///< Copy constructor
69      virtual ~Column(){}; ///< Default destructor;
70      //--------------
71      // basic accessor functions
72      //
73      int    getWidth(){return itsWidth;};         
74      void   setWidth(int i){itsWidth=i;};   
75      int    getPrecision(){return itsPrecision;};     
76      void   setPrecision(int i){itsPrecision=i;};
77      std::string getName(){return itsName;};         
78      void   setName(std::string s){itsName=s;}; 
79      std::string getUnits(){return itsUnits;};         
80      void   setUnits(std::string s){itsUnits=s;};
81      //? COLNAME getType(){return type;};
82      std::string type(){return itsType;};
83      void   setType(std::string type){itsType=type;};
84      std::string getUCD(){return itsUCD;};
85      void        setUCD(std::string s){itsUCD=s;};
86      std::string getDatatype(){return itsDatatype;};
87      void        setDatatype(std::string s){itsDatatype=s;};
88      std::string getColID(){return itsColID;};
89      void        setColID(std::string s){itsColID=s;};
90      std::string getExtraInfo(){return itsExtraInfo;};
91      void        setExtraInfo(std::string s){itsExtraInfo=s;};
92
93      //--------------
94      // other functions
95      //
96      /// @brief Make the column one space wider.
97      void   widen(){itsWidth++;};
98
99      /// @brief Increase the precision by one, widening the column if necessary.
100      void   upPrec(){itsPrecision++; itsWidth++;};
101
102      void   changePrec(int p);
103
104      //--------------
105      // Outputting functions -- all in columns.cc
106      //
107      /// @brief write the title of the column to the stream
108      void   printTitle(std::ostream &stream);
109
110      /// @brief write the units of the column to the stream
111      void   printUnits(std::ostream &stream);
112
113      /// @brief write dashes the full width of the column to the stream
114      void   printDash (std::ostream &stream);
115
116      /// @brief write blanks the full width of the column to the stream
117      void   printBlank(std::ostream &stream);
118
119      /// @brief Print a given value in a column with correct width & precision.
120      template <class T> void printEntry(std::ostream &stream, T value);
121
122      /// @brief Decides whether the column is used for a given table type
123      bool   doCol(DESTINATION dest, bool flagFint=true);
124
125
126    private:
127      std::string itsType;   ///< The type of the column - for reference purposes
128      std::string itsName;   ///< The title of the column
129      std::string itsUnits;  ///< The units that the values in the column are expressed in.
130      int itsWidth;          ///< How wide is the column (in ascii spaces)
131      int itsPrecision;      ///< What precision should be used to print the values? (If 0, the setprecision command is not used.)
132      std::string itsUCD;    ///< The UCD associated with the value
133      std::string itsDatatype; ///< What datatype do the values take?
134      std::string itsColID;  ///< The column ID
135      std::string itsExtraInfo; ///< Any other info? This can be the 'ref' entry for a VOTable field.
136    };
137
138    Column defaultColumn(std::string type);
139
140
141  }
142
143}
144
145#endif
146
Note: See TracBrowser for help on using the repository browser.