43 template <
typename ArrayType>
44 void CoherentArrayElementReader(Binder* binder,
void* data,
size_t position)
46 auto arrayData = (ArrayType*)data;
47 CoherentReadInternal(binder, arrayData[position]);
50 typedef void(*Reader)(Binder*,
void*, size_t);
53 class ArrayReaderFactory
56 static Reader ElementReader()
58 return cohtml::CoherentArrayElementReader<T>;
63 class ArrayReaderFactory<T*>
66 static Reader ElementReader()
72 template <
typename ArrayType>
73 void CoherentArrayElementBinder(Binder* binder,
void* arr,
size_t index)
75 auto castedArray = (ArrayType*)arr;
76 CoherentBindInternal(binder, castedArray[index]);
79 template <
typename ArrayType,
size_t ArraySize>
80 void CoherentBindInternal(Binder* binder, ArrayType (&array)[ArraySize])
82 if (!binder->TryBindArrayByRef((
void*)(array),
84 CoherentArrayElementBinder<ArrayType>,
85 ArrayReaderFactory<ArrayType>::ElementReader()))
87 binder->ArrayBegin(ArraySize);
89 for (
size_t i = 0; i < ArraySize; ++i)
91 CoherentBindInternal(binder, array[i]);
98 template <
typename ArrayType,
size_t ArraySize>
99 void CoherentBindInternal(Binder* binder,
const ArrayType(&array)[ArraySize])
101 if (!binder->TryBindArrayByRef((
void*)(array),
103 CoherentArrayElementBinder<const ArrayType>,
104 ArrayReaderFactory<ArrayType>::ElementReader()))
106 binder->ArrayBegin(ArraySize);
108 for (
size_t i = 0; i < ArraySize; ++i)
110 CoherentBindInternal(binder, array[i]);
117 template <
typename ArrayType,
size_t ArraySize>
118 void CoherentReadInternal(Binder* binder, ArrayType (&array)[ArraySize])
120 size_t arraySize = binder->ReadArrayBegin();
121 assert(arraySize == ArraySize);
124 for (
size_t i = 0; i < arraySize; ++i)
126 binder->ReadArrayElement(index++);
127 CoherentReadInternal(binder, array[i]);
130 binder->ReadArrayEnd();
Contains almost all Coherent namespaces, classes and functions.
Definition: DataStorage.h:38