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

◆ ArrayCreateAndAccess() [2/2]

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

Create a new child of primitive items and access that array, one 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 single dimensional array.

On return, "data[index]" can be used to access the array element at the specified index. See the SdsArrayAccessHelper class for more information.

In this example, we instantiate value to provide access to an array of SDS short items/

   sds::Id structure;
   ...
   sds::ArrayWriteHelper<short> values;
   id = structure.ArrayCreateAndAccess("itemName", 10, &values);
   unsigned long count = values.Size();
   for (unsigned long i = 0; i < count ; ++i)
        values[i] = 10 + i;
Warning
nitems argument can give problems in resolving this overload versions the other overload of this name. That other overload accepts a container in that position and sometimes compilers default to that rather then this method. The solution is to ensure the nitems argument is cast explicitly to "unsigned".
See also
sds::ArrayAccessHelper
sds::ArrayWriteHelper
CreateChildArray
Parameters
nameThe name of the new SDS item.
nitemsThe number of items in the array.
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.

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