The vector data types require the same abstract member functions be
defined as the simple types. The definition for ptr_duplicate
is also the same for vector as for simple types. However, the
read member function for the vector types (classes Array
and List) is more complicated than for the simple types
because vectors of values are represented in two ways in DODS,
depending on the type of variable in the vector. Arrays are stored as
C would store them for the simple types such as Byte,
Int32 and Float64. However, compound types are stored
as arrays of the DODS C++ objects (with the exception of arrays
themselves, but more on that later).
When reading an array of Byte values, the val2buf member function
should be passed a pointer to values stored in a contiguous piece of
memory. For example, when read is called to read a variable
byte-array, it must determine how much memory to allocate to
hold that much information, use new to allocate an adequate
amount of memory, use the dataset's API calls to read
byte-array into the newly allocated memory and then pass that
memory to val2buf. This same procedure can be followed for all
the simple types.
However, when reading an array of Structure, for example, the
values must be stored in the DODS Array object one at a time
using the Array member function set_vec. An
Array object containing a 3x4 array of Structure
objects will actually point to 12 different instances of that class.
An Array object containing Byte objects contains
only one instance of the Byte class, as a template for the
array elements.
Arrays in DODS are unlike arrays in C in that an array object may have more than one dimension. In terms of the way a value is stored, however, an Array is a single dimensional object. When an Array is declared as having two or more dimensions, those are mapped onto a single vector. To access the element A_ij of array A, you must know the size of the first dimension, I, and use the expression i * I + j to compute the offset into the vector.
Since the class List is a single dimension array without declared size (the size of each value of the List object is stored in the object) the rules for Array's read member function apply.