AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface

◆ ArrayCreateAndAccess() [1/2]

template<typename T , class ContainerType >
Id drama::sds::Id::ArrayCreateAndAccess ( const std::string &  name,
const ContainerType dims,
sds::ArrayWriteHelper< T > *const  data,
const std::string &  extra = "" 
)
inline

Create a new child of primitive items and access that array, multi-dimensional.

Accesses an array using an ArrayWriteHelper of the appropriate type.
This provides an easy way to create and access an array of primitive values.

This version creates a multi-dimensional array with up to 7 dimensions.

On return, "data[index]" can be used to access the array element at the specified index. See the SdsArrayAccessHelper class for more information. Note that Multidimensional arrays must be indexed by calculating the equivalent single dimensional index (otherwise the type definitions are too hard).

In this example, we instantiate value to provide access to a 2 dimensional array of float items/

   sds::Id structure;
   ...
   sds::ArrayWriteHelper<float> values;
   std::vector<unsigned long> dims(2);
   dims[0] = 10;
   dims[1] =  5;
   id = structure.ArrayCreateAndAccess("itemName", dims, &values);
   unsigned long count = values.Size();
   for (unsigned long i = 0; i < count ; ++i)
        values[i] = 10 + i;
Warning
Some compilers will try to use this overload of this method when the 2nd argument (dims) is NOT a container, the intent would be to invoke the other overload where that argument is an unsigned int item (single dimensional version). The solution is to ensure the argument is cast explicitly to "unsigned".
See also
sds::ArrayAccessHelper
sds::ArrayWriteHelper
CreateChildArray
Parameters
nameThe name of the new SDS item.
dimsThe dimensions are written to this array. This container will be cleared and then push_back() applied up to 7 times.
dataA pointer to an object which allows you to access the underlying SDS data. It must be an Instantiation of a the class ArrayWriteHelper appropriate for type T.
extraThe extra data, if any. Defaults to none.
Template Parameters
TThe array access helper to use.
ContainerTypeA container with clear() and push_back() methods. The push_back() method must accept unsigned long items.

References drama::sds::ArrayAccessHelper< T >::Code(), CreateChildArray(), and drama::CreateRunDramaTask().