casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Member Functions | Private Attributes
casa::TBArray Class Reference

Holds a potentially multi-dimensional array. More...

#include <TBArray.h>

List of all members.

Public Member Functions

 TBArray (int row, int col, String type, String array)
 Constructor for a data array (in other words, an array found in the data of a table).
 TBArray (int keywordIndex, String type, String array)
 Constructor for a table keyword array (in other words, an array found in the table keywords).
 TBArray (String col, int index, String type, String array)
 Constructor for a field keyword array (in other words, an array found in the field keywords).
 TBArray (String type, String array)
 Constructor for a non-specific array.
 ~TBArray ()
bool isValid ()
 Returns true if the array is valid, false otherwise.
vector< int > getDimensions ()
 Returns the dimensions of the array in list format.
unsigned int dim ()
 Returns the dimensionality of the array.
int dimensionAt (unsigned int i)
 If the dimensions are thought of as a list (e.g., 2x4x2), then this method returns the ith dimension in the list.
bool isOneDimensional ()
 Returns true if the array is one-dimensional, false otherwise.
String getType ()
 Returns the type of the array.
vector< void * > * getData ()
 Returns the data representation.
int getRow ()
 Returns the row of the table where the array is located.
int getCol ()
 Returns the column of the table where the array is located.
bool sameLocationAs (TBArray *array)
 Returns true if the given array is in the same location as this array, false otherwise.
String getName (TBTable *table)
 Returns the name of this array, assuming that it belongs to the given table.
String dataAt (vector< int > d)
 Returns the data at the given coordinates, or blank if the coordinates are invalid.
void setDataAt (vector< int > d, String newVal)
 Sets the data at the given coordinates to the given value.
bool dimensionIsValid (vector< int > d)
 Returns true if the given coordinates are valid for this array, false otherwise.
String toFlattenedString ()
 Returns a "flattened" String representation of this array.
bool contains (String value)
 Returns true if this array contains the given value, false otherwise.
bool containsBetween (String value1, String value2)
 Returns true if this array contains any value that is between the two given values, false otherwise.
bool containsLessThan (String value)
 Returns true if this array contains any value that is less than the given value, false otherwise.
bool containsGreaterThan (String value)
 Returns true if this array contains any value that is greater than the given value, false otherwise.

Private Member Functions

void parseArray (String *table)
 Parses the given String into the array.
String parseRow (String &str, vector< void * > *r, vector< int > d, int x)
 Helper for parseArray().
void parseMultidimensionalTable (String str)
 Helper for parseArray().
void insertPlaceholders (vector< void * > *r, vector< int > d, int x)
 Helper for parseArray().
String toFlattenedString (vector< void * > *row, int d)
 Helper method for toFlattenedString();.
bool contains (vector< void * > *data, int n, String v)
 Helper method for contains().
bool containsBetween (vector< void * > *data, int n, double v1, double v2)
 Helper method for containsBetween().
bool containsLessThan (vector< void * > *data, int n, double v)
 Helper method for containsLessThan().
bool containsGreaterThan (vector< void * > *data, int n, double v)
 Helper method for containsGreaterThan().
void deleteData (vector< void * > *data, int n)
 Deletes the data in the given row.

Private Attributes

vector< int > dimensions
 Holds the dimensions of this array.
vector< void * > data
 Data representation.
bool valid
 Indicates whether the array is valid or not.
String type
 The type of the array.
int row
 The row of the array for data arrays, or the keyword index for other arrays.
int col
 The column of the array for data arrays, invalid for other arrays.
bool oneDim
 Indicates whether this array is one-dimensional or not.
bool isData
 Indicates whether this is a data array or not.
bool isColKeyword
 Indicates whether this is a field keyword array or not.
String field
 Holds the field name for a field keyword array, empty otherwise.

Detailed Description

Holds a potentially multi-dimensional array.

Synopsis

A TBArray holds a array object as used by the table browser. The data is represented by String values, while the array structure is represented by vectors of void*s. For all but the "last" dimension, the void*s point to other vector<void*>s, and on the last dimension the void*s point to Strings. NOTE: this class is mostly obsolete now that the browser uses the TBData structure.

Definition at line 55 of file TBArray.h.


Constructor & Destructor Documentation

casa::TBArray::TBArray ( int  row,
int  col,
String  type,
String  array 
)

Constructor for a data array (in other words, an array found in the data of a table).

Takes as input the row and column of the array in table, the type of table, and the String holding the values of the array which need to be parsed.

casa::TBArray::TBArray ( int  keywordIndex,
String  type,
String  array 
)

Constructor for a table keyword array (in other words, an array found in the table keywords).

Takes as input the index of the keyword in the table keywords list, the type of the array, and the String holding the values of the array which need to be parsed.

casa::TBArray::TBArray ( String  col,
int  index,
String  type,
String  array 
)

Constructor for a field keyword array (in other words, an array found in the field keywords).

Takes as input the name of the field, the index of the keyword in the field keywords list, the type of the array, and the String holding the values of the array which need to be parsed.

