From e5aac3b8e450e980909e5b900ff3ca10f8797341 Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Tue, 19 Oct 2010 14:52:07 -0400 Subject: [PATCH] Main change is epicsBoolean=>bool equuals => operator== Additional implementation in Convert.cpp --- QtC-pvData.config | 1 + QtC-pvData.creator | 1 + QtC-pvData.files | 76 +++ QtC-pvData.includes | 4 + pvDataApp/factory/AbstractPVArray.h | 6 +- pvDataApp/factory/AbstractPVField.h | 4 +- pvDataApp/factory/BasePVBoolean.h | 14 +- pvDataApp/factory/BasePVBooleanArray.h | 14 +- pvDataApp/factory/BasePVByte.h | 4 +- pvDataApp/factory/BasePVByteArray.h | 4 +- pvDataApp/factory/BasePVDouble.h | 4 +- pvDataApp/factory/BasePVDoubleArray.h | 4 +- pvDataApp/factory/BasePVFloat.h | 4 +- pvDataApp/factory/BasePVFloatArray.h | 4 +- pvDataApp/factory/BasePVInt.h | 4 +- pvDataApp/factory/BasePVIntArray.h | 4 +- pvDataApp/factory/BasePVLong.h | 4 +- pvDataApp/factory/BasePVLongArray.h | 4 +- pvDataApp/factory/BasePVShort.h | 4 +- pvDataApp/factory/BasePVShortArray.h | 4 +- pvDataApp/factory/BasePVString.h | 4 +- pvDataApp/factory/BasePVStringArray.h | 4 +- pvDataApp/factory/BasePVStructure.h | 4 +- pvDataApp/factory/BasePVStructureArray.h | 2 +- pvDataApp/factory/Convert.cpp | 569 ++++++++++++++++++++--- pvDataApp/factory/TypeFunc.cpp | 8 +- pvDataApp/misc/byteBuffer.h | 4 +- pvDataApp/pv/convert.h | 16 +- pvDataApp/pv/pvData.h | 24 +- pvDataApp/pv/pvIntrospect.h | 6 +- pvDataApp/test/testPVScalar.cpp | 36 +- pvDataApp/test/testPVScalarArray.cpp | 4 +- 32 files changed, 689 insertions(+), 160 deletions(-) create mode 100644 QtC-pvData.config create mode 100644 QtC-pvData.creator create mode 100644 QtC-pvData.files create mode 100644 QtC-pvData.includes diff --git a/QtC-pvData.config b/QtC-pvData.config new file mode 100644 index 0000000..8cec188 --- /dev/null +++ b/QtC-pvData.config @@ -0,0 +1 @@ +// ADD PREDEFINED MACROS HERE! diff --git a/QtC-pvData.creator b/QtC-pvData.creator new file mode 100644 index 0000000..e94cbbd --- /dev/null +++ b/QtC-pvData.creator @@ -0,0 +1 @@ +[General] diff --git a/QtC-pvData.files b/QtC-pvData.files new file mode 100644 index 0000000..537a550 --- /dev/null +++ b/QtC-pvData.files @@ -0,0 +1,76 @@ +include/AbstractPVArray.h +include/AbstractPVField.h +include/AbstractPVScalar.h +include/AbstractPVScalarArray.h +include/BasePVBoolean.h +include/BasePVBooleanArray.h +include/BasePVByte.h +include/BasePVByteArray.h +include/BasePVDouble.h +include/BasePVDoubleArray.h +include/BasePVFloat.h +include/BasePVFloatArray.h +include/BasePVInt.h +include/BasePVIntArray.h +include/BasePVLong.h +include/BasePVLongArray.h +include/BasePVShort.h +include/BasePVShortArray.h +include/BasePVString.h +include/BasePVStructure.h +include/BasePVStructureArray.h +include/bitSet.h +include/byteBuffer.h +include/convert.h +include/factory.h +include/lock.h +include/noDefaultMethods.h +include/pvData.h +include/pvIntrospect.h +include/requester.h +include/serialize.h +include/standardField.h +pvDataApp/factory/AbstractPVArray.h +pvDataApp/factory/AbstractPVField.h +pvDataApp/factory/AbstractPVScalar.h +pvDataApp/factory/AbstractPVScalarArray.h +pvDataApp/factory/BasePVBoolean.h +pvDataApp/factory/BasePVBooleanArray.h +pvDataApp/factory/BasePVByte.h +pvDataApp/factory/BasePVByteArray.h +pvDataApp/factory/BasePVDouble.h +pvDataApp/factory/BasePVDoubleArray.h +pvDataApp/factory/BasePVFloat.h +pvDataApp/factory/BasePVFloatArray.h +pvDataApp/factory/BasePVInt.h +pvDataApp/factory/BasePVIntArray.h +pvDataApp/factory/BasePVLong.h +pvDataApp/factory/BasePVLongArray.h +pvDataApp/factory/BasePVShort.h +pvDataApp/factory/BasePVShortArray.h +pvDataApp/factory/BasePVString.h +pvDataApp/factory/BasePVStringArray.h +pvDataApp/factory/BasePVStructure.h +pvDataApp/factory/BasePVStructureArray.h +pvDataApp/factory/Convert.cpp +pvDataApp/factory/factory.h +pvDataApp/factory/FieldCreateFactory.cpp +pvDataApp/factory/PVAuxInfoImpl.cpp +pvDataApp/factory/PVDataCreateFactory.cpp +pvDataApp/factory/StandardField.cpp +pvDataApp/factory/TypeFunc.cpp +pvDataApp/misc/bitSet.h +pvDataApp/misc/byteBuffer.h +pvDataApp/misc/lock.h +pvDataApp/misc/noDefaultMethods.h +pvDataApp/misc/requester.h +pvDataApp/misc/serialize.h +pvDataApp/pv/convert.h +pvDataApp/pv/pvData.h +pvDataApp/pv/pvIntrospect.h +pvDataApp/pv/standardField.h +pvDataApp/test/testIntrospect.cpp +pvDataApp/test/testPVAuxInfo.cpp +pvDataApp/test/testPVScalar.cpp +pvDataApp/test/testPVScalarArray.cpp +pvDataApp/test/testSimpleStructure.cpp \ No newline at end of file diff --git a/QtC-pvData.includes b/QtC-pvData.includes new file mode 100644 index 0000000..a4c58da --- /dev/null +++ b/QtC-pvData.includes @@ -0,0 +1,4 @@ +include +pvDataApp/factory +pvDataApp/misc +pvDataApp/pv \ No newline at end of file diff --git a/pvDataApp/factory/AbstractPVArray.h b/pvDataApp/factory/AbstractPVArray.h index 2bbd096..b669fe5 100644 --- a/pvDataApp/factory/AbstractPVArray.h +++ b/pvDataApp/factory/AbstractPVArray.h @@ -16,7 +16,7 @@ namespace epics { namespace pvData { {} int length; int capacity; - epicsBoolean capacityMutable; + bool capacityMutable; }; PVArray::PVArray(PVStructure *parent,FieldConstPtr field) @@ -51,7 +51,7 @@ namespace epics { namespace pvData { } - epicsBoolean PVArray::isCapacityMutable() + bool PVArray::isCapacityMutable() { if(PVField::isImmutable()) { return epicsFalse; @@ -59,7 +59,7 @@ namespace epics { namespace pvData { return pImpl->capacityMutable; } - void PVArray::setCapacityMutable(epicsBoolean isMutable) + void PVArray::setCapacityMutable(bool isMutable) { if(isMutable && PVField::isImmutable()) { PVField::message(fieldImmutable,errorMessage); diff --git a/pvDataApp/factory/AbstractPVField.h b/pvDataApp/factory/AbstractPVField.h index 24c9cbf..a04ff81 100644 --- a/pvDataApp/factory/AbstractPVField.h +++ b/pvDataApp/factory/AbstractPVField.h @@ -22,7 +22,7 @@ static String notImplemented("not implemented"); int fieldOffset; int nextFieldOffset; PVAuxInfo *pvAuxInfo; - epicsBoolean immutable; + bool immutable; Requester *requester; PostHandler *postHandler; }; @@ -106,7 +106,7 @@ static String notImplemented("not implemented"); return pImpl->pvAuxInfo; } - epicsBoolean PVField::isImmutable() {return pImpl->immutable;} + bool PVField::isImmutable() {return pImpl->immutable;} void PVField::setImmutable() {pImpl->immutable = epicsTrue;} diff --git a/pvDataApp/factory/BasePVBoolean.h b/pvDataApp/factory/BasePVBoolean.h index 1910780..f0fd590 100644 --- a/pvDataApp/factory/BasePVBoolean.h +++ b/pvDataApp/factory/BasePVBoolean.h @@ -18,17 +18,17 @@ namespace epics { namespace pvData { public: BasePVBoolean(PVStructure *parent,ScalarConstPtr scalar); virtual ~BasePVBoolean(); - virtual epicsBoolean get(); - virtual void put(epicsBoolean val); + virtual bool get(); + virtual void put(bool val); virtual void serialize(ByteBuffer *pbuffer, SerializableControl *pflusher) ; virtual void deserialize(ByteBuffer *pbuffer, DeserializableControl *pflusher); virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: - epicsBoolean value; + bool value; }; BasePVBoolean::BasePVBoolean(PVStructure *parent,ScalarConstPtr scalar) @@ -37,9 +37,9 @@ namespace epics { namespace pvData { BasePVBoolean::~BasePVBoolean() {} - epicsBoolean BasePVBoolean::get() { return value;} + bool BasePVBoolean::get() { return value;} - void BasePVBoolean::put(epicsBoolean val){value = val;} + void BasePVBoolean::put(bool val){value = val;} void BasePVBoolean::serialize(ByteBuffer *pbuffer, SerializableControl *pflusher) @@ -61,7 +61,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVBoolean::equals(PVField *pvField) + bool BasePVBoolean::operator==(PVField *pvField) { return getConvert()->equals(this,pvField); } diff --git a/pvDataApp/factory/BasePVBooleanArray.h b/pvDataApp/factory/BasePVBooleanArray.h index ba36fa3..5f7a5a6 100644 --- a/pvDataApp/factory/BasePVBooleanArray.h +++ b/pvDataApp/factory/BasePVBooleanArray.h @@ -25,7 +25,7 @@ namespace epics { namespace pvData { virtual int get(int offset, int length, BooleanArrayData *data) ; virtual int put(int offset,int length,BooleanArray from, int fromOffset); - virtual void shareData(epicsBoolean value[],int capacity,int length); + virtual void shareData(bool value[],int capacity,int length); // from Serializable virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) ; virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); @@ -33,14 +33,14 @@ namespace epics { namespace pvData { SerializableControl *pflusher, int offset, int count) ; virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: - epicsBoolean *value; + bool *value; }; BasePVBooleanArray::BasePVBooleanArray(PVStructure *parent, ScalarArrayConstPtr scalarArray) - : PVBooleanArray(parent,scalarArray),value(new epicsBoolean[0]) + : PVBooleanArray(parent,scalarArray),value(new bool[0]) { } BasePVBooleanArray::~BasePVBooleanArray() @@ -58,7 +58,7 @@ namespace epics { namespace pvData { } int length = PVArray::getLength(); if(length>capacity) length = capacity; - epicsBoolean *newValue = new epicsBoolean[capacity]; + bool *newValue = new bool[capacity]; for(int i=0; iequals(this,pv); } diff --git a/pvDataApp/factory/BasePVByte.h b/pvDataApp/factory/BasePVByte.h index 8babfbf..0f37456 100644 --- a/pvDataApp/factory/BasePVByte.h +++ b/pvDataApp/factory/BasePVByte.h @@ -26,7 +26,7 @@ namespace epics { namespace pvData { DeserializableControl *pflusher); virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: epicsInt8 value; }; @@ -61,7 +61,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVByte::equals(PVField *pvField) + bool BasePVByte::operator==(PVField *pvField) { return getConvert()->equals(this,pvField); } diff --git a/pvDataApp/factory/BasePVByteArray.h b/pvDataApp/factory/BasePVByteArray.h index 8302cbe..e1939af 100644 --- a/pvDataApp/factory/BasePVByteArray.h +++ b/pvDataApp/factory/BasePVByteArray.h @@ -33,7 +33,7 @@ namespace epics { namespace pvData { SerializableControl *pflusher, int offset, int count) ; virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: epicsInt8 *value; }; @@ -145,7 +145,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVByteArray::equals(PVField *pv) + bool BasePVByteArray::operator==(PVField *pv) { return getConvert()->equals(this,pv); } diff --git a/pvDataApp/factory/BasePVDouble.h b/pvDataApp/factory/BasePVDouble.h index 8f0effd..f8499b5 100644 --- a/pvDataApp/factory/BasePVDouble.h +++ b/pvDataApp/factory/BasePVDouble.h @@ -26,7 +26,7 @@ namespace epics { namespace pvData { DeserializableControl *pflusher); virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: double value; }; @@ -61,7 +61,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVDouble::equals(PVField *pvField) + bool BasePVDouble::operator==(PVField *pvField) { return getConvert()->equals(this,pvField); } diff --git a/pvDataApp/factory/BasePVDoubleArray.h b/pvDataApp/factory/BasePVDoubleArray.h index 1882e04..a1ed474 100644 --- a/pvDataApp/factory/BasePVDoubleArray.h +++ b/pvDataApp/factory/BasePVDoubleArray.h @@ -33,7 +33,7 @@ namespace epics { namespace pvData { SerializableControl *pflusher, int offset, int count) ; virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: double *value; }; @@ -145,7 +145,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVDoubleArray::equals(PVField *pv) + bool BasePVDoubleArray::operator==(PVField *pv) { return getConvert()->equals(this,pv); } diff --git a/pvDataApp/factory/BasePVFloat.h b/pvDataApp/factory/BasePVFloat.h index b748969..3d56963 100644 --- a/pvDataApp/factory/BasePVFloat.h +++ b/pvDataApp/factory/BasePVFloat.h @@ -26,7 +26,7 @@ namespace epics { namespace pvData { DeserializableControl *pflusher); virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: float value; }; @@ -61,7 +61,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVFloat::equals(PVField *pvField) + bool BasePVFloat::operator==(PVField *pvField) { return getConvert()->equals(this,pvField); } diff --git a/pvDataApp/factory/BasePVFloatArray.h b/pvDataApp/factory/BasePVFloatArray.h index 0b8b9b6..438d77b 100644 --- a/pvDataApp/factory/BasePVFloatArray.h +++ b/pvDataApp/factory/BasePVFloatArray.h @@ -33,7 +33,7 @@ namespace epics { namespace pvData { SerializableControl *pflusher, int offset, int count) ; virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: float *value; }; @@ -145,7 +145,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVFloatArray::equals(PVField *pv) + bool BasePVFloatArray::operator==(PVField *pv) { return getConvert()->equals(this,pv); } diff --git a/pvDataApp/factory/BasePVInt.h b/pvDataApp/factory/BasePVInt.h index 63d17d9..526e2d6 100644 --- a/pvDataApp/factory/BasePVInt.h +++ b/pvDataApp/factory/BasePVInt.h @@ -26,7 +26,7 @@ namespace epics { namespace pvData { DeserializableControl *pflusher); virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: epicsInt32 value; }; @@ -61,7 +61,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVInt::equals(PVField *pvField) + bool BasePVInt::operator==(PVField *pvField) { return getConvert()->equals(this,pvField); } diff --git a/pvDataApp/factory/BasePVIntArray.h b/pvDataApp/factory/BasePVIntArray.h index 44fc10e..4a066d0 100644 --- a/pvDataApp/factory/BasePVIntArray.h +++ b/pvDataApp/factory/BasePVIntArray.h @@ -33,7 +33,7 @@ namespace epics { namespace pvData { SerializableControl *pflusher, int offset, int count) ; virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: epicsInt32 *value; }; @@ -145,7 +145,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVIntArray::equals(PVField *pv) + bool BasePVIntArray::operator==(PVField *pv) { return getConvert()->equals(this,pv); } diff --git a/pvDataApp/factory/BasePVLong.h b/pvDataApp/factory/BasePVLong.h index dd1d17a..bf3fa7b 100644 --- a/pvDataApp/factory/BasePVLong.h +++ b/pvDataApp/factory/BasePVLong.h @@ -26,7 +26,7 @@ namespace epics { namespace pvData { DeserializableControl *pflusher); virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: epicsInt64 value; }; @@ -61,7 +61,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVLong::equals(PVField *pvField) + bool BasePVLong::operator==(PVField *pvField) { return getConvert()->equals(this,pvField); } diff --git a/pvDataApp/factory/BasePVLongArray.h b/pvDataApp/factory/BasePVLongArray.h index 4864210..d4021f6 100644 --- a/pvDataApp/factory/BasePVLongArray.h +++ b/pvDataApp/factory/BasePVLongArray.h @@ -33,7 +33,7 @@ namespace epics { namespace pvData { SerializableControl *pflusher, int offset, int count) ; virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: epicsInt64 *value; }; @@ -145,7 +145,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVLongArray::equals(PVField *pv) + bool BasePVLongArray::operator==(PVField *pv) { return getConvert()->equals(this,pv); } diff --git a/pvDataApp/factory/BasePVShort.h b/pvDataApp/factory/BasePVShort.h index f6d7a2a..4aecbe4 100644 --- a/pvDataApp/factory/BasePVShort.h +++ b/pvDataApp/factory/BasePVShort.h @@ -26,7 +26,7 @@ namespace epics { namespace pvData { DeserializableControl *pflusher); virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: epicsInt16 value; }; @@ -61,7 +61,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVShort::equals(PVField *pvField) + bool BasePVShort::operator==(PVField *pvField) { return getConvert()->equals(this,pvField); } diff --git a/pvDataApp/factory/BasePVShortArray.h b/pvDataApp/factory/BasePVShortArray.h index 46aa268..b7bcbe1 100644 --- a/pvDataApp/factory/BasePVShortArray.h +++ b/pvDataApp/factory/BasePVShortArray.h @@ -33,7 +33,7 @@ namespace epics { namespace pvData { SerializableControl *pflusher, int offset, int count) ; virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: epicsInt16 *value; }; @@ -145,7 +145,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVShortArray::equals(PVField *pv) + bool BasePVShortArray::operator==(PVField *pv) { return getConvert()->equals(this,pv); } diff --git a/pvDataApp/factory/BasePVString.h b/pvDataApp/factory/BasePVString.h index a480a1e..22a0cca 100644 --- a/pvDataApp/factory/BasePVString.h +++ b/pvDataApp/factory/BasePVString.h @@ -26,7 +26,7 @@ namespace epics { namespace pvData { DeserializableControl *pflusher); virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: String value; }; @@ -61,7 +61,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVString::equals(PVField *pvField) + bool BasePVString::operator==(PVField *pvField) { return getConvert()->equals(this,pvField); } diff --git a/pvDataApp/factory/BasePVStringArray.h b/pvDataApp/factory/BasePVStringArray.h index 8c9daf5..9527b5f 100644 --- a/pvDataApp/factory/BasePVStringArray.h +++ b/pvDataApp/factory/BasePVStringArray.h @@ -33,7 +33,7 @@ namespace epics { namespace pvData { SerializableControl *pflusher, int offset, int count) ; virtual void toString(StringBuilder buf); virtual void toString(StringBuilder buf,int indentLevel); - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; private: String *value; }; @@ -145,7 +145,7 @@ namespace epics { namespace pvData { PVField::toString(buf,indentLevel); } - epicsBoolean BasePVStringArray::equals(PVField *pv) + bool BasePVStringArray::operator==(PVField *pv) { return getConvert()->equals(this,pv); } diff --git a/pvDataApp/factory/BasePVStructure.h b/pvDataApp/factory/BasePVStructure.h index faec1ef..0780c95 100644 --- a/pvDataApp/factory/BasePVStructure.h +++ b/pvDataApp/factory/BasePVStructure.h @@ -145,7 +145,7 @@ namespace epics { namespace pvData { throw std::logic_error(notImplemented); } - epicsBoolean PVStructure::putExtendsStructureName( + bool PVStructure::putExtendsStructureName( String extendsStructureName) { throw std::logic_error(notImplemented); @@ -188,7 +188,7 @@ namespace epics { namespace pvData { throw std::logic_error(notImplemented); } - epicsBoolean PVStructure::equals(PVField *pv) + bool PVStructure::operator==(PVField *pv) { throw std::logic_error(notImplemented); } diff --git a/pvDataApp/factory/BasePVStructureArray.h b/pvDataApp/factory/BasePVStructureArray.h index 763b6de..1c09875 100644 --- a/pvDataApp/factory/BasePVStructureArray.h +++ b/pvDataApp/factory/BasePVStructureArray.h @@ -93,7 +93,7 @@ namespace epics { namespace pvData { throw std::logic_error(notImplemented); } - epicsBoolean PVStructureArray::equals(PVField *pv) + bool PVStructureArray::operator==(PVField *pv) { throw std::logic_error(notImplemented); } diff --git a/pvDataApp/factory/Convert.cpp b/pvDataApp/factory/Convert.cpp index 22a9ca6..23bb6ae 100644 --- a/pvDataApp/factory/Convert.cpp +++ b/pvDataApp/factory/Convert.cpp @@ -13,9 +13,11 @@ namespace epics { namespace pvData { static Convert* convert = 0; +static String logicError("Logic error. Should never get here."); static String notImplemented("not implemented"); +static String illegalScalarType("Illegal ScalarType"); -static epicsBoolean convertEquals(PVField *a,PVField *b); +static bool convertEquals(PVField *a,PVField *b); static int convertFromByteArray(PVScalarArray *pv, int offset, int len,epicsInt8 from[], int fromOffset); static int convertToByteArray(PVScalarArray *pv, int offset, @@ -98,7 +100,7 @@ void Convert::getFullName(StringBuilder buf,PVField * pvField) } } -epicsBoolean Convert::equals(PVField *a,PVField *b) +bool Convert::equals(PVField *a,PVField *b) { return convertEquals(a,b); } @@ -120,7 +122,7 @@ void Convert::fromString(PVScalar *pvScalar, String from) switch(scalarType) { case pvBoolean: { PVBoolean *pv = (PVBoolean *)pvScalar; - epicsBoolean value = + bool value = ((from.compare("true")==0) ? epicsTrue : epicsFalse); pv->put(value); break; @@ -176,11 +178,10 @@ void Convert::fromString(PVScalar *pvScalar, String from) value->put(from); break; } - default: - String message("Convert::fromString unknown scalarType "); - ScalarTypeFunc::toString(&message,scalarType); - throw std::logic_error(message); } + String message("Convert::fromString unknown scalarType "); + ScalarTypeFunc::toString(&message,scalarType); + throw std::logic_error(message); } int Convert::fromString(PVScalarArray *pv, String from) @@ -204,18 +205,18 @@ int Convert::fromString(PVScalarArray *pv, String from) } int Convert::fromStringArray(PVScalarArray *pv, int offset, int length, - StringArray from, int fromOffset) + String from[], int fromOffset) { return convertFromStringArray(pv,offset,length,from,fromOffset); } int Convert::toStringArray(PVScalarArray * pv, int offset, int length, - StringArray to, int toOffset) + String to[], int toOffset) { return convertToStringArray(pv,offset,length,to,toOffset); } -epicsBoolean Convert::isCopyCompatible(FieldConstPtr from, FieldConstPtr to) +bool Convert::isCopyCompatible(FieldConstPtr from, FieldConstPtr to) { if(from->getType()!=to->getType()) return epicsFalse; switch(from->getType()) { @@ -257,7 +258,7 @@ void Convert::copy(PVField *from,PVField *to) } } -epicsBoolean Convert::isCopyScalarCompatible( +bool Convert::isCopyScalarCompatible( ScalarConstPtr fromField, ScalarConstPtr toField) { ScalarType fromScalarType = fromField->getScalarType(); @@ -273,7 +274,7 @@ epicsBoolean Convert::isCopyScalarCompatible( void Convert::copyScalar(PVScalar *from, PVScalar *to) { if(to->isImmutable()) { - if(from->equals(to)) return; + if(from==to) return; String message("Convert.copyScalar destination is immutable"); throw std::invalid_argument(message); } @@ -294,7 +295,7 @@ void Convert::copyScalar(PVScalar *from, PVScalar *to) data->toString(&buf); dataTo->put(buf); } else { - epicsBoolean value = data->get(); + bool value = data->get(); PVBoolean *dataTo = (PVBoolean*)to; dataTo->put(value); } @@ -342,13 +343,12 @@ void Convert::copyScalar(PVScalar *from, PVScalar *to) convert->fromString(to,value); break; } - default: - String message("Convert.copyScalar arguments are not compatible"); - throw std::invalid_argument(message); } + String message("Convert::copyScalar should never get here"); + throw std::logic_error(message); } -epicsBoolean Convert::isCopyScalarArrayCompatible(ScalarArrayConstPtr fromArray, +bool Convert::isCopyScalarArrayCompatible(ScalarArrayConstPtr fromArray, ScalarArrayConstPtr toArray) { ScalarType fromType = fromArray->getElementType(); @@ -365,7 +365,7 @@ int Convert::copyScalarArray(PVScalarArray *from, int offset, PVScalarArray *to, int toOffset, int length) { if(to->isImmutable()) { - if(from->equals(to)) return from->getLength(); + if(from==to) return from->getLength(); String message("Convert.copyArray destination is immutable"); throw std::invalid_argument(message); } @@ -387,7 +387,7 @@ int Convert::copyScalarArray(PVScalarArray *from, int offset, PVBooleanArray *pvto = (PVBooleanArray*)to; while(length>0) { int num = 0; - epicsBoolean *data = 0; + bool *data = 0; int fromOffset = 0; BooleanArrayData booleanArrayData = BooleanArrayData(); num = pvfrom->get(offset,length,&booleanArrayData); @@ -452,7 +452,7 @@ int Convert::copyScalarArray(PVScalarArray *from, int offset, throw std::logic_error(message); } -epicsBoolean Convert::isCopyStructureCompatible( +bool Convert::isCopyStructureCompatible( StructureConstPtr fromStruct, StructureConstPtr toStruct) { FieldConstPtrArray fromFields = fromStruct->getFields(); @@ -488,7 +488,7 @@ epicsBoolean Convert::isCopyStructureCompatible( void Convert::copyStructure(PVStructure *from, PVStructure *to) { if(to->isImmutable()) { - if(from->equals(to)) return; + if(from==to) return; String message("Convert.copyStructure destination is immutable"); throw std::invalid_argument(message); } @@ -556,7 +556,7 @@ void Convert::copyStructure(PVStructure *from, PVStructure *to) } } -epicsBoolean Convert::isCopyStructureArrayCompatible( +bool Convert::isCopyStructureArrayCompatible( StructureArrayConstPtr from, StructureArrayConstPtr to) { return isCopyStructureCompatible(from->getStructure(),to->getStructure()); @@ -566,7 +566,7 @@ void Convert::copyStructureArray( PVStructureArray *from, PVStructureArray *to) { if(to->isImmutable()) { - if(from->equals(to)) return; + if(from==to) return; String message("Convert.copyStructureArray destination is immutable"); throw std::invalid_argument(message); } @@ -602,134 +602,560 @@ void Convert::copyStructureArray( epicsInt8 Convert::toByte(PVScalar * pv) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("boolean can not be converted to byte")); + case pvByte: { + PVByte *value = (PVByte *)pv; + return value->get(); + } + case pvShort: { + PVShort *value = (PVShort *)pv; + return value->get(); + } + case pvInt: { + PVInt *value = (PVInt *)pv; + return value->get(); + } + case pvLong: { + PVLong *value = (PVLong *)pv; + return value->get(); + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + return value->get(); + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + return value->get(); + } + case pvString: + throw std::logic_error(String("string can not be converted to byte")); + } + throw std::logic_error(logicError); } epicsInt16 Convert::toShort(PVScalar * pv) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("boolean can not be converted to short")); + case pvByte: { + PVByte *value = (PVByte *)pv; + return value->get(); + } + case pvShort: { + PVShort *value = (PVShort *)pv; + return value->get(); + } + case pvInt: { + PVInt *value = (PVInt *)pv; + return value->get(); + } + case pvLong: { + PVLong *value = (PVLong *)pv; + return value->get(); + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + return value->get(); + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + return value->get(); + } + case pvString: + throw std::logic_error(String("string can not be converted to short")); + } + throw std::logic_error(logicError); } epicsInt32 Convert::toInt(PVScalar * pv) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("boolean can not be converted to int")); + case pvByte: { + PVByte *value = (PVByte *)pv; + return value->get(); + } + case pvShort: { + PVShort *value = (PVShort *)pv; + return value->get(); + } + case pvInt: { + PVInt *value = (PVInt *)pv; + return value->get(); + } + case pvLong: { + PVLong *value = (PVLong *)pv; + return value->get(); + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + return value->get(); + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + return value->get(); + } + case pvString: + throw std::logic_error(String("string can not be converted to int")); + } + throw std::logic_error(logicError); } epicsInt64 Convert::toLong(PVScalar * pv) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("boolean can not be converted to long")); + case pvByte: { + PVByte *value = (PVByte *)pv; + return value->get(); + } + case pvShort: { + PVShort *value = (PVShort *)pv; + return value->get(); + } + case pvInt: { + PVInt *value = (PVInt *)pv; + return value->get(); + } + case pvLong: { + PVLong *value = (PVLong *)pv; + return value->get(); + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + return value->get(); + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + return value->get(); + } + case pvString: + throw std::logic_error(String("string can not be converted to long")); + } + throw std::logic_error(logicError); } float Convert::toFloat(PVScalar * pv) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("boolean can not be converted to float")); + case pvByte: { + PVByte *value = (PVByte *)pv; + return value->get(); + } + case pvShort: { + PVShort *value = (PVShort *)pv; + return value->get(); + } + case pvInt: { + PVInt *value = (PVInt *)pv; + return value->get(); + } + case pvLong: { + PVLong *value = (PVLong *)pv; + return value->get(); + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + return value->get(); + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + return value->get(); + } + case pvString: + throw std::logic_error(String("string can not be converted to float")); + } + throw std::logic_error(logicError); } double Convert::toDouble(PVScalar * pv) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("boolean can not be converted to double")); + case pvByte: { + PVByte *value = (PVByte *)pv; + return value->get(); + } + case pvShort: { + PVShort *value = (PVShort *)pv; + return value->get(); + } + case pvInt: { + PVInt *value = (PVInt *)pv; + return value->get(); + } + case pvLong: { + PVLong *value = (PVLong *)pv; + return value->get(); + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + return value->get(); + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + return value->get(); + } + case pvString: + throw std::logic_error(String("string can not be converted to double")); + } + throw std::logic_error(logicError); } void Convert::fromByte(PVScalar *pv,epicsInt8 from) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("byte can not be converted to boolean")); + case pvByte: { + PVByte *value = (PVByte *)pv; + value->put(from); return; + } + case pvShort: { + PVShort *value = (PVShort *)pv; + value->put(from); return; + } + case pvInt: { + PVInt *value = (PVInt *)pv; + value->put(from); return; + } + case pvLong: { + PVLong *value = (PVLong *)pv; + value->put(from); return; + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + value->put(from); return; + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + value->put(from); return; + } + case pvString: { + PVString *value = (PVString *)pv; + char buffer[20]; + int ival = from; + sprintf(buffer,"%d",ival); + String xxx(buffer); + value->put(xxx); + return; + } + } + throw std::logic_error(logicError); } void Convert::fromShort(PVScalar *pv,epicsInt16 from) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("short can not be converted to boolean")); + case pvByte: { + PVByte *value = (PVByte *)pv; + value->put(from); return; + } + case pvShort: { + PVShort *value = (PVShort *)pv; + value->put(from); return; + } + case pvInt: { + PVInt *value = (PVInt *)pv; + value->put(from); return; + } + case pvLong: { + PVLong *value = (PVLong *)pv; + value->put(from); return; + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + value->put(from); return; + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + value->put(from); return; + } + case pvString: { + PVString *value = (PVString *)pv; + char buffer[20]; + int ival = from; + sprintf(buffer,"%d",ival); + String xxx(buffer); + value->put(xxx); + return; + } + } + throw std::logic_error(logicError); } void Convert::fromInt(PVScalar *pv, epicsInt32 from) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("int can not be converted to boolean")); + case pvByte: { + PVByte *value = (PVByte *)pv; + value->put(from); return; + } + case pvShort: { + PVShort *value = (PVShort *)pv; + value->put(from); return; + } + case pvInt: { + PVInt *value = (PVInt *)pv; + value->put(from); return; + } + case pvLong: { + PVLong *value = (PVLong *)pv; + value->put(from); return; + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + value->put(from); return; + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + value->put(from); return; + } + case pvString: { + PVString *value = (PVString *)pv; + char buffer[20]; + int ival = from; + sprintf(buffer,"%d",ival); + String xxx(buffer); + value->put(xxx); + return; + } + } + throw std::logic_error(logicError); } void Convert::fromLong(PVScalar *pv, epicsInt64 from) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("long can not be converted to boolean")); + case pvByte: { + PVByte *value = (PVByte *)pv; + value->put(from); return; + } + case pvShort: { + PVShort *value = (PVShort *)pv; + value->put(from); return; + } + case pvInt: { + PVInt *value = (PVInt *)pv; + value->put(from); return; + } + case pvLong: { + PVLong *value = (PVLong *)pv; + value->put(from); return; + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + value->put(from); return; + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + value->put(from); return; + } + case pvString: { + PVString *value = (PVString *)pv; + char buffer[20]; + long int ival = from; + sprintf(buffer,"%ld",ival); + String xxx(buffer); + value->put(xxx); + return; + } + } + throw std::logic_error(logicError); } void Convert::fromFloat(PVScalar* pv, float from) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("float can not be converted to boolean")); + case pvByte: { + PVByte *value = (PVByte *)pv; + value->put(from); return; + } + case pvShort: { + PVShort *value = (PVShort *)pv; + value->put(from); return; + } + case pvInt: { + PVInt *value = (PVInt *)pv; + value->put(from); return; + } + case pvLong: { + PVLong *value = (PVLong *)pv; + value->put(from); return; + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + value->put(from); return; + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + value->put(from); return; + } + case pvString: { + PVString *value = (PVString *)pv; + char buffer[20]; + double dval = from; + sprintf(buffer,"%e",dval); + String xxx(buffer); + value->put(xxx); + return; + } + } + throw std::logic_error(logicError); } void Convert::fromDouble(PVScalar *pv, double from) { - throw std::logic_error(notImplemented); + ScalarConstPtr scalar = pv->getScalar(); + ScalarType scalarType = scalar->getScalarType(); + switch(scalarType) { + case pvBoolean: + throw std::logic_error(String("double can not be converted to boolean")); + case pvByte: { + PVByte *value = (PVByte *)pv; + value->put(from); return; + } + case pvShort: { + PVShort *value = (PVShort *)pv; + value->put(from); return; + } + case pvInt: { + PVInt *value = (PVInt *)pv; + value->put(from); return; + } + case pvLong: { + PVLong *value = (PVLong *)pv; + value->put(from); return; + } + case pvFloat: { + PVFloat *value = (PVFloat *)pv; + value->put(from); return; + } + case pvDouble: { + PVDouble *value = (PVDouble *)pv; + value->put(from); return; + } + case pvString: { + PVString *value = (PVString *)pv; + char buffer[20]; + double dval = from; + sprintf(buffer,"%e",dval); + String xxx(buffer); + value->put(xxx); + return; + } + } + throw std::logic_error(logicError); } int Convert::toByteArray(PVScalarArray * pv, int offset, int length, epicsInt8 to[], int toOffset) { - throw std::logic_error(notImplemented); + return convertToByteArray(pv, offset, length, to, toOffset); } int Convert::toShortArray(PVScalarArray * pv, int offset, int length, epicsInt16 to[], int toOffset) { - throw std::logic_error(notImplemented); + return convertToShortArray(pv, offset, length, to, toOffset); } int Convert::toIntArray(PVScalarArray * pv, int offset, int length, epicsInt32 to[], int toOffset) { - throw std::logic_error(notImplemented); + return convertToIntArray(pv, offset, length, to, toOffset); } int Convert::toLongArray(PVScalarArray * pv, int offset, int length, epicsInt64 to[], int toOffset) { - throw std::logic_error(notImplemented); + return convertToLongArray(pv, offset, length, to, toOffset); } int Convert::toFloatArray(PVScalarArray * pv, int offset, int length, float to[], int toOffset) { - throw std::logic_error(notImplemented); + return convertToFloatArray(pv, offset, length, to, toOffset); } int Convert::toDoubleArray(PVScalarArray * pv, int offset, int length, double to[], int toOffset) { - throw std::logic_error(notImplemented); + return convertToDoubleArray(pv, offset, length, to, toOffset); } int Convert::fromByteArray(PVScalarArray *pv, int offset, int length, epicsInt8 from[], int fromOffset) { - throw std::logic_error(notImplemented); + return convertFromByteArray(pv, offset, length, from, fromOffset); } int Convert::fromShortArray(PVScalarArray *pv, int offset, int length, epicsInt16 from[], int fromOffset) { - throw std::logic_error(notImplemented); + return convertFromShortArray(pv, offset, length, from, fromOffset); } int Convert::fromIntArray(PVScalarArray *pv, int offset, int length, epicsInt32 from[], int fromOffset) { - throw std::logic_error(notImplemented); + return convertFromIntArray(pv, offset, length, from, fromOffset); } int Convert::fromLongArray(PVScalarArray *pv, int offset, int length, epicsInt64 from[], int fromOffset) { - throw std::logic_error(notImplemented); + return convertFromLongArray(pv, offset, length, from, fromOffset); } int Convert::fromFloatArray(PVScalarArray *pv, int offset, int length, float from[], int fromOffset) { - throw std::logic_error(notImplemented); + return convertFromFloatArray(pv, offset, length, from, fromOffset); } int Convert::fromDoubleArray(PVScalarArray *pv, int offset, int length, double from[], int fromOffset) { - throw std::logic_error(notImplemented); + return convertFromDoubleArray(pv, offset, length, from, fromOffset); } void Convert::newLine(StringBuilder buffer, int indentLevel) @@ -738,7 +1164,7 @@ void Convert::newLine(StringBuilder buffer, int indentLevel) for(int i=0; igetScalar()->getScalarType(); ScalarType bscalarType = b->getScalar()->getScalarType(); @@ -747,8 +1173,8 @@ static epicsBoolean scalarEquals(PVScalar *a,PVScalar *b) case pvBoolean: { PVBoolean *pa = (PVBoolean *)a; PVBoolean *pb = (PVBoolean *)b; - epicsBoolean avalue = pa->get(); - epicsBoolean bvalue = pb->get(); + bool avalue = pa->get(); + bool bvalue = pb->get(); return ((avalue==bvalue) ? epicsTrue : epicsFalse); } case pvByte: { @@ -805,22 +1231,45 @@ static epicsBoolean scalarEquals(PVScalar *a,PVScalar *b) throw std::logic_error(message); } -static epicsBoolean arrayEquals(PVScalarArray *a,PVScalarArray *b) +static bool arrayEquals(PVScalarArray *a,PVScalarArray *b) +{ + if(a==b) return epicsTrue; + ScalarType aType = a->getScalarArray()->getElementType(); + ScalarType bType = b->getScalarArray()->getElementType(); + if(aType!=bType) return epicsFalse; + if(a->getLength()!=b->getLength()) return epicsFalse; + int length = a->getLength(); + switch(aType) { + case pvBoolean: { + PVBooleanArray *aarray = (PVBooleanArray *)a; + PVBooleanArray *barray = (PVBooleanArray *)b; + BooleanArrayData adata = BooleanArrayData(); + BooleanArrayData bdata = BooleanArrayData(); + aarray->get(0,length,&adata); + barray->get(0,length,&bdata); + bool *avalue = adata.data; + bool *bvalue = bdata.data; + for(int i=0; igetField()->getType(); @@ -928,7 +1377,7 @@ void convertToString(StringBuilder buffer,PVField * pv,int indentLevel) switch(pvScalar->getScalar()->getScalarType()) { case pvBoolean: { PVBoolean *data = (PVBoolean*)pv; - epicsBoolean value = data->get(); + bool value = data->get(); if(value) { *buffer += "true"; } else { @@ -1006,7 +1455,7 @@ void convertArray(StringBuilder buffer,PVScalarArray * pv,int indentLevel) if(i!=0) *buffer += ","; int num = pvdata->get(i,1,&data); if(num==1) { - epicsBoolean * value = data.data; + bool * value = data.data; if(value[data.offset]) { *buffer += "true"; } else { diff --git a/pvDataApp/factory/TypeFunc.cpp b/pvDataApp/factory/TypeFunc.cpp index c5ddcc5..25cea8b 100644 --- a/pvDataApp/factory/TypeFunc.cpp +++ b/pvDataApp/factory/TypeFunc.cpp @@ -22,24 +22,24 @@ namespace epics { namespace pvData { } - epicsBoolean ScalarTypeFunc::isInteger(ScalarType type) { + bool ScalarTypeFunc::isInteger(ScalarType type) { if(type>=pvByte && type<=pvLong) return epicsTrue; return epicsFalse; } - epicsBoolean ScalarTypeFunc::isNumeric(ScalarType type) { + bool ScalarTypeFunc::isNumeric(ScalarType type) { if(type>=pvByte && type<=pvDouble) return epicsTrue; return epicsFalse; } - epicsBoolean ScalarTypeFunc::isPrimitive(ScalarType type) { + bool ScalarTypeFunc::isPrimitive(ScalarType type) { if(type>=pvBoolean && type<=pvDouble) return epicsTrue; return epicsFalse; } ScalarType ScalarTypeFunc::getScalarType(String pvalue) { static String unknownString = "error unknown ScalarType"; - if(pvalue.compare("epicsBooleanean")==0) return pvBoolean; + if(pvalue.compare("boolean")==0) return pvBoolean; if(pvalue.compare("byte")==0) return pvByte; if(pvalue.compare("short")==0) return pvShort; if(pvalue.compare("int")==0) return pvInt; diff --git a/pvDataApp/misc/byteBuffer.h b/pvDataApp/misc/byteBuffer.h index abdf8ba..b42d273 100644 --- a/pvDataApp/misc/byteBuffer.h +++ b/pvDataApp/misc/byteBuffer.h @@ -15,7 +15,7 @@ class ByteBuffer { virtual ~ByteBuffer(); virtual int getSize() = 0; virtual int getArrayOffset() = 0; - virtual epicsBoolean getBoolean() = 0; + virtual bool getBoolean() = 0; virtual epicsInt8 getByte() = 0; virtual epicsInt16 geShort() = 0; virtual epicsInt32 getInt() = 0; @@ -23,7 +23,7 @@ class ByteBuffer { virtual float getFloat() = 0; virtual double getDouble() = 0; virtual String getString() = 0; - virtual ByteBuffer *putBoolean(epicsBoolean value) = 0; + virtual ByteBuffer *putBoolean(bool value) = 0; virtual ByteBuffer *putByte(epicsInt8 value) = 0; virtual ByteBuffer *geShort(epicsInt16 value) = 0; virtual ByteBuffer *putInt(epicsInt32 value) = 0; diff --git a/pvDataApp/pv/convert.h b/pvDataApp/pv/convert.h index 20c3eac..dc0c950 100644 --- a/pvDataApp/pv/convert.h +++ b/pvDataApp/pv/convert.h @@ -13,28 +13,28 @@ namespace epics { namespace pvData { Convert(); ~Convert(); void getFullName(StringBuilder buf,PVField *pvField); - epicsBoolean equals(PVField *a,PVField *b); + bool equals(PVField *a,PVField *b); 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, - StringArray from, int fromOffset); + String from[], int fromOffset); int toStringArray(PVScalarArray *pv, int offset, int length, - StringArray to, int toOffset); - epicsBoolean isCopyCompatible(FieldConstPtr from, FieldConstPtr to); + String to[], int toOffset); + bool isCopyCompatible(FieldConstPtr from, FieldConstPtr to); void copy(PVField *from,PVField *to); - epicsBoolean isCopyScalarCompatible( + bool isCopyScalarCompatible( ScalarConstPtr from, ScalarConstPtr to); void copyScalar(PVScalar *from, PVScalar *to); - epicsBoolean isCopyScalarArrayCompatible(ScalarArrayConstPtr from, + bool isCopyScalarArrayCompatible(ScalarArrayConstPtr from, ScalarArrayConstPtr to); int copyScalarArray(PVScalarArray *from, int offset, PVScalarArray *to, int toOffset, int length); - epicsBoolean isCopyStructureCompatible( + bool isCopyStructureCompatible( StructureConstPtr from, StructureConstPtr to); void copyStructure(PVStructure *from, PVStructure *to); - epicsBoolean isCopyStructureArrayCompatible( + bool isCopyStructureArrayCompatible( StructureArrayConstPtr from, StructureArrayConstPtr to); void copyStructureArray( PVStructureArray *from, PVStructureArray *to); diff --git a/pvDataApp/pv/pvData.h b/pvDataApp/pv/pvData.h index 1838afa..171b2c1 100644 --- a/pvDataApp/pv/pvData.h +++ b/pvDataApp/pv/pvData.h @@ -38,8 +38,6 @@ 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 { @@ -72,7 +70,7 @@ namespace epics { namespace pvData { int getNextFieldOffset() ; int getNumberFields() ; PVAuxInfo * getPVAuxInfo(); - epicsBoolean isImmutable() ; + bool isImmutable() ; void setImmutable(); FieldConstPtr getField() ; PVStructure * getParent() ; @@ -82,7 +80,7 @@ namespace epics { namespace pvData { void setPostHandler(PostHandler *postHandler); virtual void toString(StringBuilder buf) ; virtual void toString(StringBuilder buf,int indentLevel) ; - virtual epicsBoolean equals(PVField *pv) = 0; + virtual bool operator==(PVField *pv) = 0; protected: PVField(PVStructure *parent,FieldConstPtr field); void replaceStructure(); @@ -108,8 +106,8 @@ namespace epics { namespace pvData { int getLength() ; void setLength(int length); int getCapacity() ; - epicsBoolean isCapacityMutable() ; - void setCapacityMutable(epicsBoolean isMutable); + bool isCapacityMutable() ; + void setCapacityMutable(bool isMutable); virtual void setCapacity(int capacity) = 0; virtual void serialize(ByteBuffer *pbuffer, SerializableControl *pflusher) = 0; @@ -171,7 +169,7 @@ namespace epics { namespace pvData { SerializableControl *pflusher, int offset, int count) = 0; virtual void toString(StringBuilder buf) = 0; virtual void toString(StringBuilder buf,int indentLevel) = 0; - virtual epicsBoolean equals(PVField *pv) = 0; + virtual bool operator==(PVField *pv) = 0; protected: PVStructureArray(PVStructure *parent, StructureArrayConstPtr structureArray); @@ -205,11 +203,11 @@ namespace epics { namespace pvData { String fieldName,ScalarType elementType); PVStructureArray *getStructureArrayField(String fieldName); String getExtendsStructureName(); - epicsBoolean putExtendsStructureName( + bool putExtendsStructureName( String extendsStructureName); virtual void toString(StringBuilder buf) ; virtual void toString(StringBuilder buf,int indentLevel) ; - virtual epicsBoolean equals(PVField *pv) ; + virtual bool operator==(PVField *pv) ; virtual void serialize( ByteBuffer *pbuffer,SerializableControl *pflusher) ; virtual void deserialize( @@ -229,8 +227,8 @@ namespace epics { namespace pvData { class PVBoolean : public PVScalar { public: virtual ~PVBoolean(); - virtual epicsBoolean get() = 0; - virtual void put(epicsBoolean value) = 0; + virtual bool get() = 0; + virtual void put(bool value) = 0; protected: PVBoolean(PVStructure *parent,ScalarConstPtr scalar) : PVScalar(parent,scalar) {} @@ -315,7 +313,7 @@ namespace epics { namespace pvData { }; - typedef epicsBoolean * BooleanArray; + typedef bool * BooleanArray; class BooleanArrayData { public: BooleanArray data; @@ -329,7 +327,7 @@ namespace epics { namespace pvData { virtual void toString(StringBuilder buf,int indentLevel) = 0 ; virtual int get(int offset, int length, BooleanArrayData *data) = 0; virtual int put(int offset,int length, BooleanArray from, int fromOffset) = 0; - virtual void shareData(epicsBoolean value[],int capacity,int length) = 0; + virtual void shareData(bool value[],int capacity,int length) = 0; virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) = 0; virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0; protected: diff --git a/pvDataApp/pv/pvIntrospect.h b/pvDataApp/pv/pvIntrospect.h index e52f5f9..1a00789 100644 --- a/pvDataApp/pv/pvIntrospect.h +++ b/pvDataApp/pv/pvIntrospect.h @@ -48,9 +48,9 @@ namespace epics { namespace pvData { class ScalarTypeFunc { public: - static epicsBoolean isInteger(ScalarType type); - static epicsBoolean isNumeric(ScalarType type); - static epicsBoolean isPrimitive(ScalarType type); + static bool isInteger(ScalarType type); + static bool isNumeric(ScalarType type); + static bool isPrimitive(ScalarType type); static ScalarType getScalarType(String value); static void toString(StringBuilder buf,ScalarType scalarType); }; diff --git a/pvDataApp/test/testPVScalar.cpp b/pvDataApp/test/testPVScalar.cpp index 15fcb75..2ec5a53 100644 --- a/pvDataApp/test/testPVScalar.cpp +++ b/pvDataApp/test/testPVScalar.cpp @@ -22,9 +22,9 @@ void testBoolean() { printf("\ntestBoolean\n"); PVScalar *pvScalar = getStandardField()->scalarValue(pvBoolean); PVBoolean *pvValue = (PVBoolean *)pvScalar; - epicsBoolean value = epicsTrue; + bool value = epicsTrue; pvValue->put(value); - epicsBoolean getValue = pvValue->get(); + bool getValue = pvValue->get(); printf("put %s get %s\n", ((value==epicsFalse) ? "false" : "true"), ((getValue==epicsFalse) ? "false" : "true")); @@ -37,7 +37,7 @@ void testBoolean() { buffer.clear(); field->toString(&buffer); printf("%s\n",buffer.c_str()); - epicsBoolean isImmutable = pvValue->isImmutable(); + bool isImmutable = pvValue->isImmutable(); PVStructure *pvParent = pvValue->getParent(); printf("immutable %s parent %p\n", ((isImmutable==epicsFalse) ? "false" : "true"), @@ -57,7 +57,7 @@ void testBoolean() { printf("%s\n",buffer.c_str()); pvScalar->message(String("this is a test message"),infoMessage); PVScalar *other = getStandardField()->scalarValue(pvDouble); - epicsBoolean isEqual = pvScalar->equals(other); + bool isEqual = pvScalar==other; printf("expect false isEqual %s\n",(isEqual ? "true" : "false")); delete pvValue; } @@ -77,7 +77,7 @@ void testByte() { buffer.clear(); field->toString(&buffer); printf("%s\n",buffer.c_str()); - epicsBoolean isImmutable = pvValue->isImmutable(); + bool isImmutable = pvValue->isImmutable(); PVStructure *pvParent = pvValue->getParent(); printf("immutable %s parent %p\n", ((isImmutable==epicsFalse) ? "false" : "true"), @@ -97,7 +97,7 @@ void testByte() { printf("%s\n",buffer.c_str()); pvScalar->message(String("this is a test message"),infoMessage); PVScalar *other = getStandardField()->scalarValue(pvDouble); - epicsBoolean isEqual = pvScalar->equals(other); + bool isEqual = pvScalar==other; printf("expect false isEqual %s\n",(isEqual ? "true" : "false")); delete pvValue; } @@ -117,7 +117,7 @@ void testShort() { buffer.clear(); field->toString(&buffer); printf("%s\n",buffer.c_str()); - epicsBoolean isImmutable = pvValue->isImmutable(); + bool isImmutable = pvValue->isImmutable(); PVStructure *pvParent = pvValue->getParent(); printf("immutable %s parent %p\n", ((isImmutable==epicsFalse) ? "false" : "true"), @@ -137,7 +137,7 @@ void testShort() { printf("%s\n",buffer.c_str()); pvScalar->message(String("this is a test message"),infoMessage); PVScalar *other = getStandardField()->scalarValue(pvDouble); - epicsBoolean isEqual = pvScalar->equals(other); + bool isEqual = pvScalar==other; printf("expect false isEqual %s\n",(isEqual ? "true" : "false")); delete pvValue; } @@ -157,7 +157,7 @@ void testInt() { buffer.clear(); field->toString(&buffer); printf("%s\n",buffer.c_str()); - epicsBoolean isImmutable = pvValue->isImmutable(); + bool isImmutable = pvValue->isImmutable(); PVStructure *pvParent = pvValue->getParent(); printf("immutable %s parent %p\n", ((isImmutable==epicsFalse) ? "false" : "true"), @@ -177,7 +177,7 @@ void testInt() { printf("%s\n",buffer.c_str()); pvScalar->message(String("this is a test message"),infoMessage); PVScalar *other = getStandardField()->scalarValue(pvDouble); - epicsBoolean isEqual = pvScalar->equals(other); + bool isEqual = pvScalar==other; printf("expect false isEqual %s\n",(isEqual ? "true" : "false")); delete pvValue; } @@ -197,7 +197,7 @@ void testLong() { buffer.clear(); field->toString(&buffer); printf("%s\n",buffer.c_str()); - epicsBoolean isImmutable = pvValue->isImmutable(); + bool isImmutable = pvValue->isImmutable(); PVStructure *pvParent = pvValue->getParent(); printf("immutable %s parent %p\n", ((isImmutable==epicsFalse) ? "false" : "true"), @@ -217,7 +217,7 @@ void testLong() { printf("%s\n",buffer.c_str()); pvScalar->message(String("this is a test message"),infoMessage); PVScalar *other = getStandardField()->scalarValue(pvDouble); - epicsBoolean isEqual = pvScalar->equals(other); + bool isEqual = pvScalar==other; printf("expect false isEqual %s\n",(isEqual ? "true" : "false")); delete pvValue; } @@ -237,7 +237,7 @@ void testFloat() { buffer.clear(); field->toString(&buffer); printf("%s\n",buffer.c_str()); - epicsBoolean isImmutable = pvValue->isImmutable(); + bool isImmutable = pvValue->isImmutable(); PVStructure *pvParent = pvValue->getParent(); printf("immutable %s parent %p\n", ((isImmutable==epicsFalse) ? "false" : "true"), @@ -256,7 +256,7 @@ void testFloat() { pvValue->toString(&buffer); printf("%s\n",buffer.c_str()); pvScalar->message(String("this is a test message"),infoMessage); - epicsBoolean isEqual = pvScalar->equals(pvScalar); + bool isEqual = pvScalar==pvScalar; printf("expect true isEqual %s\n",(isEqual ? "true" : "false")); delete pvValue; } @@ -276,7 +276,7 @@ void testDouble() { buffer.clear(); field->toString(&buffer); printf("%s\n",buffer.c_str()); - epicsBoolean isImmutable = pvValue->isImmutable(); + bool isImmutable = pvValue->isImmutable(); PVStructure *pvParent = pvValue->getParent(); printf("immutable %s parent %p\n", ((isImmutable==epicsFalse) ? "false" : "true"), @@ -295,7 +295,7 @@ void testDouble() { pvValue->toString(&buffer); printf("%s\n",buffer.c_str()); pvScalar->message(String("this is a test message"),infoMessage); - epicsBoolean isEqual = pvScalar->equals(pvScalar); + bool isEqual = pvScalar==pvScalar; printf("expect true isEqual %s\n",(isEqual ? "true" : "false")); delete pvValue; } @@ -316,7 +316,7 @@ void testString() { buffer.clear(); field->toString(&buffer); printf("%s\n",buffer.c_str()); - epicsBoolean isImmutable = pvValue->isImmutable(); + bool isImmutable = pvValue->isImmutable(); PVStructure *pvParent = pvValue->getParent(); printf("immutable %s parent %p\n", ((isImmutable==epicsFalse) ? "false" : "true"), @@ -335,7 +335,7 @@ void testString() { pvValue->toString(&buffer); printf("%s\n",buffer.c_str()); pvScalar->message(String("this is a test message"),infoMessage); - epicsBoolean isEqual = pvScalar->equals(pvScalar); + bool isEqual = pvScalar==pvScalar; printf("expect true isEqual %s\n",(isEqual ? "true" : "false")); delete pvValue; } diff --git a/pvDataApp/test/testPVScalarArray.cpp b/pvDataApp/test/testPVScalarArray.cpp index 0c5df63..38c1bab 100644 --- a/pvDataApp/test/testPVScalarArray.cpp +++ b/pvDataApp/test/testPVScalarArray.cpp @@ -24,12 +24,12 @@ void testBooleanArray() { getStandardField()->scalarArrayValue(pvBoolean); PVBooleanArray *pvValue = (PVBooleanArray *)pvScalarArray; int length = 5; - epicsBoolean *value = new epicsBoolean[length]; + bool *value = new bool[length]; for(int i=0; iput(0,length,value,0); BooleanArrayData data = BooleanArrayData(); pvValue->get(0,length,&data); - epicsBoolean * getValue = data.data; + bool * getValue = data.data; printf("(orig,get):"); for(int i=0; i< length; i++) { printf("(%s,%s) ",