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
00283 class Table : public ExtHDU
00284 {
00285
00286 public:
00287
00288
00289
00290 class NoSuchColumn : public FitsException
00291 {
00292 public:
00293 NoSuchColumn (const String& name, bool silent = true);
00294 NoSuchColumn (int index, bool silent = true);
00295
00296 protected:
00297 private:
00298 private:
00299 };
00300
00301
00302
00303 class InvalidColumnSpecification : public FitsException
00304 {
00305 public:
00306 InvalidColumnSpecification (const String& msg, bool silent = true);
00307
00308 protected:
00309 private:
00310 private:
00311 };
00312 Table(const Table &right);
00313 virtual ~Table();
00314
00315
00316 virtual Column& column (const String& colName, bool caseSensitive = true) const;
00317 virtual Column& column (int colIndex
00318 ) const;
00319 virtual long rows () const;
00320 void updateRows ();
00321 void rows (long numRows);
00322 virtual void deleteColumn (const String& columnName);
00323
00324 void insertRows (long first, long number = 1);
00325 void deleteRows (long first, long number = 1);
00326 void deleteRows (const std::vector<long>& rowList);
00327 virtual long getRowsize () const;
00328 virtual int numCols () const;
00329 virtual const std::map<string, Column*>& column () const;
00330 virtual std::map<string, Column*>& column ();
00331
00332 public:
00333
00334
00335 protected:
00336 Table (FITSBase* p, HduType xtype, const String &hduName, int rows,
00337 const std::vector<String>& columnName, const std::vector<String>& columnFmt, const std::vector<String>& columnUnit = std::vector<String>(), int version = 1);
00338
00339 Table (FITSBase* p, HduType xtype, const String &hduName = String(""), int version = 1);
00340
00341
00342
00343 Table (FITSBase* p, HduType xtype, int number);
00344
00345 virtual std::ostream & put (std::ostream &s) const;
00346 void column (int columnNum, Column *value);
00347 void init (bool readFlag = false, const std::vector<String>& keys = std::vector<String>());
00348 virtual void setColumn (const String& colname, Column* value);
00349 void reindex ();
00350 void numCols (int value);
00351
00352
00353
00354 private:
00355 virtual void initRead ();
00356 virtual void readTableHeader (int ncols, std::vector<String>& colName, std::vector<String>& colFmt, std::vector<String>& colUnit) = 0;
00357
00358 void clearData ();
00359 void copyData (const Table& right);
00360
00361
00362
00363 private:
00364
00365 int m_numCols;
00366
00367
00368 std::map<string, Column*> m_column;
00369
00370
00371 friend class Column;
00372 };
00373
00374
00375
00376
00377
00378
00379
00380 inline long Table::rows () const
00381 {
00382
00383 return axis(1);
00384 }
00385
00386 inline void Table::rows (long numRows)
00387 {
00388
00389 naxes(1) = numRows;
00390 }
00391
00392 inline int Table::numCols () const
00393 {
00394 return m_numCols;
00395 }
00396
00397 inline const std::map<string, Column*>& Table::column () const
00398 {
00399 return m_column;
00400 }
00401
00402 inline void Table::numCols (int value)
00403 {
00404 m_numCols = value;
00405 }
00406
00407 inline std::map<string, Column*>& Table::column ()
00408 {
00409 return m_column;
00410 }
00411
00412 }
00413
00414
00415 #endif