Table.h

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

Generated on Fri Nov 3 17:09:05 2006 for CCfits by  doxygen 1.4.7