CCfits
2.5
|
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 00271 class Table : public ExtHDU //## Inherits: <unnamed>%3804A126EB10 00272 { 00273 00274 public: 00275 00276 00277 00278 class NoSuchColumn : public FitsException //## Inherits: <unnamed>%397CB0970174 00279 { 00280 public: 00281 NoSuchColumn (const String& name, bool silent = true); 00282 NoSuchColumn (int index, bool silent = true); 00283 00284 protected: 00285 private: 00286 private: //## implementation 00287 }; 00288 00289 00290 00291 class InvalidColumnSpecification : public FitsException //## Inherits: <unnamed>%3B1E52D703B0 00292 { 00293 public: 00294 InvalidColumnSpecification (const String& msg, bool silent = true); 00295 00296 protected: 00297 private: 00298 private: //## implementation 00299 }; 00300 Table(const Table &right); 00301 virtual ~Table(); 00302 00303 // ! return reference to a column given by column name. 00304 virtual Column& column (const String& colName, bool caseSensitive = true) const; 00305 virtual Column& column (int colIndex // ! return reference to a column given by a column index number 00306 ) const; 00307 virtual long rows () const; 00308 void updateRows (); 00309 void rows (long numRows); 00310 virtual void deleteColumn (const String& columnName); 00311 // Insert one or more blank rows into a FITS column. 00312 void insertRows (long first, long number = 1); 00313 void deleteRows (long first, long number = 1); 00314 void deleteRows (const std::vector<long>& rowList); 00315 virtual long getRowsize () const; 00316 virtual int numCols () const; 00317 virtual const ColMap& column () const; 00318 virtual ColMap& column (); 00319 virtual void copyColumn(const Column& inColumn, int colIndx, bool insertNewCol=true); 00320 00321 public: 00322 // Additional Public Declarations 00323 00324 protected: 00325 Table (FITSBase* p, HduType xtype, const String &hduName, int rows, // ! Number of rows in table at creation, to be used to initialize NAXIS2 00326 const std::vector<String>& columnName, const std::vector<String>& columnFmt, const std::vector<String>& columnUnit = std::vector<String>(), int version = 1); 00327 // To be called by reading operations. 00328 Table (FITSBase* p, HduType xtype, const String &hduName = String(""), int version = 1); 00329 // ExtHDU constructor for getting ExtHDUs by number. 00330 // Necessary since EXTNAME is a reserved not required 00331 // keyword. 00332 Table (FITSBase* p, HduType xtype, int number); 00333 00334 virtual std::ostream & put (std::ostream &s) const; 00335 void init (bool readFlag = false, const std::vector<String>& keys = std::vector<String>()); 00336 virtual void setColumn (const String& colname, Column* value); 00337 void reindex (int startNum, bool isInsert); 00338 void numCols (int value); 00339 00340 // Additional Protected Declarations 00341 00342 private: 00343 virtual void initRead (); 00344 virtual void readTableHeader (int ncols, std::vector<String>& colName, std::vector<String>& colFmt, std::vector<String>& colUnit) = 0; 00345 // deep erasure , to be called by assignment and dtors. 00346 void clearData (); 00347 void copyData (const Table& right); 00348 00349 // Additional Private Declarations 00350 00351 private: //## implementation 00352 // Data Members for Class Attributes 00353 int m_numCols; 00354 00355 // Data Members for Associations 00356 ColMap m_column; 00357 00358 // Additional Implementation Declarations 00359 friend class Column; 00360 }; 00361 00362 // Class CCfits::Table::NoSuchColumn 00363 00364 // Class CCfits::Table::InvalidColumnSpecification 00365 00366 // Class CCfits::Table 00367 00368 inline long Table::rows () const 00369 { 00370 00371 return axis(1); 00372 } 00373 00374 inline void Table::rows (long numRows) 00375 { 00376 00377 naxes(1) = numRows; 00378 } 00379 00380 inline int Table::numCols () const 00381 { 00382 return m_numCols; 00383 } 00384 00385 inline const ColMap& Table::column () const 00386 { 00387 return m_column; 00388 } 00389 00390 inline void Table::numCols (int value) 00391 { 00392 m_numCols = value; 00393 } 00394 00395 inline ColMap& Table::column () 00396 { 00397 return m_column; 00398 } 00399 00400 } // namespace CCfits 00401 00402 00403 #endif