In file Array.h:

class Array : public Vector

Holds multi-dimensional arrays.

Inheritance:


Public Methods

Array(const string &n = "", BaseType *v = 0)
The Array constructor.
Array(const Array &rhs)
The Array copy constructor
virtual bool read(const string &dataset, int &error)
Reads an array into the buffer.
void update_length(int size)
Changes the size property of the array
void append_dim(int size, string name = "")
Adds a dimension to an array.
bool add_constraint(Pix p, int start, int stride, int stop)
Adds a constraint to an Array dimension.
void reset_constraint()
Resets the projection to select the complete array
void clear_constraint()
Clears the projection; add each projected dimension explicitly using add\_constraint
Pix first_dim()
Returns a pointer to the first dimension of the array
void next_dim(Pix &p)
Given a dimension index, returns the index of the next dimension
int dimension_size(Pix p, bool constrained = false)
Returns the size of the dimension
int dimension_start(Pix p, bool constrained = false)
Returns the start index of the constraint
int dimension_stop(Pix p, bool constrained = false)
Returns the stop index of the constraint
int dimension_stride(Pix p, bool constrained = false)
Returns the stride value of the constraint
string dimension_name(Pix p)
Returns the name of the specified dimension
unsigned int dimensions(bool constrained = false)
Returns the total number of dimensions in the array

Inherited from Vector:

Public Methods

virtual void set_send_p(bool state)
virtual void set_read_p(bool state)
virtual unsigned int width()
virtual int length()
virtual void set_length(int l)
virtual unsigned int val2buf(void *val, bool reuse = false)
virtual unsigned int buf2val(void **val)
bool set_vec(unsigned int i, BaseType *val)
void vec_resize(int l)
virtual BaseType* var(const string &name = "", bool exact_match = true)
virtual BaseType* var(const string &name, btp_stack &s)
virtual BaseType* var(unsigned int i)
virtual void add_var(BaseType *v, Part p = nil)

Inherited from BaseType:

Public Methods

virtual BaseType* ptr_duplicate()
string name() const
void set_name(const string &n)
Type type() const
void set_type(const Type &t)
string type_name() const
bool is_simple_type()
bool is_vector_type()
bool is_constructor_type()
virtual int element_count(bool leaves = false)
bool synthesized_p()
void set_synthesized_p(bool state)
bool read_p()
bool send_p()
xdrproc_t xdr_coder()
virtual bool serialize(const string &dataset, DDS &dds, XDR *sink, bool ce_eval = true)
virtual bool deserialize(XDR *source, DDS *dds, bool reuse = false)
virtual void print_decl(ostream &os, string space = " ", bool print_semi = true, bool constraint_info = false, bool constrained = false)
virtual void print_val(ostream &os, string space = "", bool print_decl_p = true)
virtual bool check_semantics(string &msg, bool all = false)
virtual bool ops(BaseType *b, int op, const string &dataset)

Documentation