casa::TBArray::TBArray ( String  type,
String  array 
)

Constructor for a non-specific array.

Takes as input the type of the array and the String holding the values of the array which need to be parsed.


Member Function Documentation

Returns true if this array contains the given value, false otherwise.

bool casa::TBArray::contains ( vector< void * > *  data,
int  n,
String  v 
) [private]

Helper method for contains().

bool casa::TBArray::containsBetween ( String  value1,
String  value2 
)

Returns true if this array contains any value that is between the two given values, false otherwise.

bool casa::TBArray::containsBetween ( vector< void * > *  data,
int  n,
double  v1,
double  v2 
) [private]

Helper method for containsBetween().

Returns true if this array contains any value that is greater than the given value, false otherwise.

bool casa::TBArray::containsGreaterThan ( vector< void * > *  data,
int  n,
double  v 
) [private]

Helper method for containsGreaterThan().

Returns true if this array contains any value that is less than the given value, false otherwise.

bool casa::TBArray::containsLessThan ( vector< void * > *  data,
int  n,
double  v 
) [private]

Helper method for containsLessThan().

String casa::TBArray::dataAt ( vector< int >  d)

Returns the data at the given coordinates, or blank if the coordinates are invalid.

void casa::TBArray::deleteData ( vector< void * > *  data,
int  n 
) [private]

Deletes the data in the given row.

unsigned int casa::TBArray::dim ( )

Returns the dimensionality of the array.

For example, a 4x4 array would return 2 while a 4x4x4 array would return 3.

int casa::TBArray::dimensionAt ( unsigned int  i)

If the dimensions are thought of as a list (e.g., 2x4x2), then this method returns the ith dimension in the list.

bool casa::TBArray::dimensionIsValid ( vector< int >  d)

Returns true if the given coordinates are valid for this array, false otherwise.

Returns the column of the table where the array is located.

This is only valid for data arrays.

vector<void*>* casa::TBArray::getData ( )

Returns the data representation.

In all but the last dimension, the void*s point to vector<void*>s; in the last dimension the void*s point to Strings.

Returns the dimensions of the array in list format.

Returns the name of this array, assuming that it belongs to the given table.

For data arrays: "[table name][[row],[col]]"; for table keyword arrays: "[table name] [keyword name]"; for field keyword arrays: "[table name] [field name, keyword name]".

Returns the row of the table where the array is located.

This is only valid for data arrays.

Returns the type of the array.

void casa::TBArray::insertPlaceholders ( vector< void * > *  r,
vector< int >  d,
int  x 
) [private]

Helper for parseArray().

Creates placeholder objects (such as empty Strings and vectors) into the given row.

Returns true if the array is one-dimensional, false otherwise.

Returns true if the array is valid, false otherwise.

void casa::TBArray::parseArray ( String table) [private]

Parses the given String into the array.

Helper for parseArray().

Parses a table with dimension > 1.

String casa::TBArray::parseRow ( String str,
vector< void * > *  r,
vector< int >  d,
int  x 
) [private]

Helper for parseArray().

Parses a single row into the given vector.

Returns true if the given array is in the same location as this array, false otherwise.

For data arrays: true if the row and col values are equal; for table keyword arrays: true if they refer to the same keyword index; for field keyword arrays: true if the fields are the same and the keyword indices are the same.

void casa::TBArray::setDataAt ( vector< int >  d,
String  newVal 
)

Sets the data at the given coordinates to the given value.

This call does NOT write through to the underlying table; it only updates the data representation.

Returns a "flattened" String representation of this array.

Each cell is appended to the String separated by a space.

String casa::TBArray::toFlattenedString ( vector< void * > *  row,
int  d 
) [private]

Helper method for toFlattenedString();.


Member Data Documentation

int casa::TBArray::col [private]

The column of the array for data arrays, invalid for other arrays.

Definition at line 181 of file TBArray.h.

vector<void*> casa::TBArray::data [private]

Data representation.

Definition at line 168 of file TBArray.h.

vector<int> casa::TBArray::dimensions [private]

Holds the dimensions of this array.

Definition at line 165 of file TBArray.h.

Holds the field name for a field keyword array, empty otherwise.

Definition at line 193 of file TBArray.h.

Indicates whether this is a field keyword array or not.

Definition at line 190 of file TBArray.h.

bool casa::TBArray::isData [private]

Indicates whether this is a data array or not.

Definition at line 187 of file TBArray.h.

bool casa::TBArray::oneDim [private]

Indicates whether this array is one-dimensional or not.

Definition at line 184 of file TBArray.h.

int casa::TBArray::row [private]

The row of the array for data arrays, or the keyword index for other arrays.

Definition at line 178 of file TBArray.h.

The type of the array.

Definition at line 174 of file TBArray.h.

bool casa::TBArray::valid [private]

Indicates whether the array is valid or not.

Definition at line 171 of file TBArray.h.


The documentation for this class was generated from the following file: