Isis 3 Developer Reference
Table.h
Go to the documentation of this file.
1 #ifndef Table_h
2 #define Table_h
3 
25 #include "Blob.h"
26 #include <vector>
27 #include "TableRecord.h"
28 
29 namespace Isis {
30  class Pvl;
77  class Table : public Isis::Blob {
78  public:
82  enum Association {
83  None,
87  };
88 
89  // Constructors and Destructors
90  Table();
91  Table(const QString &tableName, TableRecord &rec);
92  Table(const QString &tableName);// Only use this constructor for reading in an existing table
93  Table(const QString &tableName, const QString &file);
94  Table(const QString &tableName, const QString &file,
95  const Pvl &fileHeader);
96  Table(const Table &other);
97  Table &operator=(const Isis::Table &other);
98 
99  ~Table();
100 
101 
102  friend std::istream&operator>>(std::istream &is, Table &table);
103  friend std::ostream&operator<<(std::ostream &os, Table &table);
104 
105  void SetAssociation(const Table::Association assoc);
106  bool IsSampleAssociated();
107  bool IsLineAssociated();
108  bool IsBandAssociated();
109 
110  int Records() const;
111  int RecordFields() const;
112  int RecordSize() const;
113 
114  // Read a record
115  TableRecord &operator[](const int index);
116 
117  // Add a record
118  void operator+=(TableRecord &rec);
119 
120  // Update a record
121  void Update(const TableRecord &rec, const int index);
122 
123  // Delete a record
124  void Delete(const int index);
125 
126  void Clear();
127 
128 
129  static QString toString(Table table, QString fieldDelimiter=",");
130 
131  protected:
132  void ReadInit();
133  void ReadData(std::istream &stream);
134  void WriteInit();
135  void WriteData(std::fstream &os);
136 
138  std::vector<char *> p_recbufs;
139 
140  int p_records;
144  bool p_swap;
145  };
146 };
147 
148 #endif
149 
void WriteInit()
Virtual Function to prepare labels for writing.
Definition: Table.cpp:376
int Records() const
Returns the number of records.
Definition: Table.cpp:224
friend std::ostream & operator<<(std::ostream &os, Table &table)
Association
Definition: Table.h:82
bool IsBandAssociated()
Checks to see if association is Bands.
Definition: Table.cpp:215
TableRecord p_record
The current table record.
Definition: Table.h:137
int RecordSize() const
Returns the number of bytes per record.
Definition: Table.cpp:242
bool IsLineAssociated()
Checks to see if association is Lines.
Definition: Table.cpp:205
Definition: Table.h:84
void WriteData(std::fstream &os)
Virtual function to write the data.
Definition: Table.cpp:406
int p_records
Holds record count read from labels, may differ from the size of p_recbufs.
Definition: Table.h:140
Definition: Table.h:86
~Table()
Destroys the Table object.
Definition: Table.cpp:176
std::vector< char * > p_recbufs
Buffers containing record values.
Definition: Table.h:138
Association p_assoc
Association Type of the table.
Definition: Table.h:143
void Clear()
Clear the table of all records.
Definition: Table.cpp:307
int RecordFields() const
Returns the number of fields per record.
Definition: Table.cpp:233
friend std::istream & operator>>(std::istream &is, Table &table)
Definition: Blob.h:64
static QString toString(Table table, QString fieldDelimiter=",")
Definition: Table.cpp:413
Definition: Table.h:85
void Delete(const int index)
Deletes a TableRecord from the Table.
Definition: Table.cpp:297
Container for cube-like labels.
Definition: Pvl.h:135
void Update(const TableRecord &rec, const int index)
Updates a TableRecord.
Definition: Table.cpp:288
void SetAssociation(const Table::Association assoc)
Sets the association to the input parameter.
Definition: Table.cpp:185
Table & operator=(const Isis::Table &other)
Sets the Table equal to the input Table object.
Definition: Table.cpp:154
Class for storing Table blobs information.
Definition: Table.h:77
void operator+=(TableRecord &rec)
Adds a TableRecord to the Table.
Definition: Table.cpp:263
TableRecord & operator[](const int index)
Reads a TableRecord from the Table.
Definition: Table.cpp:253
Definition: Table.h:83
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void ReadInit()
Virtual function to validate PVL table information.
Definition: Table.cpp:313
bool IsSampleAssociated()
Checks to see if association is Samples.
Definition: Table.cpp:195
Definition: TableRecord.h:54
void ReadData(std::istream &stream)
Virtual function to Read the data.
Definition: Table.cpp:351
bool p_swap
Only used for reading.
Definition: Table.h:144