This class is used to hold arrays of other DODS data. The elements of the array can be simple or compound data types. There is no limit on the number of dimensions an array can have, or on the size of each dimension. If desired, the user can give each dimension of an array a name. You can, for example, have a 360x180 array of temperatures, covering the whole globe with one-degree squares. In this case, you could name the first dimension ``Longitude'' and the second dimension ``Latitude''. This can help prevent a great deal of confusion. The Array is used as part of the Grid class, where the dimension names are crucial to its structure. The dimension names correspond to ``Map'' vectors, holding the actual values for that column of the array. Each array dimension carries with it its own projection information. The projection inforamtion takes the form of three integers: the start, stop, and stride values. This is clearest with an example. Consider a one-dimensional array 10 elements long. If the start value of the dimension constraint is 3, then the constrained array appears to be seven elements long. If the stop value is changed to 7, then the array appears to be five elements long. If the stride is changed to two, the array will appear to be 3 elements long. Array constraints are written as: #[start:stride:stop]#. \begin{verbatim} A = [1 2 3 4 5 6 7 8 9 10] A[3::] = [4 5 6 7 8 9 10] A[3::7] = [4 5 6 7 8] A[3:2:7] = [4 6 8] A[0:3:9] = [1 4 7 10] \end{verbatim} \note{DODS uses zero-based indexing.}
Array(const string &n = "", BaseType *v = 0)
The Array constructor requires the name of the variable to be created, and the type of data the Array is to hold. The name may be omitted, which will create a nameless variable. The template pointer may also be omitted. Note that if the template pointer is omitted when the Array is created, it {\it must} be added (with #add_var()#) before #read()# or #deserialize()# is called.
Parameters:
n - A string containing the name of the variable to be created.
v - A pointer to a variable of the type to be included in the Array.

Array(const Array &rhs)
The Array copy constructor

virtual bool read(const string &dataset, int &error)
This function should read local data and fill in the data buffer. When reading the data, the read function should use the constraint and selection information available for each dimension of the array to decide how much of the array to read. Only the values to be transmitted with #serialize()# must be read. The implementation of this function is part of creating a new DODS server, and is left for the user. For other details, refer to the description of the #read()# function in the BaseType class.
See Also:
BaseType::read

void update_length(int size)
Changes the size property of the array. If the array exists, it is augmented by a factor of #size#. This does not change the actual size of the array. @deprecated

void append_dim(int size, string name = "")
Given a size and a name, this function adds a dimension to the array. For example, if the Array is already 10 elements long, calling #append_dim# with a size of 5 will transform the array into a 10x5 matrix. Calling it again with a size of 2 will create a 10x5x2 array, and so on.
Parameters:
size - The size of the desired new row.
name - The name of the new dimension. This defaults to an empty string.

bool add_constraint(Pix p, int start, int stride, int stop)
Once a dimension has been created (see #append_dim()#), it can be ``constrained''. This will make the array appear to the rest of the world to be smaller than it is. This functions sets the projection for a dimension, and marks that dimension as part of the current projection. \note{A stride value <= 0 or > the array size is an error and causes #add_constraint# to return FALSE. Similarly, start or stop values > size also cause a FALSE return value.}
Returns:
TRUE on success, FALSE otherwise.
Parameters:
p - An index (of type Pix) pointing to the dimension in the list of dimensions.
start - The start index of the constraint.
stride - The stride value of the constraint.
stop - The stop index of the constraint.

void reset_constraint()
Resets the projection to select the complete array

void clear_constraint()
Clears the projection; add each projected dimension explicitly using add\_constraint

Pix first_dim()
Returns a pointer to the first dimension of the array

void next_dim(Pix &p)
Given a dimension index, returns the index of the next dimension

int dimension_size(Pix p, bool constrained = false)
Returns the size of the dimension.
Parameters:
p - The Pix index of the dimension.
constrained - If this parameter is TRUE, the function returns the constrained size of the array. If the dimension is not selected, the function returns zero. If it is FALSE, the function returns the dimension size whether or not the dimension is constrained.

int dimension_start(Pix p, bool constrained = false)
Returns the start index of the constraint.
Parameters:
p - The Pix index of the dimension.
constrained - If this parameter is TRUE, the function returns the start index only if the dimension is selected. If the dimension is not selected, the function returns zero. If it is FALSE, the function returns the start index whether or not the dimension is constrained.

int dimension_stop(Pix p, bool constrained = false)
Returns the stop index of the constraint.
Parameters:
p - The Pix index of the dimension.
constrained - If this parameter is TRUE, the function returns the stop index only if the dimension is selected. If the dimension is not selected, the function returns zero. If it is FALSE, the function returns the stop index whether or not the dimension is constrained.

int dimension_stride(Pix p, bool constrained = false)
Returns the stride value of the constraint.
Parameters:
p - The Pix index of the dimension.
constrained - If this parameter is TRUE, the function returns the stride value only if the dimension is selected. If the dimension is not selected, the function returns zero. If it is FALSE, the function returns the stride value whether or not the dimension is constrained.

string dimension_name(Pix p)
Returns the name of the specified dimension

unsigned int dimensions(bool constrained = false)
Returns the total number of dimensions in the array


This class has no child classes.
See Also:
Grid
List

alphabetic index hierarchy of classes


generated by doc++