add PVScalarArray::getAs and PVScalarArray::putFrom

This commit is contained in:
Michael Davidsaver
2013-04-26 17:29:22 -04:00
parent f2635c7fdc
commit 0e0ab66d45
2 changed files with 40 additions and 0 deletions

View File

@@ -41,6 +41,19 @@ template<> const ScalarType PVFloat::typeCode = pvFloat;
template<> const ScalarType PVDouble::typeCode = pvDouble;
template<> const ScalarType PVScalarValue<String>::typeCode = pvString;
//template<> const ScalarType PVBooleanArray::typeCode = pvBoolean;
template<> const ScalarType PVByteArray::typeCode = pvByte;
template<> const ScalarType PVShortArray::typeCode = pvShort;
template<> const ScalarType PVIntArray::typeCode = pvInt;
template<> const ScalarType PVLongArray::typeCode = pvLong;
template<> const ScalarType PVUByteArray::typeCode = pvUByte;
template<> const ScalarType PVUShortArray::typeCode = pvUShort;
template<> const ScalarType PVUIntArray::typeCode = pvUInt;
template<> const ScalarType PVULongArray::typeCode = pvULong;
template<> const ScalarType PVFloatArray::typeCode = pvFloat;
template<> const ScalarType PVDoubleArray::typeCode = pvDouble;
template<> const ScalarType PVStringArray::typeCode = pvString;
/** Default storage for scalar values
*/
template<typename T>

View File

@@ -646,8 +646,24 @@ public:
*/
const ScalarArrayConstPtr getScalarArray() const ;
template<ScalarType ID>
inline void getAs(typename ScalarTypeTraits<ID>::type* ptr,
size_t count, size_t offset = 0) const
{
getAs(ID, (void*)ptr, count, offset);
}
template<ScalarType ID>
inline void putFrom(const typename ScalarTypeTraits<ID>::type* ptr,
size_t count, size_t offset = 0)
{
putFrom(ID, (const void*)ptr, count, offset);
}
protected:
PVScalarArray(ScalarArrayConstPtr const & scalarArray);
virtual void getAs(ScalarType, void*, size_t, size_t) const = 0;
virtual void putFrom(ScalarType, const void*, size_t ,size_t) = 0;
private:
friend class PVDataCreate;
};
@@ -1001,6 +1017,8 @@ public:
typedef PVValueArray & reference;
typedef const PVValueArray & const_reference;
static const ScalarType typeCode;
/**
* Destructor
*/
@@ -1065,6 +1083,15 @@ protected:
PVValueArray(ScalarArrayConstPtr const & scalar)
: PVScalarArray(scalar) {}
friend class PVDataCreate;
virtual void getAs(ScalarType dtype, void* ptr, size_t count, size_t offset) const
{
castUnsafeV(count, dtype, ptr, typeCode, (const void*)(get()+offset));
}
virtual void putFrom(ScalarType dtype, const void*ptr, size_t count, size_t offset)
{
castUnsafeV(count, typeCode, (void*)(get()+offset), dtype, ptr);
}
};
template<typename T>