[300] | 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 | // ----------------------------------------------------------------------- |
---|
[93] | 28 | #ifndef COLUMNS_H |
---|
| 29 | #define COLUMNS_H |
---|
| 30 | |
---|
| 31 | #include <iostream> |
---|
| 32 | #include <iomanip> |
---|
| 33 | #include <string> |
---|
| 34 | #include <vector> |
---|
| 35 | |
---|
[378] | 36 | namespace duchamp |
---|
| 37 | { |
---|
[144] | 38 | |
---|
[378] | 39 | class Detection; |
---|
| 40 | class FitsHeader; |
---|
[222] | 41 | |
---|
[528] | 42 | /// A namespace controlling the formatting of columns of output for Duchamp. |
---|
[1061] | 43 | namespace Catalogues |
---|
[378] | 44 | { |
---|
[1047] | 45 | |
---|
| 46 | /// @brief An enumeration designed to cover the different output types |
---|
| 47 | enum DESTINATION {FILE, SCREEN, LOG, VOTABLE}; |
---|
| 48 | |
---|
[528] | 49 | /// @brief Enumerated precision categories |
---|
[439] | 50 | enum PrecType {prFLUX=3, prVEL=3, prXYZ=1, prPOS=6, prWPOS=2, prSNR=2}; |
---|
[221] | 51 | |
---|
[1066] | 52 | /// @brief Base coordinate system reference for VOTables |
---|
[1044] | 53 | const std::string coordRef="J2000"; |
---|
| 54 | |
---|
[528] | 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 | |
---|
[1061] | 62 | class Column{ |
---|
[378] | 63 | public: |
---|
[1061] | 64 | Column(); ///< Basic constructor |
---|
| 65 | Column(std::string type); //< calls the default constructor for the given type |
---|
[1064] | 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 |
---|
[1061] | 67 | Column(const Column& c);///< Assignment constructor |
---|
| 68 | Column& operator=(const Column& c); ///< Copy constructor |
---|
| 69 | virtual ~Column(){}; ///< Default destructor; |
---|
[378] | 70 | //-------------- |
---|
| 71 | // basic accessor functions |
---|
| 72 | // |
---|
[1061] | 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;}; |
---|
[93] | 92 | |
---|
[378] | 93 | //-------------- |
---|
| 94 | // other functions |
---|
| 95 | // |
---|
[528] | 96 | /// @brief Make the column one space wider. |
---|
[1061] | 97 | void widen(){itsWidth++;}; |
---|
[222] | 98 | |
---|
[528] | 99 | /// @brief Increase the precision by one, widening the column if necessary. |
---|
[1061] | 100 | void upPrec(){itsPrecision++; itsWidth++;}; |
---|
[222] | 101 | |
---|
[540] | 102 | void changePrec(int p); |
---|
| 103 | |
---|
[378] | 104 | //-------------- |
---|
| 105 | // Outputting functions -- all in columns.cc |
---|
| 106 | // |
---|
[528] | 107 | /// @brief write the title of the column to the stream |
---|
[378] | 108 | void printTitle(std::ostream &stream); |
---|
[222] | 109 | |
---|
[528] | 110 | /// @brief write the units of the column to the stream |
---|
[378] | 111 | void printUnits(std::ostream &stream); |
---|
[222] | 112 | |
---|
[528] | 113 | /// @brief write dashes the full width of the column to the stream |
---|
[378] | 114 | void printDash (std::ostream &stream); |
---|
[222] | 115 | |
---|
[528] | 116 | /// @brief write blanks the full width of the column to the stream |
---|
[378] | 117 | void printBlank(std::ostream &stream); |
---|
[222] | 118 | |
---|
[528] | 119 | /// @brief Print a given value in a column with correct width & precision. |
---|
[378] | 120 | template <class T> void printEntry(std::ostream &stream, T value); |
---|
[93] | 121 | |
---|
[528] | 122 | /// @brief Decides whether the column is used for a given table type |
---|
[1061] | 123 | bool doCol(DESTINATION dest, bool flagFint=true); |
---|
[440] | 124 | |
---|
| 125 | |
---|
[378] | 126 | private: |
---|
[1067] | 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. |
---|
[1061] | 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? |
---|
[1067] | 134 | std::string itsColID; ///< The column ID |
---|
[1061] | 135 | std::string itsExtraInfo; ///< Any other info? This can be the 'ref' entry for a VOTable field. |
---|
[378] | 136 | }; |
---|
| 137 | |
---|
[1061] | 138 | Column defaultColumn(std::string type); |
---|
| 139 | |
---|
| 140 | |
---|
[378] | 141 | } |
---|
[93] | 142 | |
---|
[378] | 143 | } |
---|
[93] | 144 | |
---|
| 145 | #endif |
---|
| 146 | |
---|