Table.h

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

Generated on Thu Jun 28 11:49:08 2007 for CCfits by  doxygen 1.4.7