4 #ifndef GloriaFitsTable_h
5 #define GloriaFitsTable_h 1
21 #include "GloriaFitsHeader.h"
22 #include "GloriaTableColumn.h"
135 void ReadFitsFile(
string FitsFileName);
141 void ReadTextFile(
string TextFileName);
146 void WriteFitsFile(
string FitsFileName,
bool binary_tbl=
true);
151 void WriteTextFile(
string TextFileName,
int colWidth=10,
char ColumnSeparator =
' ');
156 void WriteTextStream(std::ostream& outF,
int colWidth=10,
char ColumnSeparator =
' ');
170 {
return _columns.at(iCol)->Name();};
174 {
return _nameMap.find(name)->second; };
178 {
return _columns.at(iCol)->Type(); };
182 {
return _columns.at(_nameMap.find(name)->second)->Type(); };
187 {
return _nameMap.find(name)!=_nameMap.end();};
191 {
return _columns.at(iCol); } ;
195 {
return _columns.at(_nameMap.find(name)->second); } ;
242 void AddColumn(
string Name,
TableColumnType Type,
string Unit =
"" ,
string Comment =
"" );
251 void AddColumn(
string Name, T empty,
string Unit =
"" ,
string Comment =
"" );
287 template <
class T0,
class T1>
288 inline void AddRow(T0 val0, T1 val1){
AddRow(); SetLast(0,val0); SetLast(1,val1);};
295 template <
class T0,
class T1,
class T2>
296 inline void AddRow(T0 val0, T1 val1, T2 val2){
AddRow(); SetLast(0,val0); SetLast(1,val1); SetLast(2,val2);};
302 template <
class T0,
class T1,
class T2,
class T3>
303 inline void AddRow(T0 val0, T1 val1, T2 val2, T3 val3)
304 { AddRow(); SetLast(0,val0); SetLast(1,val1); SetLast(2,val2);SetLast(3,val3);};
310 template <
class T0,
class T1,
class T2,
class T3,
class T4>
311 inline void AddRow(T0 val0, T1 val1, T2 val2, T3 val3, T4 val4)
312 { AddRow(); SetLast(0,val0); SetLast(1,val1); SetLast(2,val2);SetLast(3,val3);SetLast(4,val4);};
317 void SetValue(
string Name,
int iRow, T val);
323 void SetValue(
int iCol,
int iRow, T val);
329 void SetLast(
int iCol, T val);
334 void SetLast(
string Name, T val);
339 void GetValue(
string Name,
int iRow, T* val);
344 void GetValue(
int iCol,
int iRow, T* val);
348 void CopyTableRow(
GloriaFitsTable* source,
int isource,
int itarget=-1);
354 void AdjustColumns();
361 long* CreateSortIndex(
int iCol,
bool reverse=
false);
364 long* CreateSortIndex(
string name,
bool reverse=
false);
367 void SortTable(
int iCol,
bool reverse=
false);
370 void SortTable(
string name,
bool reverse=
false);
374 inline bool IsSorted() {
return (_nSorted == _nRow); } ;
378 {
return (_nSorted == _nRow && name == _sortName); } ;
387 void DeleteRow(
int iRow);
396 void DeleteColumn(
int iCol);
399 void DeleteColumn(
string name);
410 void Print( std::ostream& os,
int colWidth=10);
414 void InitializeEmptyTable();
string SortName()
Return name of the column used for table sorting.
Definition: GloriaFitsTable.h:381
TableColumnType
Enumerator for allowed column type classes.
Definition: GloriaTableColumn.h:46
TableColumnType GetColumnType(string name)
Returns type for given column name.
Definition: GloriaFitsTable.h:181
bool IsSorted()
Check if table is sorted.
Definition: GloriaFitsTable.h:374
int _sortColumn
ID of column used for sorting.
Definition: GloriaFitsTable.h:433
T & GetValueOf(int iCol, int iRow)
Returns value of given type, from given column index and row.
Definition: GloriaFitsTable.h:226
namespace for data storing and exchange formats
Definition: GloriaAstrometry.h:15
string _sortName
Name of column used for sorting.
Definition: GloriaFitsTable.h:430
GloriaTableColumnOf< T > * GetColumnOf(int iCol)
Returns pointer to the column of given type, for given column index.
Definition: GloriaFitsTable.h:200
void AddRow(T0 val0, T1 val1, T2 val2)
Add new row and set value to the first three columns.
Definition: GloriaFitsTable.h:296
void AddRow(T0 val0, T1 val1)
Add new row and set value to the first two columns.
Definition: GloriaFitsTable.h:288
bool IsSortedBy(string name)
Check if table is sorted by given column.
Definition: GloriaFitsTable.h:377
vector< T > & GetVectorOf(int iCol)
Returns data vector of given type, from given column index.
Definition: GloriaFitsTable.h:212
Abstract class. Used for deriving classes with different column types.
Definition: GloriaTableColumn.h:80
multimap< string, int > _nameMap
Column name map. Name is not always unique!
Definition: GloriaFitsTable.h:424
bool ColumnExists(string name)
Check if given column exists.
Definition: GloriaFitsTable.h:186
string GetColumnName(int iCol)
Returns name of column.
Definition: GloriaFitsTable.h:169
int GetColumnId(string name)
Returns column Id.
Definition: GloriaFitsTable.h:173
int _nSorted
Number of sorted rows.
Definition: GloriaFitsTable.h:427
T & GetValueOf(string name, int iRow)
Returns value of given type, from given column name and row.
Definition: GloriaFitsTable.h:233
Table column class for different content types.
Definition: GloriaTableColumn.h:185
int _nRow
Table size.
Definition: GloriaFitsTable.h:418
TableColumnType GetColumnType(int iCol)
Returns type of column.
Definition: GloriaFitsTable.h:177
int GetColumnNumber()
Returns number of defined columns.
Definition: GloriaFitsTable.h:163
GloriaTableColumn * GetColumn(int iCol)
Returns base class pointer for given column index.
Definition: GloriaFitsTable.h:190
GloriaTableColumnOf< T > * GetColumnOf(string name)
Returns pointer to the column of given type, for given column name.
Definition: GloriaFitsTable.h:206
Class for reading and processing fits tables in Luiza.
Definition: GloriaFitsTable.h:109
void AddRow(T val)
Add new row and set value to the first column.
Definition: GloriaFitsTable.h:281
int SortColumn()
Return name of the column used for table sorting.
Definition: GloriaFitsTable.h:384
void AddRow(T0 val0, T1 val1, T2 val2, T3 val3, T4 val4)
Add new row and set value to the first five columns.
Definition: GloriaFitsTable.h:311
GloriaTableColumn * GetColumn(string name)
Returns base class pointer for named column stored in the table.
Definition: GloriaFitsTable.h:194
int GetRowNumber()
Returns number of filled rows.
Definition: GloriaFitsTable.h:166
vector< T > & GetVectorOf(string name)
Returns data vector of given type, from given column name.
Definition: GloriaFitsTable.h:219
vector< GloriaTableColumn * > _columns
Column vector.
Definition: GloriaFitsTable.h:421
void AddRow(T0 val0, T1 val1, T2 val2, T3 val3)
Add new row and set value to the first four columns.
Definition: GloriaFitsTable.h:303