diff --git a/pvDataApp/factory/AbstractPVArray.h b/pvDataApp/factory/AbstractPVArray.h index aafefe8..fd16164 100644 --- a/pvDataApp/factory/AbstractPVArray.h +++ b/pvDataApp/factory/AbstractPVArray.h @@ -28,9 +28,11 @@ namespace epics { namespace pvData { delete pImpl; } - int PVArray::getLength() const {return pImpl->length;} + int PVArray::getLength() {return pImpl->length;} - static StringConst fieldImmutable("field is immutable"); + int PVArray::getCapacity() {return pImpl->capacity;} + + static String fieldImmutable("field is immutable"); void PVArray::setLength(int length) { if(PVField::isImmutable()) { @@ -43,7 +45,7 @@ namespace epics { namespace pvData { } - epicsBoolean PVArray::isCapacityImmutable() const + epicsBoolean PVArray::isCapacityImmutable() { if(PVField::isImmutable()) { return epicsFalse; @@ -60,7 +62,7 @@ namespace epics { namespace pvData { pImpl->capacityMutable = isMutable; } - static StringConst capacityImmutable("capacity is immutable"); + static String capacityImmutable("capacity is immutable"); void PVArray::setCapacity(int capacity) { if(PVField::isImmutable()) { @@ -74,9 +76,9 @@ namespace epics { namespace pvData { pImpl->capacity = capacity; } - void PVArray::toString(StringBuilder buf) const {toString(buf,0);} + void PVArray::toString(StringBuilder buf) {toString(buf,0);} - void PVArray::toString(StringBuilder buf, int indentLevel) const + void PVArray::toString(StringBuilder buf, int indentLevel) { throw std::logic_error(notImplemented); } diff --git a/pvDataApp/factory/AbstractPVField.h b/pvDataApp/factory/AbstractPVField.h index 8b280ee..b938de7 100644 --- a/pvDataApp/factory/AbstractPVField.h +++ b/pvDataApp/factory/AbstractPVField.h @@ -11,7 +11,7 @@ namespace epics { namespace pvData { -static StringConst notImplemented("not implemented"); +static String notImplemented("not implemented"); static Convert *convert = 0; @@ -60,14 +60,14 @@ static StringConst notImplemented("not implemented"); delete pImpl; } - StringConst PVField::getRequesterName() const + String PVField::getRequesterName() { - static StringConst none("none"); + static String none("none"); if(pImpl->requester!=0) return pImpl->requester->getRequesterName(); return none; } - void PVField::message(StringConst message,MessageType messageType) const + void PVField::message(String message,MessageType messageType) { if(pImpl->requester) { pImpl->requester->message(message,messageType); @@ -80,7 +80,7 @@ static StringConst notImplemented("not implemented"); } void PVField::setRequester(Requester *prequester) { - static StringConst requesterPresent = + static String requesterPresent = "Logic Error. requester is already present"; if(pImpl->requester==0) { pImpl->requester = prequester; @@ -89,19 +89,19 @@ static StringConst notImplemented("not implemented"); throw std::logic_error(requesterPresent); } - int PVField::getFieldOffset() const + int PVField::getFieldOffset() { if(pImpl->nextFieldOffset==0) computeOffset(this); return pImpl->fieldOffset; } - int PVField::getNextFieldOffset() const + int PVField::getNextFieldOffset() { if(pImpl->nextFieldOffset==0) computeOffset(this); return pImpl->nextFieldOffset; } - int PVField::getNumberFields() const + int PVField::getNumberFields() { if(pImpl->nextFieldOffset==0) computeOffset(this); return (pImpl->nextFieldOffset - pImpl->fieldOffset); @@ -114,25 +114,25 @@ static StringConst notImplemented("not implemented"); return pImpl->pvAuxInfo; } - epicsBoolean PVField::isImmutable() const {return pImpl->immutable;} + epicsBoolean PVField::isImmutable() {return pImpl->immutable;} void PVField::setImmutable() {pImpl->immutable = epicsTrue;} - FieldConstPtr PVField::getField() const {return pImpl->field;} + FieldConstPtr PVField::getField() {return pImpl->field;} - PVStructure * PVField::getParent() const {return pImpl->parent;} + PVStructure * PVField::getParent() {return pImpl->parent;} void PVField::replacePVField(PVField * newPVField) { throw std::logic_error(notImplemented); } - void PVField::renameField(StringConst newName) + void PVField::renameField(String newName) { throw std::logic_error(notImplemented); } - void PVField::postPut() const + void PVField::postPut() { throw std::logic_error(notImplemented); } @@ -142,14 +142,14 @@ static StringConst notImplemented("not implemented"); throw std::logic_error(notImplemented); } - void PVField::toString(StringBuilder buf) const {toString(buf,0);} + void PVField::toString(StringBuilder buf) {toString(buf,0);} - void PVField::toString(StringBuilder buf,int indentLevel) const + void PVField::toString(StringBuilder buf,int indentLevel) { throw std::logic_error(notImplemented); } - void PVField::computeOffset(PVField const * const pvField) { + void PVField::computeOffset(PVField * pvField) { PVStructure *pvTop = pvField->getParent(); if(pvTop==0) { pvTop = (PVStructure *)pvField; @@ -160,7 +160,7 @@ static StringConst notImplemented("not implemented"); } int offset = 0; int nextOffset = 1; - PVFieldArrayPtr pvFields = pvTop->getPVFields(); + PVFieldPtrArray pvFields = pvTop->getPVFields(); for(int i=0; i < pvTop->getStructure()->getNumberFields(); i++) { offset = nextOffset; PVField *pvField = pvFields[i]; @@ -185,11 +185,11 @@ static StringConst notImplemented("not implemented"); top->pImpl->nextFieldOffset = nextOffset; } - void PVField::computeOffset(PVField const * const pvField,int offset) { + void PVField::computeOffset(PVField * pvField,int offset) { int beginOffset = offset; int nextOffset = offset + 1; PVStructure *pvStructure = (PVStructure *)pvField; - PVFieldArrayPtr pvFields = pvStructure->getPVFields(); + PVFieldPtrArray pvFields = pvStructure->getPVFields(); for(int i=0; i < pvStructure->getStructure()->getNumberFields(); i++) { offset = nextOffset; PVField *pvSubField = pvFields[i]; diff --git a/pvDataApp/factory/AbstractPVScalar.h b/pvDataApp/factory/AbstractPVScalar.h index cf46f70..7314e4d 100644 --- a/pvDataApp/factory/AbstractPVScalar.h +++ b/pvDataApp/factory/AbstractPVScalar.h @@ -16,7 +16,7 @@ namespace epics { namespace pvData { PVScalar::PVScalar(PVStructure *parent,ScalarConstPtr scalar) : PVField(parent,scalar) {} - ScalarConstPtr PVScalar::getScalar() const + ScalarConstPtr PVScalar::getScalar() { return (ScalarConstPtr) PVField::getField(); } diff --git a/pvDataApp/factory/AbstractPVScalarArray.h b/pvDataApp/factory/AbstractPVScalarArray.h index f380eec..64b997a 100644 --- a/pvDataApp/factory/AbstractPVScalarArray.h +++ b/pvDataApp/factory/AbstractPVScalarArray.h @@ -17,7 +17,7 @@ namespace epics { namespace pvData { ScalarArrayConstPtr scalarArray) : PVArray(parent,scalarArray) {} - ScalarArrayConstPtr PVScalarArray::getScalarArray() const + ScalarArrayConstPtr PVScalarArray::getScalarArray() { return (ScalarArrayConstPtr) PVField::getField(); } diff --git a/pvDataApp/factory/BasePVDouble.h b/pvDataApp/factory/BasePVDouble.h index 4a5efd6..98d91b6 100644 --- a/pvDataApp/factory/BasePVDouble.h +++ b/pvDataApp/factory/BasePVDouble.h @@ -18,14 +18,15 @@ namespace epics { namespace pvData { public: BasePVDouble(PVStructure *parent,ScalarConstPtr scalar); virtual ~BasePVDouble(); - virtual double get()const; + virtual double get(); virtual void put(double val); virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher) const; + SerializableControl *pflusher) ; virtual void deserialize(ByteBuffer *pbuffer, DeserializableControl *pflusher); - virtual void toString(StringBuilder buf)const; - virtual void toString(StringBuilder buf,int indentLevel)const; + virtual void toString(StringBuilder buf); + virtual void toString(StringBuilder buf,int indentLevel); + virtual epicsBoolean equals(PVField *pv) ; private: double value; }; @@ -36,12 +37,12 @@ namespace epics { namespace pvData { BasePVDouble::~BasePVDouble() {} - double BasePVDouble::get()const { return value;} + double BasePVDouble::get() { return value;} void BasePVDouble::put(double val){value = val;} void BasePVDouble::serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher) const + SerializableControl *pflusher) { throw std::logic_error(notImplemented); } @@ -52,13 +53,18 @@ namespace epics { namespace pvData { throw std::logic_error(notImplemented); } - void BasePVDouble::toString(StringBuilder buf)const {toString(buf,0);} + void BasePVDouble::toString(StringBuilder buf) {toString(buf,0);} - void BasePVDouble::toString(StringBuilder buf,int indentLevel) const + void BasePVDouble::toString(StringBuilder buf,int indentLevel) { convert->getString(buf,this,indentLevel); PVField::toString(buf,indentLevel); } + epicsBoolean BasePVDouble::equals(PVField *) + { + throw std::logic_error(notImplemented); + } + }} #endif /* BASEPVDOUBLE_H */ diff --git a/pvDataApp/factory/BasePVDoubleArray.h b/pvDataApp/factory/BasePVDoubleArray.h index e74cf9d..027beec 100644 --- a/pvDataApp/factory/BasePVDoubleArray.h +++ b/pvDataApp/factory/BasePVDoubleArray.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "pvData.h" #include "factory.h" #include "AbstractPVScalarArray.h" @@ -21,17 +22,18 @@ namespace epics { namespace pvData { BasePVDoubleArray(PVStructure *parent,ScalarArrayConstPtr scalarArray); virtual ~BasePVDoubleArray(); virtual void setCapacity(int capacity); - virtual int get(int offset, int length, DoubleArrayData *data) const; - virtual int put(int offset,int length,DoubleArrayPtr from, + virtual int get(int offset, int length, DoubleArrayData *data) ; + virtual int put(int offset,int length,DoubleArray from, int fromOffset); - virtual void shareData(DoubleArrayPtr from); - // from Serializable - virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const; - virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); - virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher, int offset, int count) const; - virtual void toString(StringBuilder buf)const; - virtual void toString(StringBuilder buf,int indentLevel)const; + virtual void shareData(DoubleArrayData *from); + // from Serializable + virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ; + virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); + virtual void serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher, int offset, int count) ; + virtual void toString(StringBuilder buf); + virtual void toString(StringBuilder buf,int indentLevel); + virtual epicsBoolean equals(PVField *pv) ; private: double *doubleArray; }; @@ -52,25 +54,25 @@ namespace epics { namespace pvData { } int BasePVDoubleArray::get(int offset, int length, - DoubleArrayData *data) const + DoubleArrayData *data) { data->data = doubleArray; return getLength(); } int BasePVDoubleArray::put(int offset,int length, - DoubleArrayPtr from,int fromOffset) + DoubleArray from,int fromOffset) { return getLength(); } - void BasePVDoubleArray::shareData(DoubleArrayPtr from) + void BasePVDoubleArray::shareData(DoubleArrayData *from) { throw std::logic_error(notImplemented); } void BasePVDoubleArray::serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher) const + SerializableControl *pflusher) { throw std::logic_error(notImplemented); } @@ -82,21 +84,25 @@ namespace epics { namespace pvData { } void BasePVDoubleArray::serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher, int offset, int count) const + SerializableControl *pflusher, int offset, int count) { throw std::logic_error(notImplemented); } - void BasePVDoubleArray::toString(StringBuilder buf)const + void BasePVDoubleArray::toString(StringBuilder buf) { toString(buf,1); } - void BasePVDoubleArray::toString(StringBuilder buf,int indentLevel)const + void BasePVDoubleArray::toString(StringBuilder buf,int indentLevel) { convert->getString(buf,this,indentLevel); PVArray::toString(buf,indentLevel); } + epicsBoolean BasePVDoubleArray::equals(PVField *pv) + { + throw std::logic_error(notImplemented); + } }} #endif /* BASEPVDOUBLEARRAY_H */ diff --git a/pvDataApp/factory/BasePVStructure.h b/pvDataApp/factory/BasePVStructure.h index 915e97f..0c668bb 100644 --- a/pvDataApp/factory/BasePVStructure.h +++ b/pvDataApp/factory/BasePVStructure.h @@ -16,8 +16,8 @@ namespace epics { namespace pvData { ~PVStructurePvt(); int numberFields; - PVFieldArrayPtr pvFields; - StringConst const extendsStructureName; + PVFieldPtrArray pvFields; + String extendsStructureName; }; PVStructurePvt::PVStructurePvt() @@ -53,12 +53,12 @@ namespace epics { namespace pvData { return (StructureConstPtr)PVField::getField(); } - PVFieldArrayPtr PVStructure::getPVFields() + PVFieldPtrArray PVStructure::getPVFields() { return pImpl->pvFields; } - PVFieldPtr PVStructure::getSubField(StringConst fieldName) + PVFieldPtr PVStructure::getSubField(String fieldName) { throw std::logic_error(notImplemented); } @@ -73,93 +73,93 @@ namespace epics { namespace pvData { throw std::logic_error(notImplemented); } - void PVStructure::appendPVFields(PVFieldArrayPtr pvFields) + void PVStructure::appendPVFields(PVFieldPtrArray pvFields) { throw std::logic_error(notImplemented); } - void PVStructure::removePVField(StringConst fieldName) + void PVStructure::removePVField(String fieldName) { throw std::logic_error(notImplemented); } - PVBoolean *PVStructure::getBooleanField(StringConst fieldName) + PVBoolean *PVStructure::getBooleanField(String fieldName) { throw std::logic_error(notImplemented); } - PVByte *PVStructure::getByteField(StringConst fieldName) + PVByte *PVStructure::getByteField(String fieldName) { throw std::logic_error(notImplemented); } - PVShort *PVStructure::getShortField(StringConst fieldName) + PVShort *PVStructure::getShortField(String fieldName) { throw std::logic_error(notImplemented); } - PVInt *PVStructure::getIntField(StringConst fieldName) + PVInt *PVStructure::getIntField(String fieldName) { throw std::logic_error(notImplemented); } - PVLong *PVStructure::getLongField(StringConst fieldName) + PVLong *PVStructure::getLongField(String fieldName) { throw std::logic_error(notImplemented); } - PVFloat *PVStructure::getFloatField(StringConst fieldName) + PVFloat *PVStructure::getFloatField(String fieldName) { throw std::logic_error(notImplemented); } - PVDouble *PVStructure::getDoubleField(StringConst fieldName) + PVDouble *PVStructure::getDoubleField(String fieldName) { throw std::logic_error(notImplemented); } - PVString *PVStructure::getStringField(StringConst fieldName) + PVString *PVStructure::getStringField(String fieldName) { throw std::logic_error(notImplemented); } - PVStructure *PVStructure::getStructureField(StringConst fieldName) + PVStructure *PVStructure::getStructureField(String fieldName) { throw std::logic_error(notImplemented); } PVScalarArray *PVStructure::getScalarArrayField( - StringConst fieldName,ScalarType elementType) + String fieldName,ScalarType elementType) { throw std::logic_error(notImplemented); } PVStructureArray *PVStructure::getStructureArrayField( - StringConst fieldName) + String fieldName) { throw std::logic_error(notImplemented); } - StringConst PVStructure::getExtendsStructureName() + String PVStructure::getExtendsStructureName() { throw std::logic_error(notImplemented); } epicsBoolean PVStructure::putExtendsStructureName( - StringConst extendsStructureName) + String extendsStructureName) { throw std::logic_error(notImplemented); } - void PVStructure::toString(StringBuilder buf) const {toString(buf,0);} + void PVStructure::toString(StringBuilder buf) {toString(buf,0);} - void PVStructure::toString(StringBuilder buf,int indentLevel) const + void PVStructure::toString(StringBuilder buf,int indentLevel) { throw std::logic_error(notImplemented); } void PVStructure::serialize( - ByteBuffer *pbuffer,SerializableControl *pflusher) const + ByteBuffer *pbuffer,SerializableControl *pflusher) { throw std::logic_error(notImplemented); } @@ -171,13 +171,13 @@ namespace epics { namespace pvData { } void PVStructure::serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher, int offset, int count) const + SerializableControl *pflusher, int offset, int count) { throw std::logic_error(notImplemented); } void PVStructure::serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher,BitSet *pbitSet) const + SerializableControl *pflusher,BitSet *pbitSet) { throw std::logic_error(notImplemented); } @@ -188,6 +188,11 @@ namespace epics { namespace pvData { throw std::logic_error(notImplemented); } + epicsBoolean PVStructure::equals(PVField *pv) + { + throw std::logic_error(notImplemented); + } + class BasePVStructure : public PVStructure { public: BasePVStructure(PVStructure *parent,StructureConstPtr structure); diff --git a/pvDataApp/factory/BasePVStructureArray.h b/pvDataApp/factory/BasePVStructureArray.h index fb08959..32f9bf6 100644 --- a/pvDataApp/factory/BasePVStructureArray.h +++ b/pvDataApp/factory/BasePVStructureArray.h @@ -17,7 +17,7 @@ namespace epics { namespace pvData { StructureArrayConstPtr structureArray; StructureArrayData *structureArrayData; - PVStructureArrayPtr pvStructureArray; + PVStructurePtrArray pvStructureArray; }; PVStructureArrayPvt::PVStructureArrayPvt( StructureArrayConstPtr structureArray) @@ -45,30 +45,30 @@ namespace epics { namespace pvData { delete pImpl; } - StructureArrayConstPtr PVStructureArray::getStructureArray() const + StructureArrayConstPtr PVStructureArray::getStructureArray() { return pImpl->structureArray; } int PVStructureArray::get( - int offset, int length, StructureArrayData *data) const + int offset, int length, StructureArrayData *data) { throw std::logic_error(notImplemented); } int PVStructureArray::put(int offset,int length, - PVStructureArrayPtr from, int fromOffset) + PVStructurePtrArray from, int fromOffset) { throw std::logic_error(notImplemented); } - void PVStructureArray::shareData(PVStructureArrayPtr from) + void PVStructureArray::shareData(StructureArrayData *from) { throw std::logic_error(notImplemented); } void PVStructureArray::serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher) const + SerializableControl *pflusher) { throw std::logic_error(notImplemented); } @@ -80,14 +80,19 @@ namespace epics { namespace pvData { } void PVStructureArray::serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher, int offset, int count) const + SerializableControl *pflusher, int offset, int count) { throw std::logic_error(notImplemented); } - void PVStructureArray::toString(StringBuilder buf) const {toString(buf,0);} + void PVStructureArray::toString(StringBuilder buf) {toString(buf,0);} - void PVStructureArray::toString(StringBuilder buf,int indentLevel) const + void PVStructureArray::toString(StringBuilder buf,int indentLevel) + { + throw std::logic_error(notImplemented); + } + + epicsBoolean PVStructureArray::equals(PVField *pv) { throw std::logic_error(notImplemented); } diff --git a/pvDataApp/factory/Convert.cpp b/pvDataApp/factory/Convert.cpp index 4f4f430..a86027d 100644 --- a/pvDataApp/factory/Convert.cpp +++ b/pvDataApp/factory/Convert.cpp @@ -1,263 +1,851 @@ /* Convert.cpp */ +#include #include +#include #include -#include +#include +#include "lock.h" +#include "pvIntrospect.h" +#include "pvData.h" #include "convert.h" namespace epics { namespace pvData { -static std::string notImplemented("not implemented"); +static Convert* convert = 0; - Convert::Convert(){} +static String notImplemented("not implemented"); - Convert::~Convert(){} +static int convertFromByteArray(PVScalarArray *pv, int offset, + int len,epicsInt8 from[], int fromOffset); +static int convertToByteArray(PVScalarArray *pv, int offset, + int len,epicsInt8 to[], int toOffset); +static int convertFromShortArray(PVScalarArray *pv, int offset, + int len,epicsInt16 from[], int fromOffset); +static int convertToShortArray(PVScalarArray *pv, int offset, + int len,epicsInt16 to[], int toOffset); +static int convertFromIntArray(PVScalarArray *pv, int offset, + int len,epicsInt32 from[], int fromOffset); +static int convertToIntArray(PVScalarArray *pv, int offset, + int len,epicsInt32 to[], int toOffset); +static int convertFromLongArray(PVScalarArray *pv, int offset, + int len,epicsInt64 from[], int fromOffset); +static int convertToLongArray(PVScalarArray * pv, int offset, + int len,epicsInt64 to[], int toOffset); +static int convertFromFloatArray(PVScalarArray *pv, int offset, + int len,float from[], int fromOffset); +static int convertToFloatArray(PVScalarArray * pv, int offset, + int len,float to[], int toOffset); +static int convertFromDoubleArray(PVScalarArray *pv, int offset, + int len,double from[], int fromOffset); +static int convertToDoubleArray(PVScalarArray * pv, int offset, + int len,double to[], int toOffset); +static int convertFromStringArray(PVScalarArray *pv, int offset, + int len,String from[], int fromOffset); +static int convertToStringArray(PVScalarArray * pv, int offset, + int len,String to[], int toOffset); - void Convert::getFullName(StringConst buf,PVField const *pvField) - { - throw std::logic_error(notImplemented); +static void convertToString(StringBuilder buffer, + PVField * pv,int indentLevel); +static void convertStructure(StringBuilder buffer, + PVStructure *data,int indentLevel); +static void convertArray(StringBuilder buffer, + PVScalarArray * pv,int indentLevel); +static void convertStructureArray(StringBuilder buffer, + PVStructureArray * pvdata,int indentLevel); +static int copyArrayDataReference(PVScalarArray *from,PVArray *to); +static int CopyNumericArray(PVScalarArray *from, + int offset, PVScalarArray *to, int toOffset, int len); + +static std::vector split(String commaSeparatedList); + +static std::vector split(String commaSeparatedList) { + String::size_type numValues = 1; + String::size_type index=0; + while(epicsTrue) { + String::size_type pos = commaSeparatedList.find(',',index); + if(pos==String::npos) break; + numValues++; + index = pos +1; } - - void Convert::getString(StringBuilder buf,PVField const * pvField,int indentLevel) - { - throw std::logic_error(notImplemented); + std::vector valueList(numValues,""); + index=0; + for(size_t i=0; iempty(); + *buf += pvField->getField()->getFieldName(); + PVStructure *parent; + while((parent=pvField->getParent())!=0) { + pvField = pvField->getParent(); + String name = pvField->getField()->getFieldName(); + if(name.length()>0) { + buf->insert(0,"."); + buf->insert(0,name); + } } +} - void Convert::fromString(PVScalar *pv, StringConst from) - { - throw std::logic_error(notImplemented); +void Convert::getString(StringBuilder buf,PVField * pvField,int indentLevel) +{ + convertToString(buf,pvField,indentLevel); +} + +void Convert::getString(StringBuilder buf,PVField * pvField) +{ + convertToString(buf,pvField,0); +} + +void Convert::fromString(PVScalar *pvScalar, String from) +{ + ScalarConstPtr scalar = pvScalar->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: { + PVBoolean *pv = (PVBoolean *)pvScalar; + epicsBoolean value = + ((from.compare("true")==0) ? epicsTrue : epicsFalse); + pv->put(value); + break; + } + case pvByte : { + PVByte *pv = (PVByte*)pvScalar; + int ival; + sscanf(from.c_str(),"%d",&ival); + epicsInt8 value = ival; + pv->put(value); + break; + } + case pvShort : { + PVShort *pv = (PVShort*)pvScalar; + int ival; + sscanf(from.c_str(),"%d",&ival); + epicsInt16 value = ival; + pv->put(value); + break; + } + case pvInt : { + PVInt *pv = (PVInt*)pvScalar; + int ival; + sscanf(from.c_str(),"%d",&ival); + epicsInt32 value = ival; + pv->put(value); + break; + } + case pvLong : { + PVLong *pv = (PVLong*)pvScalar; + long int ival; + sscanf(from.c_str(),"%ld",&ival); + epicsInt64 value = ival; + pv->put(value); + break; + } + case pvFloat : { + PVFloat *pv = (PVFloat*)pvScalar; + float value; + sscanf(from.c_str(),"%f",&value); + pv->put(value); + break; + } + case pvDouble : { + PVDouble*pv = (PVDouble*)pvScalar; + double value; + sscanf(from.c_str(),"%lf",&value); + pv->put(value); + break; + } + case pvString: { + PVString *value = (PVString*)pvScalar; + value->put(from); + break; + } + default: + String message("Convert::fromString unknown scalarType "); + ScalarTypeFunc::toString(&message,scalarType); + throw std::logic_error(message); } +} - int Convert::fromString(PVScalarArray *pv, StringConst from) - { - throw std::logic_error(notImplemented); +int Convert::fromString(PVScalarArray *pv, String from) +{ + if(from[0]=='[' && from[from.length()]==']') { + int offset = from.rfind(']'); + from = from.substr(1, offset); } - - int Convert::fromStringArray(PVScalarArray *pv, int offset, int length, - StringConstArray from, int fromOffset) - { - throw std::logic_error(notImplemented); + std::vector valueList = split(from); + int length = valueList.size(); + StringArray valueArray = new String[length]; + for(int i=0; isetLength(length); + delete valueArray; + return length; +} - int Convert::toStringArray(PVScalarArray const *pv, int offset, int length, - StringConstArray to, int fromOffset) - { - throw std::logic_error(notImplemented); +int Convert::fromStringArray(PVScalarArray *pv, int offset, int length, + StringArray from, int fromOffset) +{ + return convertFromStringArray(pv,offset,length,from,fromOffset); +} + +int Convert::toStringArray(PVScalarArray * pv, int offset, int length, + StringArray to, int toOffset) +{ + return convertToStringArray(pv,offset,length,to,toOffset); +} + +epicsBoolean Convert::isCopyCompatible(FieldConstPtr from, FieldConstPtr to) +{ + if(from->getType()!=to->getType()) return epicsFalse; + switch(from->getType()) { + case scalar: + return isCopyScalarCompatible((ScalarConstPtr)from,(ScalarConstPtr)to); + case scalarArray: + return isCopyScalarArrayCompatible((ScalarArrayConstPtr)from,(ScalarArrayConstPtr)to); + case structure: + return isCopyStructureCompatible((StructureConstPtr)from,(StructureConstPtr)to); + case structureArray: + return isCopyStructureArrayCompatible((StructureArrayConstPtr)from,(StructureArrayConstPtr)to); } + String message("Convert::isCopyCompatible should never get here"); + throw std::logic_error(message); +} - epicsBoolean Convert::isCopyCompatible(FieldConstPtr from, FieldConstPtr to) - { - throw std::logic_error(notImplemented); +void Convert::copy(PVField *from,PVField *to) +{ + switch(from->getField()->getType()) { + case scalar: + copyScalar((PVScalar *)from,(PVScalar *)to); + return; + case scalarArray: { + PVScalarArray *fromArray = (PVScalarArray *)from; + PVScalarArray *toArray = (PVScalarArray *)to; + int length = copyScalarArray(fromArray,0,toArray,0,fromArray->getLength()); + if(toArray->getLength()!=length) toArray->setLength(length); + return; } - - void Convert::copy(PVField const *from,PVField *to) - { - throw std::logic_error(notImplemented); + case structure: + copyStructure((PVStructure *)from,(PVStructure *)to); + return; + case structureArray: { + PVStructureArray *fromArray = (PVStructureArray *)from; + PVStructureArray *toArray = (PVStructureArray *)to; + copyStructureArray(fromArray,toArray); + return; } - - 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::isCopyScalarCompatible( + ScalarConstPtr fromField, ScalarConstPtr toField) +{ + ScalarType fromScalarType = fromField->getScalarType(); + ScalarType toScalarType = toField->getScalarType(); + if(fromScalarType==toScalarType) return epicsTrue; + if(ScalarTypeFunc::isNumeric(fromScalarType) + && ScalarTypeFunc::isNumeric(toScalarType)) return epicsTrue; + if(fromScalarType==pvString) return epicsTrue; + if(toScalarType==pvString) return epicsTrue; + return epicsFalse; +} + +void Convert::copyScalar(PVScalar *from, PVScalar *to) +{ + if(to->isImmutable()) { + if(from->equals(to)) return; + String message("Convert.copyScalar destination is immutable"); + throw std::invalid_argument(message); } - - epicsBoolean Convert::isCopyScalarArrayCompatible(ScalarArrayConstPtr from, - ScalarArrayConstPtr to) - { - throw std::logic_error(notImplemented); + ScalarType fromType = from->getScalar()->getScalarType(); + ScalarType toType = to->getScalar()->getScalarType(); + switch(fromType) { + case pvBoolean: { + if(toType!=pvBoolean) { + if(toType!=pvString) { + String message("Convert.copyScalar arguments are not compatible"); + throw std::invalid_argument(message); + } + } + PVBoolean *data = (PVBoolean*)from; + if(toType==pvString) { + PVString *dataTo = (PVString*)to; + String buf(""); + data->toString(&buf); + dataTo->put(buf); + } else { + epicsBoolean value = data->get(); + PVBoolean *dataTo = (PVBoolean*)to; + dataTo->put(value); + } + break; + } + case pvByte : { + PVByte *data = (PVByte*)from; + epicsInt8 value = data->get(); + convert->fromByte(to,value); + break; + } + case pvShort : { + PVShort *data = (PVShort*)from; + short value = data->get(); + convert->fromShort(to,value); + break; + } + case pvInt :{ + PVInt *data = (PVInt*)from; + int value = data->get(); + convert->fromInt(to,value); + break; + } + case pvLong : { + PVLong *data = (PVLong*)from; + long value = data->get(); + convert->fromLong(to,value); + break; + } + case pvFloat : { + PVFloat *data = (PVFloat*)from; + float value = data->get(); + convert->fromFloat(to,value); + break; + } + case pvDouble : { + PVDouble *data = (PVDouble*)from; + double value = data->get(); + convert->fromDouble(to,value); + break; + } + case pvString: { + PVString *data = (PVString*)from; + String value = data->get(); + convert->fromString(to,value); + break; + } + default: + String message("Convert.copyScalar arguments are not compatible"); + throw std::invalid_argument(message); } +} - int Convert::copyScalarArray(PVScalarArray const *from, int offset, - PVScalarArray *to, int toOffset, int length) - { - throw std::logic_error(notImplemented); +epicsBoolean Convert::isCopyScalarArrayCompatible(ScalarArrayConstPtr fromArray, + ScalarArrayConstPtr toArray) +{ + ScalarType fromType = fromArray->getElementType(); + ScalarType toType = toArray->getElementType(); + if(fromType==toType) return epicsTrue; + if(ScalarTypeFunc::isNumeric(fromType) + && ScalarTypeFunc::isNumeric(toType)) return epicsTrue; + if(toType==pvString) return epicsTrue; + if(fromType==pvString) return epicsTrue; + return epicsFalse; +} + +int Convert::copyScalarArray(PVScalarArray *from, int offset, + PVScalarArray *to, int toOffset, int length) +{ + if(to->isImmutable()) { + if(from->equals(to)) return from->getLength(); + String message("Convert.copyArray destination is immutable"); + throw std::invalid_argument(message); } - - 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(StringBuilder buffer, int indentLevel) - { - *buffer += "\n"; - for(int i=0; igetScalarArray()->getElementType(); + ScalarType toElementType = to->getScalarArray()->getElementType(); + + if(from->isImmutable() && (fromElementType==toElementType)) { + if(offset==0 && toOffset==0 && length==from->getLength()) { + return copyArrayDataReference(from,to); + } } + int ncopy = 0; + if(ScalarTypeFunc::isNumeric(fromElementType) + && ScalarTypeFunc::isNumeric(toElementType)) { + return CopyNumericArray(from,offset,to,toOffset,length); + } else if(toElementType==pvBoolean && fromElementType==pvBoolean) { + PVBooleanArray *pvfrom = (PVBooleanArray*)from; + PVBooleanArray *pvto = (PVBooleanArray*)to; + while(length>0) { + int num = 0; + epicsBoolean *data = 0; + int fromOffset = 0; + BooleanArrayData booleanArrayData = BooleanArrayData(); + num = pvfrom->get(offset,length,&booleanArrayData); + data = booleanArrayData.data; + fromOffset = booleanArrayData.offset; + if(num<=0) return ncopy; + while(num>0) { + int n = pvto->put(toOffset,num,data,fromOffset); + if(n<=0) return ncopy; + length -= n; num -= n; ncopy+=n; offset += n; toOffset += n; + } + } + } else if(toElementType==pvString && fromElementType==pvString) { + PVStringArray *pvfrom = (PVStringArray*)from; + PVStringArray *pvto = (PVStringArray*)to; + while(length>0) { + int num = 0; + String *data; + int fromOffset = 0; + StringArrayData stringArrayData = StringArrayData(); + num = pvfrom->get(offset,length,&stringArrayData); + data = stringArrayData.data; + fromOffset = stringArrayData.offset; + if(num<=0) return ncopy; + while(num>0) { + int n = pvto->put(toOffset,num,data,fromOffset); + if(n<=0) return ncopy; + length -= n; num -= n; ncopy+=n; offset += n; toOffset += n; + } + } + } else if(toElementType==pvString) { + PVStringArray *pvto = (PVStringArray*)to; + ncopy = from->getLength(); + if(ncopy>length) ncopy = length; + int num = ncopy; + String toData[1]; + while(num>0) { + convert->toStringArray(from,offset,1,toData,0); + if(pvto->put(toOffset,1,toData,0)<=0) break; + num--; offset++; toOffset++; + } + return ncopy; + } else if(fromElementType==pvString) { + PVStringArray *pvfrom = (PVStringArray*)from; + while(length>0) { + int num = 0; + String *data = 0; + int fromOffset = 0; + StringArrayData stringArrayData = StringArrayData(); + num = pvfrom->get(offset,length,&stringArrayData); + data = stringArrayData.data; + fromOffset = stringArrayData.offset; + if(num<=0) return ncopy; + while(num>0) { + int n = fromStringArray(to,toOffset,num,data,fromOffset); + if(n<=0) return ncopy; + length -= n; num -= n; ncopy+=n; offset += n; toOffset += n; + } + } + } + String message("Convert::copyScalarArray should not get here"); + throw std::logic_error(message); +} + +epicsBoolean Convert::isCopyStructureCompatible( + StructureConstPtr fromStruct, StructureConstPtr toStruct) +{ + FieldConstPtrArray fromFields = fromStruct->getFields(); + FieldConstPtrArray toFields = toStruct->getFields(); + int length = fromStruct->getNumberFields(); + if(length!=toStruct->getNumberFields()) return epicsFalse; + for(int i=0; igetType(); + Type toType = to->getType(); + if(fromType!=toType) return epicsFalse; + switch(fromType) { + case scalar: + if(!convert->isCopyScalarCompatible((ScalarConstPtr)from,(ScalarConstPtr)to)) return epicsFalse; + break; + case scalarArray: + if(!isCopyScalarArrayCompatible((ScalarArrayConstPtr)from,(ScalarArrayConstPtr)to)) + return epicsFalse; + break; + case structure: + if(!isCopyStructureCompatible((StructureConstPtr)from,(StructureConstPtr)to)) + return epicsFalse; + break; + case structureArray: + if(!isCopyStructureArrayCompatible((StructureArrayConstPtr)from, + (StructureArrayConstPtr)to)) return epicsFalse; + } + } + return epicsTrue; +} + +void Convert::copyStructure(PVStructure *from, PVStructure *to) +{ + if(to->isImmutable()) { + if(from->equals(to)) return; + String message("Convert.copyStructure destination is immutable"); + throw std::invalid_argument(message); + } + if(from==to) return; + PVFieldPtrArray fromDatas = from->getPVFields(); + PVFieldPtrArray toDatas = to->getPVFields(); + if(from->getStructure()->getNumberFields() + != to->getStructure()->getNumberFields()) { + String message("Convert.copyStructure Illegal copyStructure"); + throw std::invalid_argument(message); + } + int numberFields = from->getStructure()->getNumberFields(); + if(numberFields==2) { + // look for enumerated structure and copy choices first + String fieldName = fromDatas[0]->getField()->getFieldName(); + if(fieldName.compare("index")==0) { + FieldConstPtr fieldIndex = fromDatas[0]->getField(); + FieldConstPtr fieldChoices = fromDatas[1]->getField(); + if(fieldIndex->getType()==scalar + && fieldChoices->getFieldName().compare("choices") + && fieldChoices->getType()==scalarArray) { + PVScalar *pvScalar = (PVScalar*)fromDatas[0]; + PVScalarArray *pvArray = (PVScalarArray*)fromDatas[1]; + if((pvScalar->getScalar()->getScalarType()==pvInt) + && (pvArray->getScalarArray()->getElementType()==pvString)) { + PVScalarArray* toArray = (PVScalarArray*)toDatas[1]; + copyScalarArray(pvArray,0,toArray,0,pvArray->getLength()); + PVScalar *toScalar = (PVScalar*)toDatas[0]; + copyScalar(pvScalar,toScalar); + return; + } + } + } + } + for(int i=0; i < numberFields; i++) { + PVField *fromData = fromDatas[i]; + PVField *toData = toDatas[i]; + Type fromType = fromData->getField()->getType(); + Type toType = toData->getField()->getType(); + if(fromType!=toType) { + String message("Convert.copyStructure Illegal copyStructure"); + throw std::invalid_argument(message); + } + switch(fromType) { + case scalar: + copyScalar((PVScalar*)fromData,(PVScalar*)toData); + break; + case scalarArray: { + PVScalarArray *fromArray = (PVScalarArray*)fromData; + PVScalarArray *toArray = (PVScalarArray*)toData; + int length = copyScalarArray(fromArray,0,toArray,0,fromArray->getLength()); + if(toArray->getLength()!=length) toArray->setLength(length); + break; + } + case structure: + copyStructure((PVStructure*)fromData,(PVStructure*)toData); + break; + case structureArray: { + PVStructureArray *fromArray = (PVStructureArray*)fromData; + PVStructureArray *toArray = (PVStructureArray*)toData; + copyStructureArray(fromArray,toArray); + break; + } + } + } +} + +epicsBoolean Convert::isCopyStructureArrayCompatible( + StructureArrayConstPtr from, StructureArrayConstPtr to) +{ + return isCopyStructureCompatible(from->getStructure(),to->getStructure()); +} + +void Convert::copyStructureArray( + PVStructureArray *from, PVStructureArray *to) +{ + if(to->isImmutable()) { + if(from->equals(to)) return; + String message("Convert.copyStructureArray destination is immutable"); + throw std::invalid_argument(message); + } + if(!isCopyStructureCompatible( + from->getStructureArray()->getStructure(), + to->getStructureArray()->getStructure())) { + String message("Convert.copyStructureArray from and to are not compatible"); + throw std::invalid_argument(message); + } + PVStructurePtrArray fromArray = 0; + int length = from->getLength(); + StructureArrayData structureArrayData = StructureArrayData(); + from->get(0, length,&structureArrayData); + fromArray = structureArrayData.data; + PVStructurePtrArray toArray = 0; + if(to->getCapacity()setCapacity(length); + to->get(0, length,&structureArrayData); + toArray = structureArrayData.data; + for(int i=0; igetStructureArray()->getStructure(); + toArray[i] = getPVDataCreate()->createPVStructure(0,structure); + } + copyStructure(fromArray[i],toArray[i]); + } + } + to->setLength(length); + to->postPut(); +} + +epicsInt8 Convert::toByte(PVScalar * pv) +{ + throw std::logic_error(notImplemented); +} + +epicsInt16 Convert::toShort(PVScalar * pv) +{ + throw std::logic_error(notImplemented); +} + +epicsInt32 Convert::toInt(PVScalar * pv) +{ + throw std::logic_error(notImplemented); +} + +epicsInt64 Convert::toLong(PVScalar * pv) +{ + throw std::logic_error(notImplemented); +} + +float Convert::toFloat(PVScalar * pv) +{ + throw std::logic_error(notImplemented); +} + +double Convert::toDouble(PVScalar * 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 * pv, int offset, int length, + epicsInt8 to[], int toOffset) +{ + throw std::logic_error(notImplemented); +} + +int Convert::toShortArray(PVScalarArray * pv, int offset, int length, + epicsInt16 to[], int toOffset) +{ + throw std::logic_error(notImplemented); +} + +int Convert::toIntArray(PVScalarArray * pv, int offset, int length, + epicsInt32 to[], int toOffset) +{ + throw std::logic_error(notImplemented); +} + +int Convert::toLongArray(PVScalarArray * pv, int offset, int length, + epicsInt64 to[], int toOffset) +{ + throw std::logic_error(notImplemented); +} + +int Convert::toFloatArray(PVScalarArray * pv, int offset, int length, + float to[], int toOffset) +{ + throw std::logic_error(notImplemented); +} + +int Convert::toDoubleArray(PVScalarArray * 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(StringBuilder buffer, int indentLevel) +{ + *buffer += "\n"; + for(int i=0; igetFieldName(); + String name = fields[i]->getFieldName(); // look for duplicates for(int j=i+1; jgetFieldName(); + String otherName = fields[j]->getFieldName(); int result = name.compare(otherName); if(result==0) { String message("duplicate fieldName "); @@ -172,7 +172,7 @@ namespace epics { namespace pvData { } } - FieldConstPtr BaseStructure::getField(StringConst fieldName) const { + FieldConstPtr BaseStructure::getField(String fieldName) const { for(int i=0; igetFieldName()); @@ -181,7 +181,7 @@ namespace epics { namespace pvData { return 0; } - int BaseStructure::getFieldIndex(StringConst fieldName) const { + int BaseStructure::getFieldIndex(String fieldName) const { for(int i=0; igetFieldName()); @@ -205,12 +205,12 @@ namespace epics { namespace pvData { class BaseStructureArray: private BaseField,public StructureArray { public: - BaseStructureArray(StringConst fieldName,StructureConstPtr structure); + BaseStructureArray(String fieldName,StructureConstPtr structure); virtual ~BaseStructureArray(); virtual void incReferenceCount() const {BaseField::incReferenceCount();} virtual void decReferenceCount() const {BaseField::decReferenceCount();} virtual int getReferenceCount() const {return BaseField::getReferenceCount();} - virtual StringConst getFieldName() const{ + virtual String getFieldName() const{ return BaseField::getFieldName(); } virtual Type getType() const{return BaseField::getType();} @@ -221,7 +221,7 @@ namespace epics { namespace pvData { StructureConstPtr pstructure; }; - BaseStructureArray::BaseStructureArray(StringConst fieldName,StructureConstPtr structure) + BaseStructureArray::BaseStructureArray(String fieldName,StructureConstPtr structure) : BaseField(fieldName,structureArray),pstructure(structure) { pstructure->incReferenceCount(); @@ -241,7 +241,7 @@ namespace epics { namespace pvData { FieldCreate::FieldCreate(){}; - ScalarConstPtr FieldCreate::createScalar(StringConst fieldName, + ScalarConstPtr FieldCreate::createScalar(String fieldName, ScalarType scalarType) const { BaseScalar *baseScalar = new BaseScalar(fieldName,scalarType); @@ -249,13 +249,13 @@ namespace epics { namespace pvData { } ScalarArrayConstPtr FieldCreate::createScalarArray( - StringConst fieldName,ScalarType elementType) const + String fieldName,ScalarType elementType) const { BaseScalarArray *baseScalarArray = new BaseScalarArray(fieldName,elementType); return baseScalarArray; } StructureConstPtr FieldCreate::createStructure ( - StringConst fieldName,int numberFields, + String fieldName,int numberFields, FieldConstPtr fields[]) const { BaseStructure *baseStructure = new BaseStructure( @@ -263,13 +263,13 @@ namespace epics { namespace pvData { return baseStructure; } StructureArrayConstPtr FieldCreate::createStructureArray( - StringConst fieldName,StructureConstPtr structure) const + String fieldName,StructureConstPtr structure) const { BaseStructureArray *baseStructureArray = new BaseStructureArray(fieldName,structure); return baseStructureArray; } - FieldConstPtr FieldCreate::create(StringConst fieldName, + FieldConstPtr FieldCreate::create(String fieldName, FieldConstPtr pfield) const { Type type = pfield->getType(); diff --git a/pvDataApp/factory/Makefile b/pvDataApp/factory/Makefile index ba998b3..bf006fe 100644 --- a/pvDataApp/factory/Makefile +++ b/pvDataApp/factory/Makefile @@ -17,6 +17,7 @@ LIBSRCS += PVAuxInfoImpl.cpp LIBSRCS += FieldCreateFactory.cpp LIBSRCS += PVDataCreateFactory.cpp LIBSRCS += Convert.cpp +LIBSRCS += StandardField.cpp LIBRARY=pvFactory diff --git a/pvDataApp/factory/PVAuxInfoImpl.cpp b/pvDataApp/factory/PVAuxInfoImpl.cpp index 759540c..f643c81 100644 --- a/pvDataApp/factory/PVAuxInfoImpl.cpp +++ b/pvDataApp/factory/PVAuxInfoImpl.cpp @@ -15,10 +15,10 @@ namespace epics { namespace pvData { public: PVAuxInfoPvt(PVField *pvField) : pvField(pvField), - theMap(std::map()) + theMap(std::map()) {} PVField *pvField; - std::map theMap; + std::map theMap; }; PVAuxInfo::PVAuxInfo(PVField *pvField) @@ -35,9 +35,9 @@ namespace epics { namespace pvData { return pImpl->pvField; } - typedef std::map::const_iterator map_iterator; + typedef std::map::const_iterator map_iterator; - PVScalar * PVAuxInfo::createInfo(StringConst key,ScalarType scalarType) + PVScalar * PVAuxInfo::createInfo(String key,ScalarType scalarType) { map_iterator i = pImpl->theMap.find(key); if(i!=pImpl->theMap.end()) { @@ -48,17 +48,17 @@ namespace epics { namespace pvData { pImpl->pvField->message(message,errorMessage); } PVScalar *pvScalar = pvDataCreate->createPVScalar(0,key,scalarType); - pImpl->theMap.insert(std::pair(key, pvScalar)); + pImpl->theMap.insert(std::pair(key, pvScalar)); return pvScalar; } - std::map *PVAuxInfo::getInfos() + std::map *PVAuxInfo::getInfos() { return &pImpl->theMap; } - PVScalar * PVAuxInfo::getInfo(StringConst key) + PVScalar * PVAuxInfo::getInfo(String key) { map_iterator i = pImpl->theMap.find(key); if(i!=pImpl->theMap.end()) return i->second; @@ -74,7 +74,7 @@ namespace epics { namespace pvData { { map_iterator i = pImpl->theMap.begin(); while(i!=pImpl->theMap.end()) { - StringConst key = i->first; + String key = i->first; PVScalar *value = i->second; *buf += " "; *buf += key.c_str(); diff --git a/pvDataApp/factory/PVDataCreateFactory.cpp b/pvDataApp/factory/PVDataCreateFactory.cpp index 764994d..b5abaa9 100644 --- a/pvDataApp/factory/PVDataCreateFactory.cpp +++ b/pvDataApp/factory/PVDataCreateFactory.cpp @@ -3,7 +3,8 @@ #include #include #include -#include +#include "lock.h" +#include "pvIntrospect.h" #include "pvData.h" #include "convert.h" #include "factory.h" @@ -45,7 +46,7 @@ namespace epics { namespace pvData { }; PVField *PVDataCreate::createPVField(PVStructure *parent, - StringConst fieldName,PVField * fieldToClone) + String fieldName,PVField * fieldToClone) { switch(fieldToClone->getField()->getType()) { case scalar: @@ -78,7 +79,7 @@ namespace epics { namespace pvData { }; PVScalar *PVDataCreate::createPVScalar(PVStructure *parent, - StringConst fieldName,ScalarType scalarType) + String fieldName,ScalarType scalarType) { if(fieldCreate==0) fieldCreate = getFieldCreate(); ScalarConstPtr scalar = fieldCreate->createScalar(fieldName,scalarType); @@ -86,7 +87,7 @@ namespace epics { namespace pvData { }; PVScalar *PVDataCreate::createPVScalar(PVStructure *parent, - StringConst fieldName,PVScalar * scalarToClone) + String fieldName,PVScalar * scalarToClone) { PVScalar *pvScalar = createPVScalar(parent,fieldName, scalarToClone->getScalar()->getScalarType()); @@ -114,13 +115,13 @@ namespace epics { namespace pvData { }; PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent, - StringConst fieldName,ScalarType elementType) + String fieldName,ScalarType elementType) { throw std::logic_error(notImplemented); }; PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent, - StringConst fieldName,PVScalarArray * scalarArrayToClone) + String fieldName,PVScalarArray * scalarArrayToClone) { throw std::logic_error(notImplemented); }; @@ -138,13 +139,13 @@ namespace epics { namespace pvData { }; PVStructure *PVDataCreate::createPVStructure(PVStructure *parent, - StringConst fieldName,FieldConstPtrArray fields) + String fieldName,FieldConstPtrArray fields) { throw std::logic_error(notImplemented); }; PVStructure *PVDataCreate::createPVStructure(PVStructure *parent, - StringConst fieldName,PVStructure *structToClone) + String fieldName,PVStructure *structToClone) { throw std::logic_error(notImplemented); }; diff --git a/pvDataApp/factory/StandardField.cpp b/pvDataApp/factory/StandardField.cpp new file mode 100644 index 0000000..9ea2816 --- /dev/null +++ b/pvDataApp/factory/StandardField.cpp @@ -0,0 +1,75 @@ +/* StandardField.cpp */ +#include +#include +#include +#include "convert.h" +#include "standardField.h" + +namespace epics { namespace pvData { + +static String notImplemented("not implemented"); + + StandardField::StandardField(){} + + StandardField::~StandardField(){} + + PVScalar * StandardField::scalarValue(ScalarType type) + { + throw std::logic_error(notImplemented); + } + + PVScalarArray * StandardField::scalarArrayValue(ScalarType elementType) + { + throw std::logic_error(notImplemented); + } + + PVStructure * StandardField::scalarValue(ScalarType type,String properties) + { + throw std::logic_error(notImplemented); + } + + PVStructure * StandardField::scalarArrayValue(ScalarType elementType, + String properties) + { + throw std::logic_error(notImplemented); + } + + PVStructure * StandardField::enumeratedValue(StringArray choices) + { + throw std::logic_error(notImplemented); + } + + PVStructure * StandardField::enumeratedValue(StringArray choices, + String properties) + { + throw std::logic_error(notImplemented); + } + + PVStructure * StandardField::alarm() + { + throw std::logic_error(notImplemented); + } + + PVStructure * StandardField::timeStamp() + { + throw std::logic_error(notImplemented); + } + + + static StandardField* instance = 0; + + + class StandardFieldExt : public StandardField { + public: + StandardFieldExt(): StandardField(){}; + }; + + StandardField * getStandardField() { + static Mutex *mutex = new Mutex(); + Lock xx(mutex); + + if(instance==0) instance = new StandardFieldExt(); + return instance; + } + +}} diff --git a/pvDataApp/factory/TypeFunc.cpp b/pvDataApp/factory/TypeFunc.cpp index 28fd874..c5ddcc5 100644 --- a/pvDataApp/factory/TypeFunc.cpp +++ b/pvDataApp/factory/TypeFunc.cpp @@ -3,13 +3,14 @@ #include #include #include +#include #include "pvIntrospect.h" namespace epics { namespace pvData { void TypeFunc::toString(StringBuilder buf,const Type type) { - static StringConst unknownString = "logic error unknown Type"; + static String unknownString = "logic error unknown Type"; switch(type) { case scalar : *buf += "scalar"; break; case scalarArray : *buf += "scalarArray"; break; @@ -21,24 +22,24 @@ namespace epics { namespace pvData { } - bool ScalarTypeFunc::isInteger(ScalarType type) { - if(type>=pvByte && type<=pvLong) return true; - return false; + epicsBoolean ScalarTypeFunc::isInteger(ScalarType type) { + if(type>=pvByte && type<=pvLong) return epicsTrue; + return epicsFalse; } - bool ScalarTypeFunc::isNumeric(ScalarType type) { - if(type>=pvByte && type<=pvDouble) return true; - return false; + epicsBoolean ScalarTypeFunc::isNumeric(ScalarType type) { + if(type>=pvByte && type<=pvDouble) return epicsTrue; + return epicsFalse; } - bool ScalarTypeFunc::isPrimitive(ScalarType type) { - if(type>=pvBoolean && type<=pvDouble) return true; - return false; + epicsBoolean ScalarTypeFunc::isPrimitive(ScalarType type) { + if(type>=pvBoolean && type<=pvDouble) return epicsTrue; + return epicsFalse; } - ScalarType ScalarTypeFunc::getScalarType(StringConst pvalue) { - static StringConst unknownString = "error unknown ScalarType"; - if(pvalue.compare("boolean")==0) return pvBoolean; + ScalarType ScalarTypeFunc::getScalarType(String pvalue) { + static String unknownString = "error unknown ScalarType"; + if(pvalue.compare("epicsBooleanean")==0) return pvBoolean; if(pvalue.compare("byte")==0) return pvByte; if(pvalue.compare("short")==0) return pvShort; if(pvalue.compare("int")==0) return pvInt; @@ -49,7 +50,7 @@ namespace epics { namespace pvData { throw std::invalid_argument(unknownString); } void ScalarTypeFunc::toString(StringBuilder buf,const ScalarType scalarType) { - static StringConst unknownString = "logic error unknown ScalarType"; + static String unknownString = "logic error unknown ScalarType"; switch(scalarType) { case pvBoolean : *buf += "pvBoolean"; return; case pvByte : *buf += "pvByte"; return;; diff --git a/pvDataApp/misc/bitSet.h b/pvDataApp/misc/bitSet.h index 02b6495..2d43818 100644 --- a/pvDataApp/misc/bitSet.h +++ b/pvDataApp/misc/bitSet.h @@ -5,6 +5,6 @@ namespace epics { namespace pvData { class BitSet; // must be defined and implemented - + }} #endif /* BITSET_H */ diff --git a/pvDataApp/misc/byteBuffer.h b/pvDataApp/misc/byteBuffer.h index 99a99bd..abdf8ba 100644 --- a/pvDataApp/misc/byteBuffer.h +++ b/pvDataApp/misc/byteBuffer.h @@ -8,27 +8,29 @@ namespace epics { namespace pvData { // not sure why I have to define epicsInt64 typedef long long epicsInt64; +class ByteBuffer; + class ByteBuffer { public: virtual ~ByteBuffer(); - virtual int getSize() const = 0; - virtual int getArrayOffset() const = 0; - virtual epicsBoolean getBoolean() const = 0; - virtual epicsInt8 getByte() const = 0; - virtual epicsInt16 geShort() const = 0; - virtual epicsInt32 getInt() const = 0; - virtual epicsInt64 getLong() const = 0; - virtual float getFloat() const = 0; - virtual double getDouble() const = 0; - virtual StringConst getString() const = 0; - virtual ByteBuffer * putBoolean(epicsBoolean value) const = 0; - virtual ByteBuffer * putByte(epicsInt8 value) const = 0; - virtual ByteBuffer * geShort(epicsInt16 value) const = 0; - virtual ByteBuffer * putInt(epicsInt32 value) const = 0; - virtual ByteBuffer * putLong(epicsInt64 value) const = 0; - virtual ByteBuffer * putFloat(float value) const = 0; - virtual ByteBuffer * putDouble(double value) const = 0; - virtual ByteBuffer * putString(StringConst value) const = 0; + virtual int getSize() = 0; + virtual int getArrayOffset() = 0; + virtual epicsBoolean getBoolean() = 0; + virtual epicsInt8 getByte() = 0; + virtual epicsInt16 geShort() = 0; + virtual epicsInt32 getInt() = 0; + virtual epicsInt64 getLong() = 0; + virtual float getFloat() = 0; + virtual double getDouble() = 0; + virtual String getString() = 0; + virtual ByteBuffer *putBoolean(epicsBoolean value) = 0; + virtual ByteBuffer *putByte(epicsInt8 value) = 0; + virtual ByteBuffer *geShort(epicsInt16 value) = 0; + virtual ByteBuffer *putInt(epicsInt32 value) = 0; + virtual ByteBuffer *putLong(epicsInt64 value) = 0; + virtual ByteBuffer *putFloat(float value) = 0; + virtual ByteBuffer *putDouble(double value) = 0; + virtual ByteBuffer *putString(String value) = 0; // Must define arrays }; diff --git a/pvDataApp/misc/lock.h b/pvDataApp/misc/lock.h index 2dc7162..d362d1f 100644 --- a/pvDataApp/misc/lock.h +++ b/pvDataApp/misc/lock.h @@ -19,6 +19,7 @@ namespace epics { namespace pvData { epicsMutex *lockPtr; }; + class Lock : private NoDefaultMethods { public: explicit Lock(Mutex *pm) diff --git a/pvDataApp/misc/requester.h b/pvDataApp/misc/requester.h index 9afd615..3e1700a 100644 --- a/pvDataApp/misc/requester.h +++ b/pvDataApp/misc/requester.h @@ -3,15 +3,22 @@ #ifndef REQUESTER_H #define REQUESTER_H namespace epics { namespace pvData { - - enum MessageType {infoMessage,warningMessage,errorMessage,fatalErrorMessage}; - static std::string messageTypeName[] = {"info","warning","error","fatalError"}; + class Requester; + + enum MessageType { + infoMessage,warningMessage,errorMessage,fatalErrorMessage + }; + + static std::string messageTypeName[] = { + "info","warning","error","fatalError" + }; class Requester { public: - virtual StringConst getRequesterName() const = 0; - virtual void message(StringConst message,MessageType messageType) const = 0; + virtual String getRequesterName() = 0; + virtual void message(String message,MessageType messageType) = 0; }; + }} #endif /* REQUESTER_H */ diff --git a/pvDataApp/misc/serialize.h b/pvDataApp/misc/serialize.h index 48eca82..5016e8b 100644 --- a/pvDataApp/misc/serialize.h +++ b/pvDataApp/misc/serialize.h @@ -5,10 +5,15 @@ #include "byteBuffer.h" namespace epics { namespace pvData { + class SerializableControl; + class DeserializableControl; + class Serializable; + class BitSetSerializable; + class SerializableArray; class SerializableControl { - virtual void flushSerializeBuffer() const =0; - virtual void ensureBuffer(int size) const =0; + virtual void flushSerializeBuffer() =0; + virtual void ensureBuffer(int size) =0; }; class DeserializableControl { @@ -17,25 +22,25 @@ namespace epics { namespace pvData { class Serializable { public: - virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher) const = 0; - virtual void deserialize(ByteBuffer *pbuffer, - DeserializableControl *pflusher) = 0; + virtual void serialize(ByteBuffer *buffer, + SerializableControl *flusher) = 0; + virtual void deserialize(ByteBuffer *buffer, + DeserializableControl *flusher) = 0; }; class BitSetSerializable { public: - virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher,BitSet *pbitSet) const = 0; - virtual void deserialize(ByteBuffer *pbuffer, - DeserializableControl*pflusher,BitSet *pbitSet) = 0; + virtual void serialize(ByteBuffer *buffer, + SerializableControl *flusher,BitSet *bitSet) = 0; + virtual void deserialize(ByteBuffer *buffer, + DeserializableControl *flusher,BitSet *bitSet) = 0; }; class SerializableArray : public Serializable { public: - virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher, int offset, int count) const = 0; + virtual void serialize(ByteBuffer *buffer, + SerializableControl *flusher, int offset, int count) = 0; }; }} diff --git a/pvDataApp/pv/Makefile b/pvDataApp/pv/Makefile index 389adc0..524b8fd 100644 --- a/pvDataApp/pv/Makefile +++ b/pvDataApp/pv/Makefile @@ -5,6 +5,7 @@ include $(TOP)/configure/CONFIG INC += pvIntrospect.h INC += pvData.h INC += convert.h +INC += standardField.h include $(TOP)/configure/RULES #---------------------------------------- diff --git a/pvDataApp/pv/convert.h b/pvDataApp/pv/convert.h index d70e088..6fca111 100644 --- a/pvDataApp/pv/convert.h +++ b/pvDataApp/pv/convert.h @@ -8,58 +8,58 @@ namespace epics { namespace pvData { - class Convert { + class Convert : NoDefaultMethods { public: Convert(); ~Convert(); - void getFullName(StringConst buf,PVField const *pvField); - void getString(StringBuilder buf,PVField const * pvField,int indentLevel); - void getString(StringBuilder buf,PVField const * pvField); - void fromString(PVScalar *pv, StringConst from); - int fromString(PVScalarArray *pv, StringConst from); + void getFullName(StringBuilder buf,PVField *pvField); + void getString(StringBuilder buf,PVField * pvField,int indentLevel); + void getString(StringBuilder buf,PVField *pvField); + void fromString(PVScalar *pv, String from); + int fromString(PVScalarArray *pv, String from); int fromStringArray(PVScalarArray *pv, int offset, int length, - StringConstArray from, int fromOffset); - int toStringArray(PVScalarArray const *pv, int offset, int length, - StringConstArray to, int fromOffset); + StringArray from, int fromOffset); + int toStringArray(PVScalarArray *pv, int offset, int length, + StringArray to, int toOffset); epicsBoolean isCopyCompatible(FieldConstPtr from, FieldConstPtr to); - void copy(PVField const *from,PVField *to); + void copy(PVField *from,PVField *to); epicsBoolean isCopyScalarCompatible( ScalarConstPtr from, ScalarConstPtr to); - void copyScalar(PVScalar const *from, PVScalar *to); + void copyScalar(PVScalar *from, PVScalar *to); epicsBoolean isCopyScalarArrayCompatible(ScalarArrayConstPtr from, ScalarArrayConstPtr to); - int copyScalarArray(PVScalarArray const *from, int offset, + int copyScalarArray(PVScalarArray *from, int offset, PVScalarArray *to, int toOffset, int length); epicsBoolean isCopyStructureCompatible( StructureConstPtr from, StructureConstPtr to); - void copyStructure(PVStructure const *from, PVStructure *to); + void copyStructure(PVStructure *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); + PVStructureArray *from, PVStructureArray *to); + epicsInt8 toByte(PVScalar *pv); + epicsInt16 toShort(PVScalar *pv); + epicsInt32 toInt(PVScalar *pv); + epicsInt64 toLong(PVScalar *pv); + float toFloat(PVScalar *pv); + double toDouble(PVScalar *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, + int toByteArray(PVScalarArray *pv, int offset, int length, epicsInt8 to[], int toOffset); - int toShortArray(PVScalarArray const *pv, int offset, int length, + int toShortArray(PVScalarArray *pv, int offset, int length, epicsInt16 to[], int toOffset); - int toIntArray(PVScalarArray const *pv, int offset, int length, + int toIntArray(PVScalarArray *pv, int offset, int length, epicsInt32 to[], int toOffset); - int toLongArray(PVScalarArray const *pv, int offset, int length, + int toLongArray(PVScalarArray *pv, int offset, int length, epicsInt64 to[], int toOffset); - int toFloatArray(PVScalarArray const *pv, int offset, int length, + int toFloatArray(PVScalarArray *pv, int offset, int length, float to[], int toOffset); - int toDoubleArray(PVScalarArray const *pv, int offset, int length, + int toDoubleArray(PVScalarArray *pv, int offset, int length, double to[], int toOffset); int fromByteArray(PVScalarArray *pv, int offset, int length, epicsInt8 from[], int fromOffset); @@ -74,10 +74,6 @@ namespace epics { namespace pvData { int fromDoubleArray(PVScalarArray *pv, int offset, int length, double from[], int fromOffset); void newLine(StringBuilder buf, int indentLevel); - - private: - Convert(Convert const & ); // not implemented - Convert & operator=(Convert const &); //not implemented }; extern Convert * getConvert(); diff --git a/pvDataApp/pv/pvData.h b/pvDataApp/pv/pvData.h index e5b8c9e..d216283 100644 --- a/pvDataApp/pv/pvData.h +++ b/pvDataApp/pv/pvData.h @@ -11,6 +11,9 @@ #include "serialize.h" namespace epics { namespace pvData { + class PVAuxInfo; + class PostHandler; + class PVField; class PVScalar; class PVBoolean; @@ -35,6 +38,8 @@ namespace epics { namespace pvData { class PVStructure; class PVStructureArray; + + // NOTE this prevents compiler from generating default methods for this and // derived classes class PVAuxInfo : private NoDefaultMethods { @@ -42,9 +47,9 @@ namespace epics { namespace pvData { PVAuxInfo(PVField *pvField); ~PVAuxInfo(); PVField * getPVField(); - PVScalar * createInfo(StringConst key,ScalarType scalarType); - std::map *getInfos(); - PVScalar * getInfo(StringConst key); + PVScalar * createInfo(String key,ScalarType scalarType); + std::map *getInfos(); + PVScalar * getInfo(String key); void toString(StringBuilder buf); void toString(StringBuilder buf,int indentLevel); private: @@ -59,38 +64,39 @@ namespace epics { namespace pvData { class PVField : public Requester, public Serializable ,private NoDefaultMethods{ public: virtual ~PVField(); - StringConst getRequesterName() const; - virtual void message(StringConst message,MessageType messageType) const; + String getRequesterName() ; + virtual void message(String message,MessageType messageType) ; virtual void setRequester(Requester *prequester); - int getFieldOffset() const; - int getNextFieldOffset() const; - int getNumberFields() const; + int getFieldOffset() ; + int getNextFieldOffset() ; + int getNumberFields() ; PVAuxInfo * getPVAuxInfo(); - epicsBoolean isImmutable() const; + epicsBoolean isImmutable() ; void setImmutable(); - FieldConstPtr getField() const; - PVStructure * getParent() const; + FieldConstPtr getField() ; + PVStructure * getParent() ; void replacePVField(PVField * newPVField); - void renameField(StringConst newName); - void postPut() const; + void renameField(String newName); + void postPut() ; void setPostHandler(PostHandler *postHandler); - virtual void toString(StringBuilder buf) const; - virtual void toString(StringBuilder buf,int indentLevel) const; + virtual void toString(StringBuilder buf) ; + virtual void toString(StringBuilder buf,int indentLevel) ; + virtual epicsBoolean equals(PVField *pv) = 0; protected: PVField(PVStructure *parent,FieldConstPtr field); void replaceStructure(); private: class PVFieldPvt *pImpl; - static void computeOffset(const PVField * const pvField); - static void computeOffset(const PVField * const pvField,int offset); + static void computeOffset(PVField *pvField); + static void computeOffset(PVField *pvField,int offset); }; class PVScalar : public PVField { public: virtual ~PVScalar(); - ScalarConstPtr getScalar() const; - virtual void toString(StringBuilder buf) const = 0; - virtual void toString(StringBuilder buf,int indentLevel) const = 0; + ScalarConstPtr getScalar() ; + virtual void toString(StringBuilder buf) = 0; + virtual void toString(StringBuilder buf,int indentLevel) = 0; protected: PVScalar(PVStructure *parent,ScalarConstPtr scalar); }; @@ -98,131 +104,129 @@ namespace epics { namespace pvData { class PVArray : public PVField, public SerializableArray { public: virtual ~PVArray(); - int getLength() const; + int getLength() ; void setLength(int length); - int getCapacity() const; - epicsBoolean isCapacityImmutable() const; + int getCapacity() ; + epicsBoolean isCapacityImmutable() ; void setCapacityImmutable(epicsBoolean isMutable); virtual void setCapacity(int capacity) = 0; virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher) const = 0; + SerializableControl *pflusher) = 0; virtual void deserialize(ByteBuffer *pbuffer, DeserializableControl *pflusher) = 0; virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher, int offset, int count) const = 0; - virtual void toString(StringBuilder buf) const; - virtual void toString(StringBuilder buf,int indentLevel) const = 0; + SerializableControl *pflusher, int offset, int count) = 0; + virtual void toString(StringBuilder buf) ; + virtual void toString(StringBuilder buf,int indentLevel) = 0; protected: PVArray(PVStructure *parent,FieldConstPtr field); private: - class PVArrayPvt *pImpl; + class PVArrayPvt * pImpl; }; class PVScalarArray : public PVArray { public: virtual ~PVScalarArray(); - ScalarArrayConstPtr getScalarArray() const; + ScalarArrayConstPtr getScalarArray() ; virtual void setCapacity(int capacity) = 0; virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher) const = 0; + SerializableControl *pflusher) = 0; virtual void deserialize(ByteBuffer *pbuffer, DeserializableControl *pflusher) = 0; virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher, int offset, int count) const = 0; - virtual void toString(StringBuilder buf) const = 0; - virtual void toString(StringBuilder buf,int indentLevel) const = 0; + SerializableControl *pflusher, int offset, int count) = 0; + virtual void toString(StringBuilder buf) = 0; + virtual void toString(StringBuilder buf,int indentLevel) = 0; protected: PVScalarArray(PVStructure *parent,ScalarArrayConstPtr scalarArray); private: }; typedef PVStructure * PVStructurePtr; - typedef PVStructurePtr * PVStructureArrayPtr; - + typedef PVStructurePtr* PVStructurePtrArray; class StructureArrayData { public: - PVStructureArrayPtr data; + PVStructurePtrArray data; int offset; }; class PVStructureArray : public PVArray { public: virtual ~PVStructureArray(); - virtual StructureArrayConstPtr getStructureArray() const; + virtual StructureArrayConstPtr getStructureArray() ; virtual int get(int offset, int length, - StructureArrayData *data) const; + StructureArrayData *data) ; virtual int put(int offset,int length, - PVStructureArrayPtr from, int fromOffset); - virtual void shareData(PVStructureArrayPtr from); + PVStructurePtrArray from, int fromOffset); + virtual void shareData(StructureArrayData *from); virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher) const; - virtual void deserialize(ByteBuffer *pbuffer, + SerializableControl *pflusher) ; + virtual void deserialize(ByteBuffer *buffer, DeserializableControl *pflusher); virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher, int offset, int count) const; - virtual void toString(StringBuilder buf) const; - virtual void toString(StringBuilder buf,int indentLevel) const; + SerializableControl *pflusher, int offset, int count) ; + virtual void toString(StringBuilder buf) ; + virtual void toString(StringBuilder buf,int indentLevel) ; + virtual epicsBoolean equals(PVField *pv) ; protected: PVStructureArray(PVStructure *parent, StructureArrayConstPtr structureArray); private: - PVStructureArray(); // not implemented - PVStructureArray(PVStructureArray const & ); // not implemented - PVStructureArray & operator=(PVStructureArray const &); //not implemented class PVStructureArrayPvt *pImpl; }; - typedef PVField * PVFieldPtr; - typedef PVFieldPtr * PVFieldArrayPtr; + typedef PVField* PVFieldPtr; + typedef PVFieldPtr * PVFieldPtrArray; class PVStructure : public PVField,public BitSetSerializable { public: virtual ~PVStructure(); StructureConstPtr getStructure(); - PVFieldArrayPtr getPVFields(); - PVFieldPtr getSubField(StringConst fieldName); - PVFieldPtr getSubField(int fieldOffset); - void appendPVField(PVField * pvField); - void appendPVFields(PVFieldArrayPtr pvFields); - void removePVField(StringConst fieldName); - PVBoolean *getBooleanField(StringConst fieldName); - PVByte *getByteField(StringConst fieldName); - PVShort *getShortField(StringConst fieldName); - PVInt *getIntField(StringConst fieldName); - PVLong *getLongField(StringConst fieldName); - PVFloat *getFloatField(StringConst fieldName); - PVDouble *getDoubleField(StringConst fieldName); - PVString *getStringField(StringConst fieldName); - PVStructure *getStructureField(StringConst fieldName); + PVFieldPtrArray getPVFields(); + PVField *getSubField(String fieldName); + PVField *getSubField(int fieldOffset); + void appendPVField(PVField *pvField); + void appendPVFields(PVFieldPtrArray pvFields); + void removePVField(String fieldName); + PVBoolean *getBooleanField(String fieldName); + PVByte *getByteField(String fieldName); + PVShort *getShortField(String fieldName); + PVInt *getIntField(String fieldName); + PVLong *getLongField(String fieldName); + PVFloat *getFloatField(String fieldName); + PVDouble *getDoubleField(String fieldName); + PVString *getStringField(String fieldName); + PVStructure *getStructureField(String fieldName); PVScalarArray *getScalarArrayField( - StringConst fieldName,ScalarType elementType); - PVStructureArray *getStructureArrayField(StringConst fieldName); - StringConst getExtendsStructureName(); + String fieldName,ScalarType elementType); + PVStructureArray *getStructureArrayField(String fieldName); + String getExtendsStructureName(); epicsBoolean putExtendsStructureName( - StringConst extendsStructureName); - virtual void toString(StringBuilder buf) const; - virtual void toString(StringBuilder buf,int indentLevel) const; + String extendsStructureName); + virtual void toString(StringBuilder buf) ; + virtual void toString(StringBuilder buf,int indentLevel) ; + virtual epicsBoolean equals(PVField *pv) ; virtual void serialize( - ByteBuffer *pbuffer,SerializableControl *pflusher) const; + ByteBuffer *pbuffer,SerializableControl *pflusher) ; virtual void deserialize( ByteBuffer *pbuffer,DeserializableControl *pflusher); virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher, int offset, int count) const; + SerializableControl *pflusher, int offset, int count) ; virtual void serialize(ByteBuffer *pbuffer, - SerializableControl *pflusher,BitSet *pbitSet) const; + SerializableControl *pflusher,BitSet *pbitSet) ; virtual void deserialize(ByteBuffer *pbuffer, DeserializableControl*pflusher,BitSet *pbitSet); protected: PVStructure(PVStructure *parent,StructureConstPtr structure); private: - class PVStructurePvt *pImpl; + class PVStructurePvt * pImpl; }; class PVBoolean : public PVScalar { public: virtual ~PVBoolean(); - virtual epicsBoolean get() const = 0; + virtual epicsBoolean get() = 0; virtual void put(epicsBoolean value) = 0; protected: PVBoolean(PVStructure *parent,ScalarConstPtr scalar) @@ -233,7 +237,7 @@ namespace epics { namespace pvData { class PVByte : public PVScalar { public: virtual ~PVByte(); - virtual epicsInt8 get() const = 0; + virtual epicsInt8 get() = 0; virtual void put(epicsInt8 value) = 0; protected: PVByte(PVStructure *parent,ScalarConstPtr scalar) @@ -244,7 +248,7 @@ namespace epics { namespace pvData { class PVShort : public PVScalar { public: virtual ~PVShort(); - virtual epicsInt16 get() const = 0; + virtual epicsInt16 get() = 0; virtual void put(epicsInt16 value) = 0; protected: PVShort(PVStructure *parent,ScalarConstPtr scalar) @@ -255,7 +259,7 @@ namespace epics { namespace pvData { class PVInt : public PVScalar{ public: virtual ~PVInt(); - virtual epicsInt32 get() const = 0; + virtual epicsInt32 get() = 0; virtual void put(epicsInt32 value) = 0; protected: PVInt(PVStructure *parent,ScalarConstPtr scalar) @@ -266,7 +270,7 @@ namespace epics { namespace pvData { class PVLong : public PVScalar { public: virtual ~PVLong(); - virtual epicsInt64 get() const = 0; + virtual epicsInt64 get() = 0; virtual void put(epicsInt64 value) = 0; protected: PVLong(PVStructure *parent,ScalarConstPtr scalar) @@ -277,7 +281,7 @@ namespace epics { namespace pvData { class PVFloat : public PVScalar { public: virtual ~PVFloat(); - virtual float get() const = 0; + virtual float get() = 0; virtual void put(float value) = 0; protected: PVFloat(PVStructure *parent,ScalarConstPtr scalar) @@ -288,7 +292,7 @@ namespace epics { namespace pvData { class PVDouble : public PVScalar { public: virtual ~PVDouble(); - virtual double get() const = 0; + virtual double get() = 0; virtual void put(double value) = 0; protected: PVDouble(PVStructure *parent,ScalarConstPtr scalar) @@ -299,123 +303,122 @@ namespace epics { namespace pvData { class PVString : public PVScalar { public: virtual ~PVString(); - virtual StringConst get() const = 0; - virtual void put(StringConst value) = 0; + virtual String get() = 0; + virtual void put(String value) = 0; protected: PVString(PVStructure *parent,ScalarConstPtr scalar) : PVScalar(parent,scalar) {} private: }; - typedef epicsBoolean * EpicsBooleanArrayPtr; + typedef epicsBoolean * BooleanArray; class BooleanArrayData { public: - EpicsBooleanArrayPtr data; + BooleanArray data; int offset; }; class PVBooleanArray : public PVScalarArray { public: virtual ~PVBooleanArray(); - virtual void toString(StringBuilder buf) const; - virtual void toString(StringBuilder buf,int indentLevel) const; - virtual int get(int offset, int length, BooleanArrayData *data) const; - virtual int put(int offset,int length, EpicsBooleanArrayPtr from, int fromOffset); - virtual void shareData(EpicsBooleanArrayPtr from); - virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const; + virtual void toString(StringBuilder buf) ; + virtual void toString(StringBuilder buf,int indentLevel) ; + virtual int get(int offset, int length, BooleanArrayData *data) ; + virtual int put(int offset,int length, BooleanArray from, int fromOffset); + virtual void shareData(BooleanArrayData *from); + virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ; virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); protected: PVBooleanArray(PVStructure *parent,ScalarConstPtr scalar); private: }; - typedef signed char * ByteArrayPtr; + typedef epicsInt8 * ByteArray; class ByteArrayData { public: - ByteArrayPtr data; + ByteArray data; int offset; }; class PVByteArray : public PVScalarArray { public: virtual ~PVByteArray(); - virtual void toString(StringBuilder buf) const; - virtual void toString(StringBuilder buf,int indentLevel) const; - virtual int get(int offset, int length, ByteArrayData *data) const; - virtual int put(int offset,int length, ByteArrayPtr from, int fromOffset); - virtual void shareData(ByteArrayPtr from); - virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const; + virtual void toString(StringBuilder buf) ; + virtual void toString(StringBuilder buf,int indentLevel) ; + virtual int get(int offset, int length, ByteArrayData *data) ; + virtual int put(int offset,int length, ByteArray from, int fromOffset); + virtual void shareData(ByteArrayData *from); + virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ; virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); protected: PVByteArray(PVStructure *parent,ScalarConstPtr scalar); private: }; - typedef short * ShortArrayPtr; + typedef epicsInt16 * ShortArray; class ShortArrayData { public: - ShortArrayPtr data; + ShortArray data; int offset; }; class PVShortArray : public PVScalarArray { public: virtual ~PVShortArray(); - virtual void toString(StringBuilder buf) const; - virtual void toString(StringBuilder buf,int indentLevel) const; - virtual int get(int offset, int length, ShortArrayData *data) const; - virtual int put(int offset,int length, ShortArrayPtr from, int fromOffset); - virtual void shareData(ShortArrayPtr from); - virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const; + virtual void toString(StringBuilder buf) ; + virtual void toString(StringBuilder buf,int indentLevel) ; + virtual int get(int offset, int length, ShortArrayData *data) ; + virtual int put(int offset,int length, ShortArray from, int fromOffset); + virtual void shareData(ShortArrayData *from); + virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ; virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); protected: PVShortArray(PVStructure *parent,ScalarConstPtr scalar); private: }; - typedef int * IntArrayPtr; - + typedef epicsInt32 * IntArray; class IntArrayData { public: - IntArrayPtr data; + IntArray data; int offset; }; class PVIntArray : public PVScalarArray { public: virtual ~PVIntArray(); - virtual void toString(StringBuilder buf) const; - virtual void toString(StringBuilder buf,int indentLevel) const; - virtual int get(int offset, int length, IntArrayData *data) const; - virtual int put(int offset,int length, IntArrayPtr from, int fromOffset); - virtual void shareData(IntArrayPtr from); - virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const; + virtual void toString(StringBuilder buf) ; + virtual void toString(StringBuilder buf,int indentLevel) ; + virtual int get(int offset, int length, IntArrayData *data) ; + virtual int put(int offset,int length, IntArray from, int fromOffset); + virtual void shareData(IntArrayData *from); + virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ; virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); protected: PVIntArray(PVStructure *parent,ScalarConstPtr scalar); private: }; - typedef long * LongArrayPtr; + typedef epicsInt64 * LongArray; class LongArrayData { public: - LongArrayPtr data; + LongArray data; int offset; }; class PVLongArray : public PVScalarArray { public: virtual ~PVLongArray(); - virtual void toString(StringBuilder buf) const; - virtual void toString(StringBuilder buf,int indentLevel) const; - virtual int get(int offset, int length, LongArrayData *data) const; - virtual int put(int offset,int length, LongArrayPtr from, int fromOffset); - virtual void shareData(LongArrayPtr from); - virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const; + virtual void toString(StringBuilder buf) ; + virtual void toString(StringBuilder buf,int indentLevel) ; + virtual int get(int offset, int length, LongArrayData *data) ; + virtual int put(int offset,int length, LongArray from, int fromOffset); + virtual void shareData(LongArrayData *from); + virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ; virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); protected: PVLongArray(PVStructure *parent,ScalarConstPtr scalar); @@ -423,69 +426,68 @@ namespace epics { namespace pvData { }; - typedef float * FloatArrayPtr; - + typedef float * FloatArray; class FloatArrayData { public: - FloatArrayPtr data; + FloatArray data; int offset; }; class PVFloatArray : public PVScalarArray { public: virtual ~PVFloatArray(); - virtual void toString(StringBuilder buf) const; - virtual void toString(StringBuilder buf,int indentLevel) const; - virtual int get(int offset, int length, FloatArrayData *data) const; - virtual int put(int offset,int length, FloatArrayPtr from, int fromOffset); - virtual void shareData(FloatArrayPtr from); - virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const; + virtual void toString(StringBuilder buf) ; + virtual void toString(StringBuilder buf,int indentLevel) ; + virtual int get(int offset, int length, FloatArrayData *data) ; + virtual int put(int offset,int length, FloatArray from, int fromOffset); + virtual void shareData(FloatArrayData *from); + virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ; virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); protected: PVFloatArray(PVStructure *parent,ScalarConstPtr scalar); private: }; - typedef double * DoubleArrayPtr; + typedef double * DoubleArray; class DoubleArrayData { public: - DoubleArrayPtr data; + DoubleArray data; int offset; }; class PVDoubleArray : public PVScalarArray { public: virtual ~PVDoubleArray(); - virtual void toString(StringBuilder buf) const = 0; - virtual void toString(StringBuilder buf,int indentLevel) const = 0; - virtual int get(int offset, int length, DoubleArrayData *data) const = 0; - virtual int put(int offset,int length, DoubleArrayPtr from, int fromOffset) = 0; - virtual void shareData(DoubleArrayPtr from) = 0; - virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const = 0; + virtual void toString(StringBuilder buf) = 0; + virtual void toString(StringBuilder buf,int indentLevel) = 0; + virtual int get(int offset, int length, DoubleArrayData *data) = 0; + virtual int put(int offset,int length, DoubleArray from, int fromOffset) = 0; + virtual void shareData(DoubleArrayData *from) = 0; + virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0; virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0; protected: PVDoubleArray(PVStructure *parent,ScalarArrayConstPtr scalar); private: }; - typedef std::string * StringArrayPtr; + typedef String * StringPtrArray; class StringArrayData { public: - StringArrayPtr data; + StringPtrArray data; int offset; }; class PVStringArray : public PVScalarArray { public: virtual ~PVStringArray(); - virtual void toString(StringBuilder buf) const; - virtual void toString(StringBuilder buf,int indentLevel) const; - virtual int get(int offset, int length, StringArrayData *data) const; - virtual int put(int offset,int length, StringArrayPtr from, int fromOffset); - virtual void shareData(StringArrayPtr from); - virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const; + virtual void toString(StringBuilder buf) ; + virtual void toString(StringBuilder buf,int indentLevel) ; + virtual int get(int offset, int length, StringArrayData *data) ; + virtual int put(int offset,int length, StringArray from, int fromOffset); + virtual void shareData(StringArrayData from); + virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ; virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); protected: PVStringArray(PVStructure *parent,ScalarConstPtr scalar); @@ -497,26 +499,26 @@ namespace epics { namespace pvData { PVField *createPVField(PVStructure *parent, FieldConstPtr field); PVField *createPVField(PVStructure *parent, - StringConst fieldName,PVField * fieldToClone); + String fieldName,PVField * fieldToClone); PVScalar *createPVScalar(PVStructure *parent,ScalarConstPtr scalar); PVScalar *createPVScalar(PVStructure *parent, - StringConst fieldName,ScalarType scalarType); + String fieldName,ScalarType scalarType); PVScalar *createPVScalar(PVStructure *parent, - StringConst fieldName,PVScalar * scalarToClone); + String fieldName,PVScalar * scalarToClone); PVScalarArray *createPVScalarArray(PVStructure *parent, ScalarArrayConstPtr scalarArray); PVScalarArray *createPVScalarArray(PVStructure *parent, - StringConst fieldName,ScalarType elementType); + String fieldName,ScalarType elementType); PVScalarArray *createPVScalarArray(PVStructure *parent, - StringConst fieldName,PVScalarArray * scalarArrayToClone); + String fieldName,PVScalarArray * scalarArrayToClone); PVStructureArray *createPVStructureArray(PVStructure *parent, StructureArrayConstPtr structureArray); PVStructure *createPVStructure(PVStructure *parent, StructureConstPtr structure); PVStructure *createPVStructure(PVStructure *parent, - StringConst fieldName,FieldConstPtrArray fields); + String fieldName,FieldConstPtrArray fields); PVStructure *createPVStructure(PVStructure *parent, - StringConst fieldName,PVStructure *structToClone); + String fieldName,PVStructure *structToClone); protected: PVDataCreate(); }; diff --git a/pvDataApp/pv/pvIntrospect.h b/pvDataApp/pv/pvIntrospect.h index 79a6e9e..e52f5f9 100644 --- a/pvDataApp/pv/pvIntrospect.h +++ b/pvDataApp/pv/pvIntrospect.h @@ -1,6 +1,7 @@ /* pvIntrospect.h */ #include #include +#include #ifndef PVINTROSPECT_H #define PVINTROSPECT_H #include "noDefaultMethods.h" @@ -13,8 +14,7 @@ namespace epics { namespace pvData { typedef std::string String; typedef std::string * StringBuilder; - typedef std::string const StringConst; - typedef StringConst * StringConstArray; + typedef String* StringArray; typedef Field const * FieldConstPtr; typedef FieldConstPtr * FieldConstPtrArray; @@ -48,18 +48,18 @@ namespace epics { namespace pvData { class ScalarTypeFunc { public: - static bool isInteger(ScalarType type); - static bool isNumeric(ScalarType type); - static bool isPrimitive(ScalarType type); - static ScalarType getScalarType(StringConst value); - static void toString(StringBuilder buf,const ScalarType scalarType); + static epicsBoolean isInteger(ScalarType type); + static epicsBoolean isNumeric(ScalarType type); + static epicsBoolean isPrimitive(ScalarType type); + static ScalarType getScalarType(String value); + static void toString(StringBuilder buf,ScalarType scalarType); }; class Field : private NoDefaultMethods { public: virtual ~Field(); virtual int getReferenceCount() const = 0; - virtual StringConst getFieldName() const = 0; + virtual String getFieldName() const = 0; virtual Type getType() const = 0; virtual void toString(StringBuilder buf) const = 0; virtual void toString(StringBuilder buf,int indentLevel) const = 0; @@ -89,8 +89,8 @@ namespace epics { namespace pvData { public: virtual ~Structure(); virtual int const getNumberFields() const = 0; - virtual FieldConstPtr getField(StringConst fieldName) const = 0; - virtual int getFieldIndex(StringConst fieldName) const = 0; + virtual FieldConstPtr getField(String fieldName) const = 0; + virtual int getFieldIndex(String fieldName) const = 0; virtual FieldConstPtrArray getFields() const = 0; }; @@ -103,13 +103,13 @@ namespace epics { namespace pvData { class FieldCreate { public: - FieldConstPtr create(StringConst fieldName,FieldConstPtr field) const; - ScalarConstPtr createScalar(StringConst fieldName,ScalarType scalarType) const; - ScalarArrayConstPtr createScalarArray(StringConst fieldName, + FieldConstPtr create(String fieldName,FieldConstPtr field) const; + ScalarConstPtr createScalar(String fieldName,ScalarType scalarType) const; + ScalarArrayConstPtr createScalarArray(String fieldName, ScalarType elementType) const; - StructureConstPtr createStructure (StringConst fieldName, + StructureConstPtr createStructure (String fieldName, int numberFields,FieldConstPtrArray fields) const; - StructureArrayConstPtr createStructureArray(StringConst fieldName, + StructureArrayConstPtr createStructureArray(String fieldName, StructureConstPtr structure) const; protected: FieldCreate(); diff --git a/pvDataApp/pv/standardField.h b/pvDataApp/pv/standardField.h new file mode 100644 index 0000000..65f05c0 --- /dev/null +++ b/pvDataApp/pv/standardField.h @@ -0,0 +1,30 @@ +/* standardField.h */ +#include +#include +#ifndef STANDARDFIELD_H +#define STANDARDFIELD_H +#include "pvIntrospect.h" +#include "pvData.h" + +namespace epics { namespace pvData { + + class StandardField : private NoDefaultMethods { + public: + StandardField(); + ~StandardField(); + PVScalar * scalarValue(ScalarType type); + PVScalarArray * scalarArrayValue(ScalarType elementType); + PVStructure * scalarValue(ScalarType type,String properties); + PVStructure * scalarArrayValue(ScalarType elementType, + String properties); + PVStructure * enumeratedValue(StringArray choices); + PVStructure * enumeratedValue(StringArray choices, + String properties); + PVStructure * alarm(); + PVStructure * timeStamp(); + }; + + extern StandardField * getStandardField(); + +}} +#endif /* STANDARDFIELD_H */ diff --git a/pvDataApp/test/testIntrospect.cpp b/pvDataApp/test/testIntrospect.cpp index 97e433c..d0e0cce 100644 --- a/pvDataApp/test/testIntrospect.cpp +++ b/pvDataApp/test/testIntrospect.cpp @@ -24,7 +24,7 @@ int main(int argc,char *argv[]) ScalarTypeFunc::toString(&myString,scalarType); printf("%s\n",myString.c_str()); FieldCreate * pfieldCreate = getFieldCreate(); - StringConst valueName("value"); + String valueName("value"); ScalarConstPtr pscalar = pfieldCreate->createScalar(valueName,scalarType); type = pscalar->getType(); myString.clear(); @@ -33,7 +33,7 @@ int main(int argc,char *argv[]) printf("%s\n",myString.c_str()); myString.clear(); myString += "fieldName "; - StringConst fieldName = pscalar->getFieldName(); + String fieldName = pscalar->getFieldName(); myString += fieldName; printf("%s\n",myString.c_str()); myString.clear(); @@ -45,8 +45,8 @@ int main(int argc,char *argv[]) printf("%s\n",myString.c_str()); int numberFields = 2; FieldConstPtr fields[numberFields]; - StringConst name0("high"); - StringConst name1("low"); + String name0("high"); + String name1("low"); fields[0] = pfieldCreate->createScalar(name0,pvDouble); fields[1] = pfieldCreate->createScalar(name1,pvDouble); StructureConstPtr pstructure = pfieldCreate->createStructure( diff --git a/pvDataApp/test/testPVAuxInfo.cpp b/pvDataApp/test/testPVAuxInfo.cpp index 4c08ce2..d9253bf 100644 --- a/pvDataApp/test/testPVAuxInfo.cpp +++ b/pvDataApp/test/testPVAuxInfo.cpp @@ -17,7 +17,7 @@ static String buffer(""); void testDouble() { printf("\ntestDouble\n"); - StringConst valueName("value"); + String valueName("value"); ScalarConstPtr pscalar = fieldCreate->createScalar(valueName,pvDouble); PVScalar *pvScalar = pvDataCreate->createPVScalar(0,pscalar); PVDouble *pvValue = dynamic_cast(pvScalar); @@ -28,7 +28,7 @@ void testDouble() { fprintf(stderr,"ERROR getValue put %f get %f\n",value,getValue); } PVAuxInfo *auxInfo = pvValue->getPVAuxInfo(); - StringConst stringName("string"); + String stringName("string"); pvScalar = auxInfo->createInfo(stringName,pvDouble); PVDouble *doubleInfo = dynamic_cast(pvScalar); doubleInfo->put(100.0); diff --git a/pvDataApp/test/testPVScalar.cpp b/pvDataApp/test/testPVScalar.cpp index 6869408..e422618 100644 --- a/pvDataApp/test/testPVScalar.cpp +++ b/pvDataApp/test/testPVScalar.cpp @@ -17,7 +17,7 @@ static String buffer(""); void testDouble() { printf("\ntestDouble\n"); - StringConst valueName("value"); + String valueName("value"); ScalarConstPtr pscalar = pfieldCreate->createScalar(valueName,pvDouble); PVScalar *pvScalar = pvDataCreate->createPVScalar(0,pscalar); PVDouble *pvValue = (PVDouble *)pvScalar;