SyncArray



constructor
set
get
size

SyncArray is similar to SyncData, except that it holds an array of variables. Of course, there's nothing stopping you from making an array of SyncData objects, which would seem to make SyncArray redundant.

However, SyncData objects can eat up a lot of RAM. Each SyncData instance contains a pointer to a DasyneEngine, and a pointer to a data map location. A SyncArray has only one data map pointer for the entire array.

And remember: Servers and clients need to declare all their SyncData and SyncArray objects in exactly the same order, to make sure they reference the same location in the data map.

SyncArray member functions:


template <class T>
SyncArray(DasyneEngine &syncEngine, uint32_t size);

The constructor takes either a DasyneServer or DasyneClient as its parameter, which will synchronize the variables. size is the number of array elements to create. When you create a SyncArray object, you must also specify the type of variable that it will hold:

SyncArray<float> *testArray = NULL;
DasyneServer syncEngine;

testArray = new SyncArray<float>(syncEngine, 1000); //create an array of 1000 floats
syncEngine.initialize(5555);
testArray->set(512, 17.8);
cout << testArray->get(512) << endl;

delete testArray;


template <class T>
void set(uint32_t index, T newValue);

Set the variable at the specified index to the new value.


template <class T>
T get(uint32_t index);

Return the variable at the specified index.


uint32_t size(void);

Returns the number of elements in the array.