Main Page | Class Hierarchy | Compound List | File List | Compound Members

BxArray Class Reference

Base class for all BinX array types. More...

#include <BxArray.h>

Inheritance diagram for BxArray:

BxDataObject BxObject BxArrayFixed BxArrayVariable List of all members.

Public Member Functions

 BxArray ()
 BxArray (int dim)
 BxArray (const BxArray &copy)
virtual void setByteOrder (BxByteOrder bo)
virtual char * toString (bool xml)
virtual bool toStream (FILE *)
virtual bool toStreamBinary (FILE *)
int getIndexFrom (int dim) const
int getIndexTo (int dim) const
int getCount (int dim) const
char * getDimName (int dim) const
int getElementSize () const
BxDataObjectget (int d1, int d2)
BxDataObjectget (int d1, int d2, int d3)
BxDataObjectget (int d1, int d2, int d3, int d4)
BxDataObjectgetMore (int d1,...)
virtual BxDataObjectget (int index)
virtual BxDataObjectgetNext ()
void setElementType (BxDataObject *elemObj)
void setDimensions (int dims)
bool setDimension (int, BxDimension *)
void setIndexFrom (int dim, int from)
void setIndexTo (int dim, int to)
void addDimension (BxDimension *)
void addDimensionInFront (BxDimension *)
bool addElement (BxDataObject *)
void toFirst ()

Detailed Description

BxArray is the base class for
  1. BxArrayFixed,
  2. BxArrayVariable,
  3. BxArrayStreamed.
Array is a unique data type in BinX as it differs in representation and operation from other abstract data types. An array can contain any primitive or abstract data type including any one of the array types. Different from the data type BxDataset, an array can only contain one data type. Yet, an array can contain a BxDataset, where each BxDataset instance contains several different data types as its sub-elements. Arrays have an unlimited number of dimensions. Required attributes are:
  1. arrayOffset_, which defaults to 0
  2. dimensions_, which defaults to 1
  3. dims_ array, which default to one entry
  4. elementSize_, which should be set to the number of bytes in a single array element.
This class uses the class BxArrayBuffer to manage staging chunks of the large array between memory and a binary file and making any specified data element available in the buffer.
Since: BinX version 1.0.


Constructor & Destructor Documentation

BxArray::BxArray  ) 
 

Default constructor.

Constructs an instance of the class BxArray. Default attribute values are assigned as follows:

       arrayOffset_ = 0;
       dimensions_ = 0;
       dims_ = NULL;
       elementType_ = NULL;
       arraybuf_ = NULL;
   

BxArray::BxArray int  dim  ) 
 

Construct an array having a specified number of dimensions.

The dims_ attribute is created to store the specified number of dimensions, but the dimension descriptions stored in this attribute are set to NULL. Default values for the other attributes are assigned as follows:

       arrayOffset = 0;
       dimensions_ = <value of input parameter dim>;
       dims_ = <a vector containing dim null-valued entries>;
       elementType_ = NULL;
       arraybuf_ = NULL;
   
Parameters:
dim The number of dimensions for the newly constructed array.

BxArray::BxArray const BxArray copy  ) 
 

Construct an array having attribute values identical to a specified BxArray object.

Attributes of the new array instance are initialized by copying attribute values from the specified input array. Uninitialized attribute values in the input array result in NULL valued attributes in the new array instance. If the attributes of the input array have been initialized, then the array structure of the new instance will be the same as the array structure of the input instance.
Upon completion of the copy operation, the two array instances are independent. They do not share array element objects and they must be individually destructed.

Parameters:
copy The BxArray instance whose attribute values are to be copied.


Member Function Documentation

void BxArray::addDimension BxDimension dimObj  ) 
 

Append a description of an (N+1)th dimension to an existing N-dimensional array.

An array dimension is described by a BxDimension object. A pointer to the description object is appended to the end of the dims_ attribute list. The number of array dimensions is incremented by one.
Upon completion of this method, the BxDimension object describing the new array dimension is linked to this array instance. Destruction of the BxDimension instance will be managed by the array instance.

Parameters:
dimObj A pointer to the object containing a description of the new array dimension.

void BxArray::addDimensionInFront BxDimension dimObj  ) 
 

Insert a description of a new 1st dimension, increasing the dimensions of an existing array.

An array dimension is described by a BxDimension object. The new dimension description is inserted at the beginning of the dims_ attribute list. The previously existing dimension description objects are moved forward one position in the list. The number of array dimensions is incremented by one.
Upon completion of this method, the BxDimension object describing the new array dimension is linked to this array instance. Destruction of the BxDimension instance will be managed by the array instance.

