From dd6ecf9becd2189dad81e8f8efde789ab2a44b0c Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Fri, 24 Sep 2010 09:52:08 -0400 Subject: [PATCH] all pvData interfaces and implementration stubs now defined Most methods are not implemented and throw an exception --- pvDataApp/factory/AbstractPVArray.h | 5 + pvDataApp/factory/AbstractPVField.h | 17 ++ pvDataApp/factory/AbstractPVScalarArray.h | 3 +- pvDataApp/factory/BasePVDouble.h | 52 +++- pvDataApp/factory/BasePVDoubleArray.h | 35 ++- pvDataApp/factory/BasePVStructure.h | 41 +-- pvDataApp/factory/BasePVStructureArray.h | 40 ++- pvDataApp/factory/Convert.cpp | 263 ++++++++++++++++++ pvDataApp/factory/FieldCreateFactory.cpp | 21 +- pvDataApp/factory/Makefile | 3 + pvDataApp/factory/PVAuxInfoImpl.cpp | 10 +- pvDataApp/factory/PVDataCreateFactory.cpp | 11 +- pvDataApp/factory/TypeFunc.cpp | 2 +- pvDataApp/factory/factory.h | 5 - pvDataApp/pv/Makefile | 1 + pvDataApp/pv/convert.h | 68 ++++- pvDataApp/pv/pvData.h | 1 + pvDataApp/pv/pvIntrospect.h | 1 + pvDataApp/test/Makefile | 6 +- pvDataApp/test/testDumpStdString.cpp | 2 +- .../test/{test.cpp => testIntrospect.cpp} | 2 +- pvDataApp/test/testPVScalar.cpp | 38 +-- 22 files changed, 524 insertions(+), 103 deletions(-) create mode 100644 pvDataApp/factory/Convert.cpp rename pvDataApp/test/{test.cpp => testIntrospect.cpp} (98%) diff --git a/pvDataApp/factory/AbstractPVArray.h b/pvDataApp/factory/AbstractPVArray.h index d2ab99f..74414cb 100644 --- a/pvDataApp/factory/AbstractPVArray.h +++ b/pvDataApp/factory/AbstractPVArray.h @@ -76,5 +76,10 @@ namespace epics { namespace pvData { void PVArray::toString(StringPtr buf) const {toString(buf,0);} + void PVArray::toString(StringPtr buf, int indentLevel) const + { + throw std::logic_error(notImplemented); + } + }} #endif /* ABSTRACTPVARRAY_H */ diff --git a/pvDataApp/factory/AbstractPVField.h b/pvDataApp/factory/AbstractPVField.h index b8bd560..45b33cb 100644 --- a/pvDataApp/factory/AbstractPVField.h +++ b/pvDataApp/factory/AbstractPVField.h @@ -10,6 +10,11 @@ namespace epics { namespace pvData { + +static std::string notImplemented("not implemented"); + + static Convert *convert = 0; + class PVFieldPvt { public: PVFieldPvt(PVStructure *parent,FieldConstPtr field); @@ -22,8 +27,15 @@ namespace epics { namespace pvData { epicsBoolean immutable; Requester *requester; PostHandler *postHandler; + private: + static void init(); }; + void PVFieldPvt::init() + { + convert = getConvert(); + } + PVFieldPvt::PVFieldPvt(PVStructure *parent,FieldConstPtr field) : parent(parent),field(field), fieldOffset(0), nextFieldOffset(0), @@ -112,24 +124,29 @@ namespace epics { namespace pvData { void PVField::replacePVField(PVField * newPVField) { + throw std::logic_error(notImplemented); } void PVField::renameField(StringConstPtr newName) { + throw std::logic_error(notImplemented); } void PVField::postPut() const { + throw std::logic_error(notImplemented); } void PVField::setPostHandler(PostHandler *ppostHandler) { + throw std::logic_error(notImplemented); } void PVField::toString(StringPtr buf) const {toString(buf,0);} void PVField::toString(StringPtr buf,int indentLevel) const { + throw std::logic_error(notImplemented); } void PVField::computeOffset(PVField const * const pvField) { diff --git a/pvDataApp/factory/AbstractPVScalarArray.h b/pvDataApp/factory/AbstractPVScalarArray.h index a52ab2d..f380eec 100644 --- a/pvDataApp/factory/AbstractPVScalarArray.h +++ b/pvDataApp/factory/AbstractPVScalarArray.h @@ -13,7 +13,8 @@ namespace epics { namespace pvData { PVScalarArray::~PVScalarArray() {} - PVScalarArray::PVScalarArray(PVStructure *parent,ScalarArrayConstPtr scalarArray) + PVScalarArray::PVScalarArray(PVStructure *parent, + ScalarArrayConstPtr scalarArray) : PVArray(parent,scalarArray) {} ScalarArrayConstPtr PVScalarArray::getScalarArray() const diff --git a/pvDataApp/factory/BasePVDouble.h b/pvDataApp/factory/BasePVDouble.h index 1d89ed3..de16d19 100644 --- a/pvDataApp/factory/BasePVDouble.h +++ b/pvDataApp/factory/BasePVDouble.h @@ -6,6 +6,7 @@ #include #include #include "pvData.h" +#include "convert.h" #include "factory.h" #include "AbstractPVField.h" @@ -15,20 +16,53 @@ namespace epics { namespace pvData { class BasePVDouble : public PVDouble { public: - BasePVDouble(PVStructure *parent,ScalarConstPtr scalar) - : PVDouble(parent,scalar),value(0.0) {} - virtual ~BasePVDouble() {} - virtual double get()const { return value;} - virtual void put(double val){value = val;} - virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const{} - virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher){} - virtual void toString(StringPtr buf)const {} - virtual void toString(StringPtr buf,int indentLevel)const {} + BasePVDouble(PVStructure *parent,ScalarConstPtr scalar); + virtual ~BasePVDouble(); + virtual double get()const; + virtual void put(double val); + virtual void serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher) const; + virtual void deserialize(ByteBuffer *pbuffer, + DeserializableControl *pflusher); + virtual void toString(StringPtr buf)const; + virtual void toString(StringPtr buf,int indentLevel)const; private: BasePVDouble(); // not implemented + BasePVDouble(BasePVDouble const & ); // not implemented + BasePVDouble & operator=(BasePVDouble const &); //not implemented double value; }; + BasePVDouble::BasePVDouble(PVStructure *parent,ScalarConstPtr scalar) + : PVDouble(parent,scalar),value(0.0) + {} + + BasePVDouble::~BasePVDouble() {} + + double BasePVDouble::get()const { return value;} + + void BasePVDouble::put(double val){value = val;} + + void BasePVDouble::serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher) const + { + throw std::logic_error(notImplemented); + } + + void BasePVDouble::deserialize(ByteBuffer *pbuffer, + DeserializableControl *pflusher) + { + throw std::logic_error(notImplemented); + } + + void BasePVDouble::toString(StringPtr buf)const {toString(buf,0);} + + void BasePVDouble::toString(StringPtr buf,int indentLevel) const + { + convert->getString(buf,this,indentLevel); + PVField::toString(buf,indentLevel); + } + }} #endif /* BASEPVDOUBLE_H */ diff --git a/pvDataApp/factory/BasePVDoubleArray.h b/pvDataApp/factory/BasePVDoubleArray.h index 5e15cdd..55a5b3d 100644 --- a/pvDataApp/factory/BasePVDoubleArray.h +++ b/pvDataApp/factory/BasePVDoubleArray.h @@ -37,10 +37,10 @@ namespace epics { namespace pvData { DoubleArrayPtr doubleArray; }; - BasePVDoubleArray::BasePVDoubleArray(PVStructure *parent,ScalarArrayConstPtr scalarArray) + BasePVDoubleArray::BasePVDoubleArray(PVStructure *parent, + ScalarArrayConstPtr scalarArray) : PVDoubleArray(parent,scalarArray),doubleArray(new double[0]) - { - } + { } BasePVDoubleArray::~BasePVDoubleArray() { @@ -49,6 +49,7 @@ namespace epics { namespace pvData { void BasePVDoubleArray::setCapacity(int capacity) { + throw std::logic_error(notImplemented); } int BasePVDoubleArray::get(int offset, int length, @@ -66,29 +67,37 @@ namespace epics { namespace pvData { void BasePVDoubleArray::shareData(DoubleArrayPtr from) { - } - - void BasePVDoubleArray::serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const - { - } - - void BasePVDoubleArray::deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) - { + throw std::logic_error(notImplemented); } void BasePVDoubleArray::serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher, int offset, int count) const + SerializableControl *pflusher) const { + throw std::logic_error(notImplemented); + } + + void BasePVDoubleArray::deserialize(ByteBuffer *pbuffer, + DeserializableControl *pflusher) + { + throw std::logic_error(notImplemented); + } + + void BasePVDoubleArray::serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher, int offset, int count) const + { + throw std::logic_error(notImplemented); } void BasePVDoubleArray::toString(StringPtr buf)const { + toString(buf,1); } void BasePVDoubleArray::toString(StringPtr buf,int indentLevel)const { + convert->getString(buf,this,indentLevel); + PVArray::toString(buf,indentLevel); } - }} #endif /* BASEPVDOUBLEARRAY_H */ diff --git a/pvDataApp/factory/BasePVStructure.h b/pvDataApp/factory/BasePVStructure.h index 151b712..2501f7a 100644 --- a/pvDataApp/factory/BasePVStructure.h +++ b/pvDataApp/factory/BasePVStructure.h @@ -39,7 +39,7 @@ namespace epics { namespace pvData { pImpl->numberFields = numberFields; pImpl->pvFields = new PVFieldPtr[numberFields]; for(int i=0; istructureArray; } - int PVStructureArray::get(int offset, int length, StructureArrayData *data) const + int PVStructureArray::get( + int offset, int length, StructureArrayData *data) const { - return 0; + throw std::logic_error(notImplemented); } - int PVStructureArray::put(int offset,int length, PVStructureArrayPtr from, int fromOffset) + int PVStructureArray::put(int offset,int length, + PVStructureArrayPtr from, int fromOffset) { - return 0; + throw std::logic_error(notImplemented); } void PVStructureArray::shareData(PVStructureArrayPtr from) { + throw std::logic_error(notImplemented); } - void PVStructureArray::serialize(ByteBuffer *pbuffer, SerializableControl *pflusher) const + void PVStructureArray::serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher) const { + throw std::logic_error(notImplemented); } - void PVStructureArray::deserialize(ByteBuffer *pbuffer, DeserializableControl *pflusher) + void PVStructureArray::deserialize(ByteBuffer *pbuffer, + DeserializableControl *pflusher) { + throw std::logic_error(notImplemented); } void PVStructureArray::serialize(ByteBuffer *pbuffer, SerializableControl *pflusher, int offset, int count) const { + throw std::logic_error(notImplemented); } void PVStructureArray::toString(StringPtr buf) const {toString(buf,0);} void PVStructureArray::toString(StringPtr buf,int indentLevel) const { + throw std::logic_error(notImplemented); } class BasePVStructureArray : public PVStructureArray { public: - BasePVStructureArray(PVStructure *parent,StructureArrayConstPtr structureArray) + BasePVStructureArray(PVStructure *parent, + StructureArrayConstPtr structureArray) : PVStructureArray(parent,structureArray) {} ~BasePVStructureArray(){} private: - BasePVStructureArray(); // not implemented - BasePVStructureArray(BasePVStructureArray const & ); // not implemented - BasePVStructureArray & operator=(BasePVStructureArray const &); //not implemented + // following not implemented + BasePVStructureArray(); + BasePVStructureArray(BasePVStructureArray const & ); + BasePVStructureArray & operator=(BasePVStructureArray const &); }; }} diff --git a/pvDataApp/factory/Convert.cpp b/pvDataApp/factory/Convert.cpp new file mode 100644 index 0000000..dbcf661 --- /dev/null +++ b/pvDataApp/factory/Convert.cpp @@ -0,0 +1,263 @@ +/* Convert.cpp */ +#include +#include +#include +#include "convert.h" + +namespace epics { namespace pvData { + +static std::string notImplemented("not implemented"); + + Convert::Convert(){} + + Convert::~Convert(){} + + void Convert::getFullName(StringConstPtr buf,PVField const *pvField) + { + throw std::logic_error(notImplemented); + } + + void Convert::getString(StringPtr buf,PVField const * pvField,int indentLevel) + { + throw std::logic_error(notImplemented); + } + + void Convert::getString(StringPtr buf,PVField const *pvField) + { + throw std::logic_error(notImplemented); + } + + void Convert::fromString(PVScalar *pv, StringConstPtr from) + { + throw std::logic_error(notImplemented); + } + + int Convert::fromString(PVScalarArray *pv, StringConstPtr from) + { + throw std::logic_error(notImplemented); + } + + int Convert::fromStringArray(PVScalarArray *pv, int offset, int length, + StringPtrArray from, int fromOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::toStringArray(PVScalarArray const *pv, int offset, int length, + StringPtrArray to, int fromOffset) + { + throw std::logic_error(notImplemented); + } + + epicsBoolean Convert::isCopyCompatible(FieldConstPtr from, FieldConstPtr to) + { + throw std::logic_error(notImplemented); + } + + void Convert::copy(PVField const *from,PVField *to) + { + throw std::logic_error(notImplemented); + } + + epicsBoolean Convert::isCopyScalarCompatible( + ScalarConstPtr from, ScalarConstPtr to) + { + throw std::logic_error(notImplemented); + } + + void copyScalar(PVScalar const *from, PVScalar *to) + { + throw std::logic_error(notImplemented); + } + + epicsBoolean Convert::isCopyScalarArrayCompatible(ScalarArrayConstPtr from, + ScalarArrayConstPtr to) + { + throw std::logic_error(notImplemented); + } + + int Convert::copyScalarArray(PVScalarArray const *from, int offset, + PVScalarArray *to, int toOffset, int length) + { + throw std::logic_error(notImplemented); + } + + epicsBoolean Convert::isCopyStructureCompatible( + StructureConstPtr from, StructureConstPtr to) + { + throw std::logic_error(notImplemented); + } + + void Convert::copyStructure(PVStructure const *from, PVStructure *to) + { + throw std::logic_error(notImplemented); + } + + epicsBoolean Convert::isCopyStructureArrayCompatible( + StructureArrayConstPtr from, StructureArrayConstPtr to) + { + throw std::logic_error(notImplemented); + } + + void Convert::copyStructureArray( + PVStructureArray const *from, PVStructureArray *to) + { + throw std::logic_error(notImplemented); + } + + epicsInt8 Convert::toByte(PVScalar const *pv) + { + throw std::logic_error(notImplemented); + } + + epicsInt16 Convert::toShort(PVScalar const *pv) + { + throw std::logic_error(notImplemented); + } + + epicsInt32 Convert::toInt(PVScalar const *pv) + { + throw std::logic_error(notImplemented); + } + + epicsInt64 Convert::toLong(PVScalar const *pv) + { + throw std::logic_error(notImplemented); + } + + float Convert::toFloat(PVScalar const *pv) + { + throw std::logic_error(notImplemented); + } + + double Convert::toDouble(PVScalar const *pv) + { + throw std::logic_error(notImplemented); + } + + void Convert::fromByte(PVScalar *pv,epicsInt8 from) + { + throw std::logic_error(notImplemented); + } + + void Convert::fromShort(PVScalar *pv,epicsInt16 from) + { + throw std::logic_error(notImplemented); + } + + void Convert::fromInt(PVScalar *pv, epicsInt32 from) + { + throw std::logic_error(notImplemented); + } + + void Convert::fromLong(PVScalar *pv, epicsInt64 from) + { + throw std::logic_error(notImplemented); + } + + void Convert::fromFloat(PVScalar* pv, float from) + { + throw std::logic_error(notImplemented); + } + + void Convert::fromDouble(PVScalar *pv, double from) + { + throw std::logic_error(notImplemented); + } + + int Convert::toByteArray(PVScalarArray const *pv, int offset, int length, + epicsInt8 to[], int toOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::toShortArray(PVScalarArray const *pv, int offset, int length, + epicsInt16 to[], int toOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::toIntArray(PVScalarArray const *pv, int offset, int length, + epicsInt32 to[], int toOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::toLongArray(PVScalarArray const *pv, int offset, int length, + epicsInt64 to[], int toOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::toFloatArray(PVScalarArray const *pv, int offset, int length, + float to[], int toOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::toDoubleArray(PVScalarArray const *pv, int offset, int length, + double to[], int toOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::fromByteArray(PVScalarArray *pv, int offset, int length, + epicsInt8 from[], int fromOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::fromShortArray(PVScalarArray *pv, int offset, int length, + epicsInt16 from[], int fromOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::fromIntArray(PVScalarArray *pv, int offset, int length, + epicsInt32 from[], int fromOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::fromLongArray(PVScalarArray *pv, int offset, int length, + epicsInt64 from[], int fromOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::fromFloatArray(PVScalarArray *pv, int offset, int length, + float from[], int fromOffset) + { + throw std::logic_error(notImplemented); + } + + int Convert::fromDoubleArray(PVScalarArray *pv, int offset, int length, + double from[], int fromOffset) + { + throw std::logic_error(notImplemented); + } + + void Convert::newLine(StringPtr buffer, int indentLevel) + { + *buffer += "\n"; + for(int i=0; ilock(); + if(instance==0) instance = new ConvertExt(); + lock->unlock(); + return instance; + } + +}} diff --git a/pvDataApp/factory/FieldCreateFactory.cpp b/pvDataApp/factory/FieldCreateFactory.cpp index fb09c84..516f351 100644 --- a/pvDataApp/factory/FieldCreateFactory.cpp +++ b/pvDataApp/factory/FieldCreateFactory.cpp @@ -3,11 +3,18 @@ #include #include #include -#include "pvData.h" +#include +#include "pvIntrospect.h" #include "factory.h" namespace epics { namespace pvData { + static void newLine(StringPtr buffer, int indentLevel) + { + *buffer += "\n"; + for(int i=0; ilock(); + if(instance==0) instance = new FieldCreateExt(); + lock->unlock(); + return instance; + } }} diff --git a/pvDataApp/factory/Makefile b/pvDataApp/factory/Makefile index 80826ff..ba998b3 100644 --- a/pvDataApp/factory/Makefile +++ b/pvDataApp/factory/Makefile @@ -16,9 +16,12 @@ LIBSRCS += TypeFunc.cpp LIBSRCS += PVAuxInfoImpl.cpp LIBSRCS += FieldCreateFactory.cpp LIBSRCS += PVDataCreateFactory.cpp +LIBSRCS += Convert.cpp LIBRARY=pvFactory +pvFactory_LIBS += Com + include $(TOP)/configure/RULES #---------------------------------------- # ADD RULES AFTER THIS LINE diff --git a/pvDataApp/factory/PVAuxInfoImpl.cpp b/pvDataApp/factory/PVAuxInfoImpl.cpp index 1c1feaf..ce330f2 100644 --- a/pvDataApp/factory/PVAuxInfoImpl.cpp +++ b/pvDataApp/factory/PVAuxInfoImpl.cpp @@ -1,6 +1,4 @@ -/*AbstractPVScalar.h*/ -#ifndef ABSTRACTPVSCALAR_H -#define ABSTRACTPVSCALAR_H +/*PVAuxInfo.cpp*/ #include #include #include @@ -27,6 +25,10 @@ namespace epics { namespace pvData { { } PVAuxInfo::~PVAuxInfo() { delete pImpl;} + + void PVAuxInfo::init() { + pvDataCreate = getPVDataCreate(); + } PVField * PVAuxInfo::getPVField() { return pImpl->pvField; @@ -44,7 +46,6 @@ namespace epics { namespace pvData { ScalarTypeFunc::toString(&message,scalarType); pImpl->pvField->message(&message,errorMessage); } - if(pvDataCreate==0) pvDataCreate = getPVDataCreate(); PVScalar *pvScalar = pvDataCreate->createPVScalar(0,key,scalarType); pImpl->theMap.insert(std::pair(key, pvScalar)); return pvScalar; @@ -81,4 +82,3 @@ namespace epics { namespace pvData { } } }} -#endif /* ABSTRACTPVSCALAR_H */ diff --git a/pvDataApp/factory/PVDataCreateFactory.cpp b/pvDataApp/factory/PVDataCreateFactory.cpp index 4b73fdc..2fabf6f 100644 --- a/pvDataApp/factory/PVDataCreateFactory.cpp +++ b/pvDataApp/factory/PVDataCreateFactory.cpp @@ -3,7 +3,9 @@ #include #include #include +#include #include "pvData.h" +#include "convert.h" #include "factory.h" #include "AbstractPVField.h" #include "AbstractPVScalar.h" @@ -17,8 +19,6 @@ namespace epics { namespace pvData { - static std::string notImplemented("not implemented"); - static FieldCreate * fieldCreate = 0; static PVDataCreate* pvDataCreate = 0; @@ -156,8 +156,11 @@ namespace epics { namespace pvData { }; PVDataCreate * getPVDataCreate() { - if(pvDataCreate==0) pvDataCreate = new PVDataCreateExt(); - return pvDataCreate; + static epicsMutex *lock = new epicsMutex(); + lock->lock(); + if(pvDataCreate==0) pvDataCreate = new PVDataCreateExt(); + lock->unlock(); + return pvDataCreate; } }} diff --git a/pvDataApp/factory/TypeFunc.cpp b/pvDataApp/factory/TypeFunc.cpp index 4d2771f..e1903d4 100644 --- a/pvDataApp/factory/TypeFunc.cpp +++ b/pvDataApp/factory/TypeFunc.cpp @@ -4,7 +4,7 @@ #include #include -#include "pvData.h" +#include "pvIntrospect.h" namespace epics { namespace pvData { diff --git a/pvDataApp/factory/factory.h b/pvDataApp/factory/factory.h index f4e95bc..0c1f4d8 100644 --- a/pvDataApp/factory/factory.h +++ b/pvDataApp/factory/factory.h @@ -8,10 +8,5 @@ namespace epics { namespace pvData { static DebugLevel debugLevel = highDebug; - static void newLine(StringPtr buffer,int indentLevel) { - *buffer += "\n"; - for(int i=0; i #include -#include #ifndef CONVERT_H #define CONVERT_H #include "pvIntrospect.h" @@ -9,21 +8,76 @@ namespace epics { namespace pvData { - class Convert { public: Convert(); ~Convert(); - void getFullName(std::string *buf,PVField *pvField); - void getString(std::string *buf,PVfield *pvField,int indentLevel); - void getString(std::string *buf,PVfield *pvField); + void getFullName(StringConstPtr buf,PVField const *pvField); + void getString(StringPtr buf,PVField const * pvField,int indentLevel); + void getString(StringPtr buf,PVField const * pvField); void fromString(PVScalar *pv, StringConstPtr from); int fromString(PVScalarArray *pv, StringConstPtr from); + int fromStringArray(PVScalarArray *pv, int offset, int length, + StringPtrArray from, int fromOffset); + int toStringArray(PVScalarArray const *pv, int offset, int length, + StringPtrArray to, int fromOffset); + epicsBoolean isCopyCompatible(FieldConstPtr from, FieldConstPtr to); + void copy(PVField const *from,PVField *to); + epicsBoolean isCopyScalarCompatible( + ScalarConstPtr from, ScalarConstPtr to); + void copyScalar(PVScalar const *from, PVScalar *to); + epicsBoolean isCopyScalarArrayCompatible(ScalarArrayConstPtr from, + ScalarArrayConstPtr to); + int copyScalarArray(PVScalarArray const *from, int offset, + PVScalarArray *to, int toOffset, int length); + epicsBoolean isCopyStructureCompatible( + StructureConstPtr from, StructureConstPtr to); + void copyStructure(PVStructure const *from, PVStructure *to); + epicsBoolean isCopyStructureArrayCompatible( + StructureArrayConstPtr from, StructureArrayConstPtr to); + void copyStructureArray( + PVStructureArray const *from, PVStructureArray *to); + epicsInt8 toByte(PVScalar const *pv); + epicsInt16 toShort(PVScalar const *pv); + epicsInt32 toInt(PVScalar const *pv); + epicsInt64 toLong(PVScalar const *pv); + float toFloat(PVScalar const *pv); + double toDouble(PVScalar const *pv); + void fromByte(PVScalar *pv,epicsInt8 from); + void fromShort(PVScalar *pv,epicsInt16 from); + void fromInt(PVScalar *pv, epicsInt32 from); + void fromLong(PVScalar *pv, epicsInt64 from); + void fromFloat(PVScalar* pv, float from); + void fromDouble(PVScalar *pv, double from); + int toByteArray(PVScalarArray const *pv, int offset, int length, + epicsInt8 to[], int toOffset); + int toShortArray(PVScalarArray const *pv, int offset, int length, + epicsInt16 to[], int toOffset); + int toIntArray(PVScalarArray const *pv, int offset, int length, + epicsInt32 to[], int toOffset); + int toLongArray(PVScalarArray const *pv, int offset, int length, + epicsInt64 to[], int toOffset); + int toFloatArray(PVScalarArray const *pv, int offset, int length, + float to[], int toOffset); + int toDoubleArray(PVScalarArray const *pv, int offset, int length, + double to[], int toOffset); + int fromByteArray(PVScalarArray *pv, int offset, int length, + epicsInt8 from[], int fromOffset); + int fromShortArray(PVScalarArray *pv, int offset, int length, + epicsInt16 from[], int fromOffset); + int fromIntArray(PVScalarArray *pv, int offset, int length, + epicsInt32 from[], int fromOffset); + int fromLongArray(PVScalarArray *pv, int offset, int length, + epicsInt64 from[], int fromOffset); + int fromFloatArray(PVScalarArray *pv, int offset, int length, + float from[], int fromOffset); + int fromDoubleArray(PVScalarArray *pv, int offset, int length, + double from[], int fromOffset); + void newLine(StringPtr buf, int indentLevel); + private: - Convert(); // not implemented Convert(Convert const & ); // not implemented Convert & operator=(Convert const &); //not implemented - class Convert *pImpl; }; extern Convert * getConvert(); diff --git a/pvDataApp/pv/pvData.h b/pvDataApp/pv/pvData.h index fce174b..2889a89 100644 --- a/pvDataApp/pv/pvData.h +++ b/pvDataApp/pv/pvData.h @@ -45,6 +45,7 @@ namespace epics { namespace pvData { void toString(StringPtr buf); void toString(StringPtr buf,int indentLevel); private: + static void init(); PVAuxInfo(); // not implemented PVAuxInfo(PVAuxInfo const & ); // not implemented PVAuxInfo & operator=(PVAuxInfo const &); //not implemented diff --git a/pvDataApp/pv/pvIntrospect.h b/pvDataApp/pv/pvIntrospect.h index 7ff80ff..7903603 100644 --- a/pvDataApp/pv/pvIntrospect.h +++ b/pvDataApp/pv/pvIntrospect.h @@ -11,6 +11,7 @@ namespace epics { namespace pvData { class StructureArray; typedef std::string * StringPtr; + typedef StringPtr * StringPtrArray; // pointer to constant string typedef std::string const * StringConstPtr; //array of pointers to constant string diff --git a/pvDataApp/test/Makefile b/pvDataApp/test/Makefile index 5f2b0a9..b1ecd3d 100644 --- a/pvDataApp/test/Makefile +++ b/pvDataApp/test/Makefile @@ -2,9 +2,9 @@ TOP=../.. include $(TOP)/configure/CONFIG -PROD_HOST += test -test_SRCS += test.cpp -test_LIBS += pvFactory +PROD_HOST += testIntrospect +testIntrospect_SRCS += testIntrospect.cpp +testIntrospect_LIBS += pvFactory PROD_HOST += testDumpStdString testDumpStdString_SRCS += testDumpStdString.cpp diff --git a/pvDataApp/test/testDumpStdString.cpp b/pvDataApp/test/testDumpStdString.cpp index d9a0f18..6870fa7 100644 --- a/pvDataApp/test/testDumpStdString.cpp +++ b/pvDataApp/test/testDumpStdString.cpp @@ -7,7 +7,7 @@ #include #include -#include "pvData.h" +#include "pvIntrospect.h" using namespace epics::pvData; using namespace std; diff --git a/pvDataApp/test/test.cpp b/pvDataApp/test/testIntrospect.cpp similarity index 98% rename from pvDataApp/test/test.cpp rename to pvDataApp/test/testIntrospect.cpp index 8e8c1b6..9d90ac4 100644 --- a/pvDataApp/test/test.cpp +++ b/pvDataApp/test/testIntrospect.cpp @@ -7,7 +7,7 @@ #include #include -#include "pvData.h" +#include "pvIntrospect.h" using namespace epics::pvData; diff --git a/pvDataApp/test/testPVScalar.cpp b/pvDataApp/test/testPVScalar.cpp index 9b28ce8..25b32af 100644 --- a/pvDataApp/test/testPVScalar.cpp +++ b/pvDataApp/test/testPVScalar.cpp @@ -25,32 +25,32 @@ void testDouble() { double value = 2; pvValue->put(value); double getValue = pvValue->get(); + printf("put %lf get %lf\n",value,getValue); if(value!=getValue) { fprintf(stderr,"ERROR getValue put %f get %f\n",value,getValue); } + FieldConstPtr field = pvValue->getField(); + buffer->clear(); + field->toString(buffer); + printf("%s\n",buffer->c_str()); + epicsBoolean isImmutable = pvValue->isImmutable(); + PVStructure *pvParent = pvValue->getParent(); + printf("immutable %s parent %p\n", + ((isImmutable==epicsFalse) ? "false" : "true"), + pvParent); + int offset = pvValue->getFieldOffset(); + int nextOffset = pvValue->getNextFieldOffset(); + int numberFields = pvValue->getNumberFields(); + printf("offset %d nextOffset %d numberFields %d\n", + offset,nextOffset,numberFields); + ScalarConstPtr scalar = dynamic_cast(field); + if(scalar!=field) { + fprintf(stderr,"ERROR field!=scalar field %p scalar %p\n",field,scalar); + } buffer->clear(); *buffer += "value "; pvValue->toString(buffer); printf("%s\n",buffer->c_str()); - int offset = pvValue->getFieldOffset(); - int nextOffset = pvValue->getNextFieldOffset(); - int numberFields = pvValue->getNumberFields(); - PVAuxInfo *auxInfo = pvValue->getPVAuxInfo(); - epicsBoolean isImmutable = pvValue->isImmutable(); - PVStructure *pvParent = pvValue->getParent(); - printf("offset %d nextOffset %d numberFields %d auxInfo %p immutable %s parent %p\n", - offset,nextOffset,numberFields,auxInfo, - ((isImmutable==epicsFalse) ? "false" : "true"), - pvParent); - FieldConstPtr field = pvValue->getField(); - buffer->clear(); - *buffer += "field "; - field->toString(buffer); - printf("%s\n",buffer->c_str()); - ScalarConstPtr scalar = dynamic_cast(field); - if(scalar!=field) { - fprintf(stderr,"ERROR field!=scalar field %p scalar %p\n",field,scalar); - } delete pvValue; }