CCfits 2.7

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

Table.h

    00001 //  Astrophysics Science Division,
    00002 //  NASA/ Goddard Space Flight Center
    00003 //  HEASARC
    00004 //  http://heasarc.gsfc.nasa.gov
    00005 //  e-mail: ccfits@legacy.gsfc.nasa.gov
    00006 //
    00007 //  Original author: Ben Dorman
    00008
    00009 #ifndef TABLE_H
    00010 #define TABLE_H 1
    00011
    00012 // ExtHDU
    00013 #include "ExtHDU.h"
    00014 // FitsError
    00015 #include "FitsError.h"
    00016
    00017 namespace CCfits {
    00018   class Column;
    00019
    00020 } // namespace CCfits
    00021
    00022 #ifdef _MSC_VER
    00023 #include "MSconfig.h" // for truncation warning
    00024 #endif
    00025
    00026
    00027 #ifdef SSTREAM_DEFECT
    00028 #include <strstream>
    00029 #else
    00030 #include <sstream>
    00031 #endif
    00032
    00033
    00034 namespace CCfits {
    00035
    00282   class Table : public ExtHDU  //## Inherits: <unnamed>%3804A126EB10
    00283   {
    00284
    00285     public:
    00286
    00287
    00288
    00289       class NoSuchColumn : public FitsException  //## Inherits: <unnamed>%397CB0970174
    00290       {
    00291         public:
    00292             NoSuchColumn (const String& name, bool silent = true);
    00293             NoSuchColumn (int index, bool silent = true);
    00294
    00295         protected:
    00296         private:
    00297         private: //## implementation
    00298       };
    00299
    00300
    00301
    00302       class InvalidColumnSpecification : public FitsException  //## Inherits: <unnamed>%3B1E52D703B0
    00303       {
    00304         public:
    00305             InvalidColumnSpecification (const String& msg, bool silent = true);
    00306
    00307         protected:
    00308         private:
    00309         private: //## implementation
    00310       };
    00311         Table(const Table &right);
    00312         virtual ~Table();
    00313
    00314         //  ! return reference to a column given by column name.
    00315         virtual Column& column (const String& colName, bool caseSensitive = true) const;
    00316         virtual Column& column (int colIndex    // ! return reference to a column given by a column index number
    00317         ) const;
    00318         virtual long rows () const;
    00319         void updateRows ();
    00320         void rows (long numRows);
    00321         virtual void deleteColumn (const String& columnName);
    00322         //  Insert one or more blank rows into a FITS column.
    00323         void insertRows (long first, long number = 1);
    00324         void deleteRows (long first, long number = 1);
    00325         void deleteRows (const std::vector<long>& rowList);
    00326         virtual long getRowsize () const;
    00327         virtual int numCols () const;
    00328         virtual const ColMap& column () const;
    00329         virtual ColMap& column ();
    00330         virtual void copyColumn(const Column& inColumn, int colIndx, bool insertNewCol=true);
    00331
    00332     public:
    00333       // Additional Public Declarations
    00334
    00335     protected:
    00336         Table (FITS* p, HduType xtype, const String &hduName, int rows,     // ! Number of rows in table at creation, to be used to initialize NAXIS2
    00337         const std::vector<String>& columnName, const std::vector<String>& columnFmt, const std::vector<String>& columnUnit = std::vector<String>(), int version = 1);
    00338         // ctor for creating a Group Table
    00339         Table (FITS* p, int version = 1, const String & groupName = String(""));
    00340         //  To be called by reading operations.
    00341         Table (FITS* p, HduType xtype, const String &hduName = String(""), int version = 1);
    00342         //  ExtHDU constructor for getting ExtHDUs by number.
    00343         //  Necessary since EXTNAME is a reserved not required
    00344         //  keyword.
    00345         Table (FITS* p, HduType xtype, int number);
    00346
    00347         virtual std::ostream & put (std::ostream &s) const;
    00348         void init (bool readFlag = false, const std::vector<String>& keys = std::vector<String>());
    00349         virtual void setColumn (const String& colname, Column* value);
    00350         void reindex (int startNum, bool isInsert);
    00351         void numCols (int value);
    00352
    00353       // Additional Protected Declarations
    00354
    00355     private:
    00356         virtual void initRead ();
    00357         virtual void readTableHeader (int ncols, std::vector<String>& colName, std::vector<String>& colFmt, std::vector<String>& colUnit) = 0;
    00358         //  deep erasure , to be called by  assignment and dtors.
    00359         void clearData ();
    00360         void copyData (const Table& right);
    00361
    00362       // Additional Private Declarations
    00363
    00364     private: //## implementation
    00365       // Data Members for Class Attributes
    00366         int m_numCols;
    00367
    00368       // Data Members for Associations
    00369         ColMap m_column;
    00370
    00371       // Additional Implementation Declarations
    00372       friend class Column;
    00373   };
    00374
    00375   // Class CCfits::Table::NoSuchColumn
    00376
    00377   // Class CCfits::Table::InvalidColumnSpecification
    00378
    00379   // Class CCfits::Table
    00380
    00381   inline long Table::rows () const
    00382   {
    00383
    00384     return axis(1);
    00385   }
    00386
    00387   inline void Table::rows (long numRows)
    00388   {
    00389
    00390     naxes(1) = numRows;
    00391   }
    00392
    00393   inline int Table::numCols () const
    00394   {
    00395      return m_numCols;
    00396   }
    00397
    00398   inline const ColMap& Table::column () const
    00399   {
    00400     return m_column;
    00401   }
    00402
    00403   inline void Table::numCols (int value)
    00404   {
    00405     m_numCols = value;
    00406   }
    00407
    00408   inline ColMap& Table::column ()
    00409   {
    00410     return m_column;
    00411   }
    00412
    00413 } // namespace CCfits
    00414
    00415
    00416 #endif