diff --git a/pvDataApp/factory/PVDataCreateFactory.cpp b/pvDataApp/factory/PVDataCreateFactory.cpp index a3fe68b..b32d493 100644 --- a/pvDataApp/factory/PVDataCreateFactory.cpp +++ b/pvDataApp/factory/PVDataCreateFactory.cpp @@ -41,6 +41,19 @@ template<> const ScalarType PVFloat::typeCode = pvFloat; template<> const ScalarType PVDouble::typeCode = pvDouble; template<> const ScalarType PVScalarValue::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 diff --git a/pvDataApp/pv/pvData.h b/pvDataApp/pv/pvData.h index 418bc43..5cd597a 100644 --- a/pvDataApp/pv/pvData.h +++ b/pvDataApp/pv/pvData.h @@ -646,8 +646,24 @@ public: */ const ScalarArrayConstPtr getScalarArray() const ; + template + inline void getAs(typename ScalarTypeTraits::type* ptr, + size_t count, size_t offset = 0) const + { + getAs(ID, (void*)ptr, count, offset); + } + + template + inline void putFrom(const typename ScalarTypeTraits::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