Parameters:
dimObj A pointer to the object containing a description of the new array dimension.

bool BxArray::addElement BxDataObject pElement  ) 
 

Copy a single new data element value to the next (available) array buffer element.

Successive calls to this method result in sequentially appending new array data element values at the end of the array. This method remembers the position of the next available array buffer slot for storing a new element value. For each method call, a single data element value is appended to the array. The dimensionality of the array is ignored.
If an array buffer has not been previously allocated for this array, then this method will allocate a buffer and store the new data element value in the buffer. If the array buffer is full, the buffer contents are written to an associated binary file and the new data element value is stored in the first entry of the buffer.
The input parameter value is copied into the array buffer. The caller is free to destruct the input parameter object when it is no longer needed.

Parameters:
pElement A pointer to the new data element value as a BxDataObject.
Returns:
true If the element value was successfully stored in the array buffer.

BxDataObject * BxArray::get int  index  )  [virtual]
 

Get a copy of a single data element from an array.

The data element to be retrieved from the array is identified by a single index value into the array. If the array consists of multiple dimensions, then the caller is responsible for multiplying the dimension extents times the respective index values for the desired data element. The index value must be specified as a zero-based offset into the array.
The specified array data element is copied to a BxDataObject instance and returned to the caller. The caller is responsible for destructing the returned object when it is no longer needed.
Implementation Notes:
The requested data element may or may not be resident in the buffer associated with this array. If the desired data element is not resident in the buffer, then the buffer is filled with the specified data element from the file associated with this array.

Parameters:
index Specifies the zero-based index of the array data element.
Returns:
A pointer to the data element value as a BxDataObject.

Reimplemented in BxArrayVariable.

BxDataObject * BxArray::get int  d1,
int  d2,
int  d3,
int  d4
 

Get a copy of a single data element from a four-dimensional array.

The data element to be retrieved from the array is identified by an index value for each dimension of the four-dimensional array. The index parameters are ordered. The slowest-moving index value is first, and the fastest-moving index value is last. All index values must be specified as zero-based offsets into the array.
The specified array data element is copied to a BxDataObject instance and returned to the caller. The caller is responsible for destructing the returned object when it is no longer needed.
Implementation Notes:
In the array attribute named dims_, the zero position in the dims_ list holds the description of the fastest-moving dimension.

Parameters:
d1,d2,d3,d4 Zero-based indices identifying an array data element.
Returns:
A pointer to the data element value as a BxDataObject.

BxDataObject * BxArray::get int  d1,
int  d2,
int  d3
 

Get a copy of a single data element from a three-dimensional array.

The data element to be retrieved from the array is identified by an index value for each dimension of the three-dimensional array. The index parameters are ordered. The slowest-moving index value is first, and the fastest-moving index value is last. All index values must be specified as zero-based offsets into the array.
The specified array data element is copied to a BxDataObject instance and returned to the caller. The caller is responsible for destructing the returned object when it is no longer needed.
Implementation Notes:
In the array attribute named dims_, the zero position in the dims_ list holds the description of the fastest-moving dimension.

Parameters:
d1,d2,d3 Zero-based indices identifying an array data element.
Returns:
A pointer to the data element value as a BxDataObject.

BxDataObject * BxArray::get int  d1,
int  d2
 

Get a copy of a single data element from a two-dimensional array.

The data element to be retrieved from the array is identified by an index value for each dimension of the two-dimensional array. The index parameters are ordered. The slow-moving index value is first, and the fast-moving index value is second. Both index values must be specified as zero-based offsets into the array.
The specified array data element is copied to a BxDataObject instance and returned to the caller. The caller is responsible for destructing the returned object when it is no longer needed.
Implementation Notes:
In the array attribute named dims_, the zero position in the dims_ list holds the description of the fastest-moving dimension.

Parameters:
d1,d2 Zero-based indices indentifying an array data element.
Returns:
A pointer to the data element value as a BxDataObject.

int BxArray::getCount int  dim  )  const
 

Get the number of data elements in a specified dimension of an array.

The number of data elements in a specified dimension of an array is defined by the dimension description object associated with the specified dimension of the array. The array dimension must be specified as a zero-based offset into the list of dimensions.
Exceptions:
If the dimension number is not within the range of valid dimension numbers for this array, then the method returns the value zero.

Parameters:
dim Specifies the array dimension, zero-based.
Returns:
The number of data elements in the specified array dimension.

char * BxArray::getDimName int  dim  )  const
 

Get the name of a specified dimension of an array.

The array dimension must be specified as a zero-based offset into the list of dimensions.
Exceptions:
If the dimension number is not within the range of valid dimension numbers for this array, then the method returns the value zero.

