[1061] | 1 | // ----------------------------------------------------------------------- |
---|
| 2 | // CatalogueSpecification.cc: Define the specification of a catalogue, |
---|
| 3 | // being a set of Columns |
---|
| 4 | // ----------------------------------------------------------------------- |
---|
| 5 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
| 6 | // |
---|
| 7 | // This program is free software; you can redistribute it and/or modify it |
---|
| 8 | // under the terms of the GNU General Public License as published by the |
---|
| 9 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
| 10 | // option) any later version. |
---|
| 11 | // |
---|
| 12 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
| 13 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
| 15 | // for more details. |
---|
| 16 | // |
---|
| 17 | // You should have received a copy of the GNU General Public License |
---|
| 18 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
| 19 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
| 20 | // |
---|
| 21 | // Correspondence concerning Duchamp may be directed to: |
---|
| 22 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
| 23 | // Postal address: Dr. Matthew Whiting |
---|
| 24 | // Australia Telescope National Facility, CSIRO |
---|
| 25 | // PO Box 76 |
---|
| 26 | // Epping NSW 1710 |
---|
| 27 | // AUSTRALIA |
---|
| 28 | // ----------------------------------------------------------------------- |
---|
| 29 | #include <duchamp/Outputs/CatalogueSpecification.hh> |
---|
| 30 | #include <duchamp/duchamp.hh> |
---|
| 31 | #include <duchamp/Outputs/columns.hh> |
---|
[1064] | 32 | #include <duchamp/Outputs/CatalogueSpecification.hh> |
---|
[1061] | 33 | #include <vector> |
---|
| 34 | #include <map> |
---|
| 35 | #include <string> |
---|
| 36 | |
---|
| 37 | namespace duchamp { |
---|
| 38 | |
---|
| 39 | namespace Catalogues { |
---|
| 40 | |
---|
| 41 | CatalogueSpecification::CatalogueSpecification(const CatalogueSpecification& other) |
---|
| 42 | { |
---|
| 43 | operator=(other); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | CatalogueSpecification& CatalogueSpecification::operator= (const CatalogueSpecification& other) |
---|
| 47 | { |
---|
| 48 | if(this == &other) return *this; |
---|
| 49 | this->itsColumnList = other.itsColumnList; |
---|
| 50 | this->itsTypeMap = other.itsTypeMap; |
---|
[1137] | 51 | this->itsCommentString = other.itsCommentString; |
---|
[1061] | 52 | return *this; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | void CatalogueSpecification::addColumn(Column col) |
---|
| 56 | { |
---|
[1064] | 57 | this->removeColumn(col.type()); |
---|
[1061] | 58 | this->itsColumnList.push_back(col); |
---|
| 59 | this->itsTypeMap[col.type()] = this->itsColumnList.size() - 1; |
---|
| 60 | |
---|
| 61 | } |
---|
| 62 | |
---|
[1064] | 63 | void CatalogueSpecification::removeColumn(std::string type) |
---|
| 64 | { |
---|
| 65 | if( this->itsTypeMap.find(type) != this->itsTypeMap.end() ) // already in list |
---|
| 66 | this->itsColumnList.erase( this->itsColumnList.begin()+this->itsTypeMap[type] ); |
---|
| 67 | |
---|
| 68 | } |
---|
| 69 | |
---|
[1137] | 70 | |
---|
| 71 | void CatalogueSpecification::outputTableHeader(std::ostream &stream, Catalogues::DESTINATION tableType, bool flagWCS) |
---|
| 72 | { |
---|
| 73 | /// @details |
---|
| 74 | /// Prints the header row for a table of detections. The columns |
---|
| 75 | /// that are included depend on the value of tableType, according |
---|
| 76 | /// to the Column::doCol() function. The format is a row of |
---|
| 77 | /// dashes, a row with column names, a row with column units, and |
---|
| 78 | /// another row of dashes. |
---|
| 79 | /// \param stream Where the output is written |
---|
| 80 | /// \param columns The vector list of Column objects |
---|
| 81 | /// \param tableType A string saying what format to use: one of |
---|
| 82 | /// "file", "log", "screen" or "votable" (although the latter |
---|
| 83 | /// shouldn't be used with this function). |
---|
| 84 | /// \param flagWCS A flag for use with Column::doCol(), specifying |
---|
| 85 | /// whether to use FINT or FTOT. |
---|
| 86 | |
---|
| 87 | stream << this->itsCommentString; |
---|
| 88 | for(size_t i=0;i<this->itsColumnList.size();i++) |
---|
| 89 | if(this->itsColumnList[i].doCol(tableType,flagWCS)) this->itsColumnList[i].printDash(stream); |
---|
| 90 | stream << "\n"<<this->itsCommentString; |
---|
| 91 | for(size_t i=0;i<this->itsColumnList.size();i++) |
---|
| 92 | if(this->itsColumnList[i].doCol(tableType,flagWCS)) this->itsColumnList[i].printTitle(stream); |
---|
| 93 | stream << "\n"<<this->itsCommentString; |
---|
| 94 | for(size_t i=0;i<this->itsColumnList.size();i++) |
---|
| 95 | if(this->itsColumnList[i].doCol(tableType,flagWCS)) this->itsColumnList[i].printUnits(stream); |
---|
| 96 | stream << "\n"<<this->itsCommentString; |
---|
| 97 | for(size_t i=0;i<this->itsColumnList.size();i++) |
---|
| 98 | if(this->itsColumnList[i].doCol(tableType,flagWCS)) this->itsColumnList[i].printDash(stream); |
---|
| 99 | stream << "\n"; |
---|
| 100 | |
---|
| 101 | for(size_t i=0;i<this->itsCommentString.size();i++) this->itsColumnList[0].widen(); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | |
---|
[1061] | 105 | } |
---|
| 106 | |
---|
| 107 | } |
---|