Table.h
// Astrophysics Science Division,
// NASA/ Goddard Space Flight Center
// HEASARC
// http://heasarc.gsfc.nasa.gov
// e-mail: ccfits@legacy.gsfc.nasa.gov
//
// Original author: Ben Dorman
#ifndef TABLE_H
#define TABLE_H 1
// ExtHDU
#include "ExtHDU.h"
// FitsError
#include "FitsError.h"
namespace CCfits {
class Column;
} // namespace CCfits
#ifdef _MSC_VER
#include "MSconfig.h" // for truncation warning
#endif
#ifdef SSTREAM_DEFECT
#include <strstream>
#else
#include <sstream>
#endif
namespace CCfits {
class Table : public ExtHDU //## Inherits: <unnamed>%3804A126EB10
{
public:
class NoSuchColumn : public FitsException //## Inherits: <unnamed>%397CB0970174
{
public:
NoSuchColumn (const String& name, bool silent = true);
NoSuchColumn (int index, bool silent = true);
protected:
private:
private: //## implementation
};
class InvalidColumnSpecification : public FitsException //## Inherits: <unnamed>%3B1E52D703B0
{
public:
InvalidColumnSpecification (const String& msg, bool silent = true);
protected:
private:
private: //## implementation
};
Table(const Table &right);
virtual ~Table();
// ! return reference to a column given by column name.
virtual Column& column (const String& colName, bool caseSensitive = true) const;
virtual Column& column (int colIndex // ! return reference to a column given by a column index number
) const;
virtual long rows () const;
void updateRows ();
void rows (long numRows);
virtual void deleteColumn (const String& columnName);
// Insert one or more blank rows into a FITS column.
void insertRows (long first, long number = 1);
void deleteRows (long first, long number = 1);
void deleteRows (const std::vector<long>& rowList);
virtual long getRowsize () const;
virtual int numCols () const;
virtual const ColMap& column () const;
virtual ColMap& column ();
virtual void copyColumn(const Column& inColumn, int colIndx, bool insertNewCol=true);
public:
// Additional Public Declarations
protected:
Table (FITS* p, HduType xtype, const String &hduName, int rows, // ! Number of rows in table at creation, to be used to initialize NAXIS2
const std::vector<String>& columnName, const std::vector<String>& columnFmt, const std::vector<String>& columnUnit = std::vector<String>(), int version = 1);
// ctor for creating a Group Table
Table (FITS* p, int version = 1, const String & groupName = String(""));
// To be called by reading operations.
Table (FITS* p, HduType xtype, const String &hduName = String(""), int version = 1);
// ExtHDU constructor for getting ExtHDUs by number.
// Necessary since EXTNAME is a reserved not required
// keyword.
Table (FITS* p, HduType xtype, int number);
virtual std::ostream & put (std::ostream &s) const;
void init (bool readFlag = false, const std::vector<String>& keys = std::vector<String>());
virtual void setColumn (const String& colname, Column* value);
void reindex (int startNum, bool isInsert);
void numCols (int value);
// Additional Protected Declarations
private:
virtual void initRead ();
virtual void readTableHeader (int ncols, std::vector<String>& colName, std::vector<String>& colFmt, std::vector<String>& colUnit) = 0;
// deep erasure , to be called by assignment and dtors.
void clearData ();
void copyData (const Table& right);
// Additional Private Declarations
private: //## implementation
// Data Members for Class Attributes
int m_numCols;
// Data Members for Associations
ColMap m_column;
// Additional Implementation Declarations
friend class Column;
};
// Class CCfits::Table::NoSuchColumn
// Class CCfits::Table::InvalidColumnSpecification
// Class CCfits::Table
inline long Table::rows () const
{
return axis(1);
}
inline void Table::rows (long numRows)
{
naxes(1) = numRows;
}
inline int Table::numCols () const
{
return m_numCols;
}
inline const ColMap& Table::column () const
{
return m_column;
}
inline void Table::numCols (int value)
{
m_numCols = value;
}
inline ColMap& Table::column ()
{
return m_column;
}
} // namespace CCfits
#endif
CCfits::Table::updateRows
void updateRows()
update the number of rows in the table
Definition: Table.cxx:340
CCfits::Table::~Table
virtual ~Table()
destructor
Definition: Table.cxx:174
CCfits::Table::init
void init(bool readFlag=false, const std::vector< String > &keys=std::vector< String >())
Definition: Table.cxx:253
CCfits::ExtHDU::version
int version() const
return the extension version number.
Definition: ExtHDU.h:677
CCfits::HDU::axis
long axis(size_t index) const
return the size of axis numbered index [zero based].
Definition: HDU.h:983
CCfits::Table::getRowsize
virtual long getRowsize() const
return the optimal number of rows to read or write at a time
Definition: Table.cxx:495
CCfits::FITS
Memory object representation of a disk FITS file.
Definition: FITS.h:628
CCfits::FitsException
FitsException is the base class for all exceptions thrown by this library.
Definition: FitsError.h:93
CCfits::ExtHDU
base class for all FITS extension HDUs, i.e. Image Extensions and Tables.
Definition: ExtHDU.h:438
CCfits::HDU::index
int index() const
return the HDU number
Definition: HDU.h:993
CCfits::Table::NoSuchColumn::NoSuchColumn
NoSuchColumn(const String &name, bool silent=true)
Exception ctor for exception thrown if the requested column (specified by name) is not present...
Definition: Table.cxx:27
CCfits::Table::numCols
virtual int numCols() const
return the number of Columns in the Table (the TFIELDS keyword).
Definition: Table.h:393
CCfits::ColMap
std::multimap< std::string, CCfits::Column * > ColMap
Type definition for a table&#39;s column container.
Definition: CCfits.h:142
CCfits::Table::NoSuchColumn
Exception to be thrown on a failure to retrieve a column specified either by name or index number...
Definition: Table.h:289
CCfits::Table::column
virtual const ColMap & column() const
return a reference to the multimap containing the columns.
Definition: Table.h:398
CCfits::ExtHDU::name
const String & name() const
return the name of the extension.
Definition: ExtHDU.h:651
CCfits::Table
Definition: Table.h:282
CCfits::Table::Table
Table(const Table &right)
copy constructor
Definition: Table.cxx:56
CCfits::Table::deleteColumn
virtual void deleteColumn(const String &columnName)
delete a column in a Table extension by name.
Definition: Table.cxx:377
CCfits::Table::rows
virtual long rows() const
return the number of rows in the table (NAXIS2).
Definition: Table.h:381
CCfits::HDU::naxes
std::vector< long > & naxes()
return the HDU data axis array.
Definition: HDU.h:1086
CCfits::Column
Abstract base class for Column objects.
Definition: Column.h:841
CCfits::Table::insertRows
void insertRows(long first, long number=1)
insert empty rows into the table
Definition: Table.cxx:400
CCfits::Table::copyColumn
virtual void copyColumn(const Column &inColumn, int colIndx, bool insertNewCol=true)
copy a column (from different or same HDU and file) into an existing table HDU.
Definition: Table.cxx:504
CCfits::Table::deleteRows
void deleteRows(long first, long number=1)
delete a range of rows in a table.
Definition: Table.cxx:419