Parameters:
dim Specifies the dimension, zero-based.
Returns:
A null-terminated string containing the name of the array dimension.

int BxArray::getElementSize  )  const
 

Get the size of a single data element stored by an array.

The size of a data element is expressed as the number of bytes required to represent a single data element of the element type stored by the array.

Returns:
Size of a single data element in the array.

int BxArray::getIndexFrom int  dim  )  const
 

Get the indexFrom value describing a specified dimension of an array.

The array dimension must be specified as a zero-based offset into the list of dimensions.
Exceptions:
If the dimension number is not within the range of valid dimension numbers for this array, then the method returns the value zero.

Parameters:
dim Specifies the array dimension, zero-based.
Returns:
The indexFrom value for the specified array dimension.

int BxArray::getIndexTo int  dim  )  const
 

Get the indexTo value describing a specified dimension of an array.

The array dimension must be specified as a zero-based offset into the list of dimensions.
Exceptions:
If the dimension number is not within the range of valid dimension numbers for this array, then the method returns the value zero.

Parameters:
dim Specifies the array dimension, zero-based.
Returns:
The indexTo value for the specified array dimension.

BxDataObject * BxArray::getMore int  d1,
... 
 

Get a copy of a single data element from an N-dimensional array.

The data element to be retrieved from the array is identified by an index value for each dimension of the N-dimensional array. The number of index parameters must exactly match the number of dimensions for this array. The index parameters are ordered. The slowest-moving index value is first, and the fastest-moving index value is last. All index values must be specified as zero-based offsets into the array.
When this method is invoked on a variable array or a streamed array, the index value specified by the first input parameter may be greater than the currently known extent for the slowest-moving dimension of this array.
The specified array data element is copied to a BxDataObject instance and returned to the caller. The caller is responsible for destructing the returned object when it is no longer needed.
Implementation Notes:
In the array attribute named dims_, the zero position in the dims_ list holds the description of the fastest-moving dimension.

Parameters:
d1,... A va-list of zero-based index values identifying an array data element.
Returns:
A pointer to the data element value as a BxDataObject.

BxDataObject * BxArray::getNext  )  [virtual]
 

Get the next (available) single data element from an array.

Successive calls to this method result in a sequential retrieval of array data element values. This method remembers the position of the next value to be retrieved. For each method call, a single data element value is retrieved and returned based on the order in which the element values are stored within the array. The dimensionality of the array is ignored.
The selected array data element is copied to a BxDataObject instance and returned to the caller. The caller is responsible for destructing the returned object when it is no longer needed.

Returns:
A pointer to the data element value as a BxDataObject.

Reimplemented in BxArrayVariable.

void BxArray::setByteOrder BxByteOrder  bo  )  [virtual]
 

Set byte order for elements in an array.

Set the byte order for value associated with the array and the element type for the elements of the array.

Parameters:
bo A byte order instance defining the byte order for this array.

Reimplemented from BxDataObject.

bool BxArray::setDimension int  index,
BxDimension dimObj
 

Set or reset the dimension description for a specific dimension of an array.

An array dimension is described by a BxDimension object. The new dimension description is inserted in the dims_ attribute list at the specified position, replacing any dimension description previously occupying that position in the list. The position must be specified as a zero-based offset into the list. The number of array dimensions is unchanged by this method.
Upon completion of this method, the BxDimension object describing the new array dimension is linked to this array instance. Destruction of the BxDimension instance will be managed by the array instance.
Exceptions:
If the specified position index is not a valid dimension number for this array, then the method returns the value false.

Parameters:
index The position in dims_ to hold the dimObj.
dimObj The BxDimension object describing the array dimension.
Returns:
true If successfully set,
false If the specified index is not a valid dimension number.

void BxArray::setDimensions int  dims  ) 
 

Set or reset the number of array dimensions for an existing array instance.

If the number of dimenions for this array has been set previously, then the number of dimensions is reset to the newly specified number. The dims_ attributes, describing each dimension of the array is released, a new dims_ attribute of appropriate size is created and each entry is set to NULL. Use BxArray::setDimension to initialise these attribute values.
If the current dimensions value is the same as the newly specified dimension value then no action is performed by this method.

Parameters:
dims Specifies the number of array dimensions.

void BxArray::setElementType BxDataObject elemObj  ) 
 

Set or reset the type of data element stored by an array.

Sets the array attribute recording the type of data elements stored by the array. An array element type is described by an instance of type BxDataObject.
Upon completion of this method, the BxDataObjectobject describing the element type is linked to this array instance. The caller must not explicitly destruct the BxDataObject after invoking this set method. Destruction of the BxDataObject instance will be managed by the array instance.

