CCfits 2.7
Table.h
1// Astrophysics Science Division,
2// NASA/ Goddard Space Flight Center
3// HEASARC
4// http://heasarc.gsfc.nasa.gov
5// e-mail: ccfits@legacy.gsfc.nasa.gov
6//
7// Original author: Ben Dorman
8
9#ifndef TABLE_H
10#define TABLE_H 1
11
12// ExtHDU
13#include "ExtHDU.h"
14// FitsError
15#include "FitsError.h"
16
17namespace CCfits {
18 class Column;
19
20} // namespace CCfits
21
22#ifdef _MSC_VER
23#include "MSconfig.h" // for truncation warning
24#endif
25
26
27#ifdef SSTREAM_DEFECT
28#include <strstream>
29#else
30#include <sstream>
31#endif
32
33
34namespace CCfits {
35
282 class Table : public ExtHDU //## Inherits: <unnamed>%3804A126EB10
283 {
284
285 public:
286
287
288
289 class NoSuchColumn : public FitsException //## Inherits: <unnamed>%397CB0970174
290 {
291 public:
292 NoSuchColumn (const String& name, bool silent = true);
293 NoSuchColumn (int index, bool silent = true);
294
295 protected:
296 private:
297 private: //## implementation
298 };
299
300
301
302 class InvalidColumnSpecification : public FitsException //## Inherits: <unnamed>%3B1E52D703B0
303 {
304 public:
305 InvalidColumnSpecification (const String& msg, bool silent = true);
306
307 protected:
308 private:
309 private: //## implementation
310 };
311 Table(const Table &right);
312 virtual ~Table();
313
314 // ! return reference to a column given by column name.
315 virtual Column& column (const String& colName, bool caseSensitive = true) const;
316 virtual Column& column (int colIndex // ! return reference to a column given by a column index number
317 ) const;
318 virtual long rows () const;
319 void updateRows ();
320 void rows (long numRows);
321 virtual void deleteColumn (const String& columnName);
322 // Insert one or more blank rows into a FITS column.
323 void insertRows (long first, long number = 1);
324 void deleteRows (long first, long number = 1);
325 void deleteRows (const std::vector<long>& rowList);
326 virtual long getRowsize () const;
327 virtual int numCols () const;
328 virtual const ColMap& column () const;
329 virtual ColMap& column ();
330 virtual void copyColumn(const Column& inColumn, int colIndx, bool insertNewCol=true);
331
332 public:
333 // Additional Public Declarations
334
335 protected:
336 Table (FITS* p, HduType xtype, const String &hduName, int rows, // ! Number of rows in table at creation, to be used to initialize NAXIS2
337 const std::vector<String>& columnName, const std::vector<String>& columnFmt, const std::vector<String>& columnUnit = std::vector<String>(), int version = 1);
338 // ctor for creating a Group Table
339 Table (FITS* p, int version = 1, const String & groupName = String(""));
340 // To be called by reading operations.
341 Table (FITS* p, HduType xtype, const String &hduName = String(""), int version = 1);
342 // ExtHDU constructor for getting ExtHDUs by number.
343 // Necessary since EXTNAME is a reserved not required
344 // keyword.
345 Table (FITS* p, HduType xtype, int number);
346
347 virtual std::ostream & put (std::ostream &s) const;
348 void init (bool readFlag = false, const std::vector<String>& keys = std::vector<String>());
349 virtual void setColumn (const String& colname, Column* value);
350 void reindex (int startNum, bool isInsert);
351 void numCols (int value);
352
353 // Additional Protected Declarations
354
355 private:
356 virtual void initRead ();
357 virtual void readTableHeader (int ncols, std::vector<String>& colName, std::vector<String>& colFmt, std::vector<String>& colUnit) = 0;
358 // deep erasure , to be called by assignment and dtors.
359 void clearData ();
360 void copyData (const Table& right);
361
362 // Additional Private Declarations
363
364 private: //## implementation
365 // Data Members for Class Attributes
366 int m_numCols;
367
368 // Data Members for Associations
369 ColMap m_column;
370
371 // Additional Implementation Declarations
372 friend class Column;
373 };
374
375 // Class CCfits::Table::NoSuchColumn
376
377 // Class CCfits::Table::InvalidColumnSpecification
378
379 // Class CCfits::Table
380
381 inline long Table::rows () const
382 {
383
384 return axis(1);
385 }
386
387 inline void Table::rows (long numRows)
388 {
389
390 naxes(1) = numRows;
391 }
392
393 inline int Table::numCols () const
394 {
395 return m_numCols;
396 }
397
398 inline const ColMap& Table::column () const
399 {
400 return m_column;
401 }
402
403 inline void Table::numCols (int value)
404 {
405 m_numCols = value;
406 }
407
409 {
410 return m_column;
411 }
412
413} // namespace CCfits
414
415
416#endif
Abstract base class for Column objects.
Definition Column.h:842
base class for all FITS extension HDUs, i.e. Image Extensions and Tables.
Definition ExtHDU.h:439
const String & name() const
return the name of the extension.
Definition ExtHDU.h:651
int version() const
return the extension version number.
Definition ExtHDU.h:677
Memory object representation of a disk FITS file.
Definition FITS.h:629
FitsException is the base class for all exceptions thrown by this library.
Definition FitsError.h:94
std::vector< long > & naxes()
return the HDU data axis array.
Definition HDU.h:1101
int index() const
return the HDU number
Definition HDU.h:1008
long axis(size_t index) const
return the size of axis numbered index [zero based].
Definition HDU.h:998
Exception to be thrown on a failure to retrieve a column specified either by name or index number.
Definition Table.h:290
Definition Table.h:283
virtual void copyColumn(const Column &inColumn, int colIndx, bool insertNewCol=true)
copy a column (from different or same HDU and file) into an existing table HDU.
Definition Table.cxx:504
virtual void deleteColumn(const String &columnName)
delete a column in a Table extension by name.
Definition Table.cxx:377
void insertRows(long first, long number=1)
insert empty rows into the table
Definition Table.cxx:400
virtual long rows() const
return the number of rows in the table (NAXIS2).
Definition Table.h:381
virtual const ColMap & column() const
return a reference to the multimap containing the columns.
Definition Table.h:398
virtual ~Table()
destructor
Definition Table.cxx:174
void updateRows()
update the number of rows in the table
Definition Table.cxx:340
void deleteRows(long first, long number=1)
delete a range of rows in a table.
Definition Table.cxx:419
void init(bool readFlag=false, const std::vector< String > &keys=std::vector< String >())
Definition Table.cxx:253
virtual long getRowsize() const
return the optimal number of rows to read or write at a time
Definition Table.cxx:495
virtual int numCols() const
return the number of Columns in the Table (the TFIELDS keyword).
Definition Table.h:393
Namespace enclosing all CCfits classes and globals definitions.
Definition AsciiTable.cxx:26
std::multimap< std::string, CCfits::Column * > ColMap
Type definition for a table's column container.
Definition CCfits.h:142