void NTNDArrayConverter::fromValue (NDArray *src) { typedef typename arrayType::value_type arrayValType; NDArrayInfo_t arrayInfo; size_t count, nBytes; string unionField(string(ScalarTypeFunc::name(arrayType::typeCode)) + string("Value")); src->getInfo(&arrayInfo); count = arrayInfo.nElements; nBytes = arrayInfo.totalBytes; m_array->getCompressedDataSize()->put(static_cast<int64>(nBytes)); m_array->getUncompressedDataSize()->put(static_cast<int64>(nBytes)); src->reserve(); shared_vector<arrayValType> temp((srcDataType*)src->pData, freeNDArray<srcDataType>(src), 0, count); PVUnionPtr dest = m_array->getValue(); dest->select<arrayType>(unionField)->replace(freeze(temp)); dest->postPut(); }
void NTNDArrayRecord::setValue(PVByteArray::const_svector const & bytes) { // Get the union value field PVUnionPtr value = ndarray->getValue(); // Select the byteValue field stored in "value" PVByteArrayPtr byteValue = value->select<PVByteArray>("byteValue"); // replace the shared vector with "bytes" byteValue->replace(bytes); // call postPut so that the union sees the change in the stored field value->postPut(); }