Parameters:
elemObj A pointer to the BxDataObject instance defining the element type for an array.

void BxArray::setIndexFrom int  dim,
int  from
 

Set indexFrom value for a specified dimension of an array.

Deprecated in version 1.0.
The array dimension must be specified as a zero-based offset into the list of dimensions.
Exceptions:
If the dimension number is not within the range of valid dimension numbers for this array, then no action is performed by this method.

Parameters:
dim Specifies the array dimension whose description will be modified.
from Specifies the indexFrom value for this array dimension.

void BxArray::setIndexTo int  dim,
int  to
 

Set indexTo value for a specified dimension of an array.

Deprecated in version 1.0.
The array dimension must be specified as a zero-based offset into the list of dimensions.
Exceptions:
If the dimension number is not within the range of valid dimension numbers for this array, then no action is performed by this method.

Parameters:
dim Specifies the array dimension whose description will be modified.
to Specifies the indexTo for this array dimension.

void BxArray::toFirst  ) 
 

Reset the array buffer pointer to the first element in the buffer.

The array buffer pointer is used by the getNext() method to sequentially retrieve data element values from the array buffer.
Exceptions:
If an array buffer is not currently allocated, no action is taken.

bool BxArray::toStream FILE *  stream  )  [virtual]
 

Write the implicit and complete XML (DataBinX) representation for an array to a file.

The BinX XML schema for this array is combined with the array data element values to create a DataBinX file.
The input file pointer must be open for writing.
Output Example:
The following is an example of the final contents of a DataBinX file for a small fixed-length array.

   <arrayFixed varName="x" typeName="x">
      <dim name="d2" index="1">
        <dim name="d1" index="1">
          <short-16>11</short-16>
        </dim>
        <dim name="d1" index="2">
          <short-16>12</short-16>
        </dim>
        <dim name="d1" index="3">
          <short-16>13</short-16>
        </dim>
        <dim name="d1" index="4">
          <short-16>14</short-16>
        </dim>
      </dim>
      <dim name="d2" index="2">
        <dim name="d1" index="1">
          <short-16>21</short-16>
        </dim>
        <dim name="d1" index="2">
          <short-16>22</short-16>
        </dim>
        <dim name="d1" index="3">
          <short-16>23</short-16>
        </dim>
        <dim name="d1" index="4">
          <short-16>24</short-16>
        </dim>
      </dim>
   </arrayFixed>
   
The array contains eight data elements, organized in a two-dimensional array having dimension extents two by four.
Parameters:
stream A pointer to a file open for writing.
Returns:
true If no file I/O error occurs,
false If the file is not open for writing.

Reimplemented from BxDataObject.

Reimplemented in BxArrayVariable.

bool BxArray::toStreamBinary FILE *  stream  )  [virtual]
 

Write all of the data element values of an array to a binary file.

The file must be open for writing in binary mode.

Parameters:
stream A pointer to a file open for writing in binary mode.
Returns:
Always returns true, even if a file I/O error occurs.

Reimplemented from BxDataObject.

Reimplemented in BxArrayVariable.

char * BxArray::toString bool  xml  )  [virtual]
 

Build a printable string containing a closed BinX XML schema definition for an array.

The resulting string includes:

  • The opening XML tag for a BinX data class
  • The BinX XML element indicating the array type, which is one of
    1. arrayFixed
    2. arrayVariable
    3. arrayStream
  • The BinX XML element indicating the type of element store in the array, which is one of the basic BinX types or a user-defined type, such as a structure or union
  • The BinX XML elements describing the extent of each array dimension
  • The closing XML tag for a BinX data class

This method appends the closing XML tag to the end of the returned string. To obtain an unclosed XML string, to which additional XML elements can be appended, use the method BxArray::toArrayHeader.
This method is reimplemented from the base class BxDataObject. The semantic of the reimplementation are modified as follows:
  • The Boolean input parameter has no effect on the behaviour of the method.
  • The method does not construct a DataBinx representation, as defined by the base class BxDataObject.
To obtain the DataBinX representation of the array, (which includes the BinX XML schema for each data element and each data element value), use the method BxArray::toStream().
If the input parameter value is true, then the schema corresponding to the array dimension descriptions will be listed in the reverse order to which they are stored in the array object attribute named dims_.
This method allocates memory to hold the returned BinX XML schema string. The caller is responsible for releasing the memory when the string is no longer needed.
Returns:
A pointer to a string containing the closed BinX XML schema for this array.

Reimplemented from BxDataObject.


The documentation for this class was generated from the following files:
Generated on Fri May 6 13:36:18 2005 for edikt::BinX by doxygen 1.3.3