00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef TABLE_H
00010 #define TABLE_H 1
00011
00012
00013 #include "ExtHDU.h"
00014
00015 #include "FitsError.h"
00016
00017 namespace CCfits {
00018 class Column;
00019
00020 }
00021
00022 #ifdef _MSC_VER
00023 #include "MSconfig.h"
00024 #endif
00025
00026 #ifdef HAVE_CONFIG_H
00027 #include "config.h"
00028 #endif
00029
00030 #ifdef SSTREAM_DEFECT
00031 #include <strstream>
00032 #else
00033 #include <sstream>
00034 #endif
00035
00036
00037 namespace CCfits {
00038
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
00313 virtual Column& column (const String& colName, bool caseSensitive = true) const;
00314 virtual Column& column (int colIndex
00315 ) const;
00316 virtual long rows () const;
00317 void updateRows ();
00318 void rows (long numRows);
00319 virtual void deleteColumn (const String& columnName);
00320
00321 void insertRows (long first, long number = 1);
00322 void deleteRows (long first, long number = 1);
00323 void deleteRows (const std::vector<long>& rowList);
00324 virtual long getRowsize () const;
00325 virtual int numCols () const;
00326 virtual const std::map<string, Column*>& column () const;
00327 virtual std::map<string, Column*>& column ();
00328
00329 public:
00330
00331
00332 protected:
00333 Table (FITSBase* p, HduType xtype, const String &hduName, int rows,
00334 const std::vector<String>& columnName, const std::vector<String>& columnFmt, const std::vector<String>& columnUnit = std::vector<String>(), int version = 1);
00335
00336 Table (FITSBase* p, HduType xtype, const String &hduName = String(""), int version = 1);
00337
00338
00339
00340 Table (FITSBase* p, HduType xtype, int number);
00341
00342 virtual std::ostream & put (std::ostream &s) const;
00343 void column (int columnNum, Column *value);
00344 void init (bool readFlag = false, const std::vector<String>& keys = std::vector<String>());
00345 virtual void setColumn (const String& colname, Column* value);
00346 void reindex ();
00347 void numCols (int value);
00348
00349
00350
00351 private:
00352 virtual void initRead ();
00353 virtual void readTableHeader (int ncols, std::vector<String>& colName, std::vector<String>& colFmt, std::vector<String>& colUnit) = 0;
00354
00355 void clearData ();
00356 void copyData (const Table& right);
00357
00358
00359
00360 private:
00361
00362 int m_numCols;
00363
00364
00365 std::map<string, Column*> m_column;
00366
00367
00368 friend class Column;
00369 };
00370
00371
00372
00373
00374
00375
00376
00377 inline long Table::rows () const
00378 {
00379
00380 return axis(1);
00381 }
00382
00383 inline void Table::rows (long numRows)
00384 {
00385
00386 naxes(1) = numRows;
00387 }
00388
00389 inline int Table::numCols () const
00390 {
00391 return m_numCols;
00392 }
00393
00394 inline const std::map<string, Column*>& Table::column () const
00395 {
00396 return m_column;
00397 }
00398
00399 inline void Table::numCols (int value)
00400 {
00401 m_numCols = value;
00402 }
00403
00404 inline std::map<string, Column*>& Table::column ()
00405 {
00406 return m_column;
00407 }
00408
00409 }
00410
00411
00412 #endif