00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef TABLE_H
00013 #define TABLE_H 1
00014
00015
00016 #include "ExtHDU.h"
00017
00018 #include "FitsError.h"
00019
00020 namespace CCfits {
00021 class Column;
00022
00023 }
00024
00025 #ifdef _MSC_VER
00026 #include "MSconfig.h"
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
00281 {
00282
00283 public:
00284
00285
00286
00287 class NoSuchColumn : public FitsException
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:
00296 };
00297
00298
00299
00300 class InvalidColumnSpecification : public FitsException
00301 {
00302 public:
00303 InvalidColumnSpecification (const String& msg, bool silent = true);
00304
00305 protected:
00306 private:
00307 private:
00308 };
00309 Table(const Table &right);
00310 virtual ~Table();
00311
00312 const std::map<String,Column*>& column () const;
00313
00314 virtual Column& column (const String& colName) const;
00315 virtual Column& column (int colIndex
00316 ) const;
00317 virtual long rows () const;
00318 void updateRows ();
00319 void rows (long numRows);
00320 virtual void deleteColumn (const String& columnName);
00321
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
00329
00330 protected:
00331 Table (FITSBase* p, HduType xtype, const String &hduName, int rows,
00332 const std::vector<String>& columnName, const std::vector<String>& columnFmt, const std::vector<String>& columnUnit = std::vector<String>(), int version = 1);
00333
00334 Table (FITSBase* p, HduType xtype, const String &hduName = String(""), int version = 1);
00335
00336
00337
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
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
00354 void clearData ();
00355 void copyData (const Table& right);
00356
00357
00358
00359 private:
00360
00361 int m_numCols;
00362
00363
00364 std::map<string, Column*> m_column;
00365
00366
00367 friend class Column;
00368 };
00369
00370
00371
00372
00373
00374
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 }
00409
00410
00411 #endif