From 0d32a60b083dd293bc418e6aca00f484fc5696c8 Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Thu, 23 Sep 2010 11:01:41 -0400 Subject: [PATCH] everything now builds --- pvDataApp/factory/AbstractPVArray.h | 80 ++++ pvDataApp/factory/AbstractPVField.h | 182 +++++--- pvDataApp/factory/AbstractPVScalar.h | 15 +- pvDataApp/factory/AbstractPVScalarArray.h | 25 ++ pvDataApp/factory/BasePVDouble.h | 53 +-- pvDataApp/factory/BasePVDoubleArray.h | 94 +++++ pvDataApp/factory/BasePVStructure.h | 199 +++++++++ pvDataApp/factory/BasePVStructureArray.h | 95 +++++ pvDataApp/factory/Makefile | 7 + pvDataApp/factory/PVAuxInfoImpl.cpp | 84 ++++ pvDataApp/factory/PVDataCreateFactory.cpp | 86 +++- pvDataApp/pv/pvData.h | 489 ++++++++++++++++++++-- pvDataApp/pv/requester.h | 2 +- pvDataApp/pv/serialize.h | 6 +- pvDataApp/test/Makefile | 6 +- pvDataApp/test/testPVAuxInfo.cpp | 51 +++ 16 files changed, 1311 insertions(+), 163 deletions(-) create mode 100644 pvDataApp/factory/AbstractPVArray.h create mode 100644 pvDataApp/factory/AbstractPVScalarArray.h create mode 100644 pvDataApp/factory/BasePVDoubleArray.h create mode 100644 pvDataApp/factory/BasePVStructure.h create mode 100644 pvDataApp/factory/BasePVStructureArray.h create mode 100644 pvDataApp/factory/PVAuxInfoImpl.cpp create mode 100644 pvDataApp/test/testPVAuxInfo.cpp diff --git a/pvDataApp/factory/AbstractPVArray.h b/pvDataApp/factory/AbstractPVArray.h new file mode 100644 index 0000000..d2ab99f --- /dev/null +++ b/pvDataApp/factory/AbstractPVArray.h @@ -0,0 +1,80 @@ +/*AbstractPVArray.h*/ +#ifndef ABSTRACTPVARRAY_H +#define ABSTRACTPVARRAY_H +#include +#include +#include +#include +#include "pvData.h" +#include "factory.h" + +namespace epics { namespace pvData { + + class PVArrayPvt { + public: + PVArrayPvt() : length(0),capacity(0),capacityMutable(epicsTrue) + {} + int length; + int capacity; + epicsBoolean capacityMutable; + }; + + PVArray::PVArray(PVStructure *parent,FieldConstPtr field) + : PVField(parent,field),pImpl(new PVArrayPvt()) + { } + + PVArray::~PVArray() + { + delete pImpl; + } + + int PVArray::getLength() const {return pImpl->length;} + + static std::string fieldImmutable("field is immutable"); + + void PVArray::setLength(int length) { + if(PVField::isImmutable()) { + PVField::message(&fieldImmutable,errorMessage); + return; + } + if(length>pImpl->capacity) this->setCapacity(length); + if(length>pImpl->capacity) length = pImpl->capacity; + pImpl->length = length; + } + + + epicsBoolean PVArray::isCapacityImmutable() const + { + if(PVField::isImmutable()) { + return epicsFalse; + } + return pImpl->capacityMutable; + } + + void PVArray::setCapacityImmutable(epicsBoolean isMutable) + { + if(isMutable && PVField::isImmutable()) { + PVField::message(&fieldImmutable,errorMessage); + return; + } + pImpl->capacityMutable = isMutable; + } + + static std::string capacityImmutable("capacity is immutable"); + + void PVArray::setCapacity(int capacity) { + if(PVField::isImmutable()) { + PVField::message(&fieldImmutable,errorMessage); + return; + } + if(pImpl->capacityMutable==epicsFalse) { + PVField::message(&capacityImmutable,errorMessage); + return; + } + pImpl->capacity = capacity; + } + + void PVArray::toString(StringPtr buf) const {toString(buf,0);} + +}} +#endif /* ABSTRACTPVARRAY_H */ diff --git a/pvDataApp/factory/AbstractPVField.h b/pvDataApp/factory/AbstractPVField.h index 1afdc6c..b8bd560 100644 --- a/pvDataApp/factory/AbstractPVField.h +++ b/pvDataApp/factory/AbstractPVField.h @@ -10,121 +10,191 @@ namespace epics { namespace pvData { - PVField::~PVField(){} - - class AbstractPVField : public PVField { + class PVFieldPvt { public: - AbstractPVField(PVStructure *parent,FieldConstPtr field); - virtual ~AbstractPVField(); - // from Requester - virtual StringConstPtr getRequesterName() const; - virtual void message(StringConstPtr message,MessageType messageType) const; - // from PVField - virtual void setRequester(Requester *prequester); - virtual int getFieldOffset() const; - virtual int getNextFieldOffset() const; - virtual int getNumberFields() const; - virtual PVAuxInfo * getPVAuxInfo() const {return pvAuxInfo;} - virtual epicsBoolean isImmutable() const {return immutable;} - virtual void setImmutable() {immutable = epicsTrue;} - virtual FieldConstPtr getField() const {return field;} - virtual PVStructure * getParent() const {return parent;} - virtual void replacePVField(PVField * newPVField); - virtual void renameField(StringConstPtr newName); - virtual void postPut() const; - virtual void setPostHandler(PostHandler *ppostHandler); - virtual void toString(StringPtr buf) const {toString(buf,0);} - virtual void toString(StringPtr buf,int indentLevel) const; - protected: - void replaceStructure(); - private: - AbstractPVField(AbstractPVField const & ); // not implemented - AbstractPVField & operator=(AbstractPVField const &); //not implemented + PVFieldPvt(PVStructure *parent,FieldConstPtr field); + ~PVFieldPvt(); + PVStructure *parent; + FieldConstPtr field; int fieldOffset; int nextFieldOffset; PVAuxInfo *pvAuxInfo; epicsBoolean immutable; - PVStructure *parent; - FieldConstPtr field; Requester *requester; PostHandler *postHandler; }; - AbstractPVField::AbstractPVField(PVStructure *parent,FieldConstPtr field) - : fieldOffset(0),nextFieldOffset(0),pvAuxInfo(0),immutable(epicsFalse), - parent(parent),field(field),requester(0),postHandler(0) + PVFieldPvt::PVFieldPvt(PVStructure *parent,FieldConstPtr field) + : parent(parent),field(field), + fieldOffset(0), nextFieldOffset(0), + pvAuxInfo(0), + immutable(epicsFalse),requester(0),postHandler(0) { field->incReferenceCount(); } - AbstractPVField::~AbstractPVField() + PVFieldPvt::~PVFieldPvt() { field->decReferenceCount(); } - StringConstPtr AbstractPVField::getRequesterName() const + + PVField::PVField(PVStructure *parent,FieldConstPtr field) + : pImpl(new PVFieldPvt(parent,field)) + {} + + PVField::~PVField() + { + delete pImpl; + } + + StringConstPtr PVField::getRequesterName() const { static std::string none("none"); - if(requester!=0) return requester->getRequesterName(); + if(pImpl->requester!=0) return pImpl->requester->getRequesterName(); return &none; } - void AbstractPVField::message(StringConstPtr message,MessageType messageType) const + void PVField::message(StringConstPtr message,MessageType messageType) const { - if(requester) { - requester->message(message,messageType); + if(pImpl->requester) { + pImpl->requester->message(message,messageType); } else { printf("%s %s %s\n", messageTypeName[messageType].c_str(), - field->getFieldName()->c_str(), + pImpl->field->getFieldName()->c_str(), message->c_str()); } } - void AbstractPVField::setRequester(Requester *prequester) + void PVField::setRequester(Requester *prequester) { - static std::string requesterPresent = "Logic Error. requester is already present"; - if(requester==0) { - requester = prequester; + static std::string requesterPresent = + "Logic Error. requester is already present"; + if(pImpl->requester==0) { + pImpl->requester = prequester; return; } throw std::logic_error(requesterPresent); } - int AbstractPVField::getFieldOffset() const + int PVField::getFieldOffset() const { - return -1; + if(pImpl->nextFieldOffset==0) computeOffset(this); + return pImpl->fieldOffset; } - int AbstractPVField::getNextFieldOffset() const + int PVField::getNextFieldOffset() const { - return -1; + if(pImpl->nextFieldOffset==0) computeOffset(this); + return pImpl->nextFieldOffset; } - int AbstractPVField::getNumberFields() const + int PVField::getNumberFields() const { - return -1; + if(pImpl->nextFieldOffset==0) computeOffset(this); + return (pImpl->nextFieldOffset - pImpl->fieldOffset); } - void AbstractPVField::replacePVField(PVField * newPVField) + PVAuxInfo * PVField::getPVAuxInfo(){ + if(pImpl->pvAuxInfo==0) { + pImpl->pvAuxInfo = new PVAuxInfo(this); + } + return pImpl->pvAuxInfo; + } + + epicsBoolean PVField::isImmutable() const {return pImpl->immutable;} + + void PVField::setImmutable() {pImpl->immutable = epicsTrue;} + + FieldConstPtr PVField::getField() const {return pImpl->field;} + + PVStructure * PVField::getParent() const {return pImpl->parent;} + + void PVField::replacePVField(PVField * newPVField) { } - void AbstractPVField::renameField(StringConstPtr newName) + void PVField::renameField(StringConstPtr newName) { } - void AbstractPVField::postPut() const + void PVField::postPut() const { } - void AbstractPVField::setPostHandler(PostHandler *ppostHandler) + void PVField::setPostHandler(PostHandler *ppostHandler) { } - void AbstractPVField::toString(StringPtr buf,int indentLevel) const + void PVField::toString(StringPtr buf) const {toString(buf,0);} + + void PVField::toString(StringPtr buf,int indentLevel) const { } + void PVField::computeOffset(PVField const * const pvField) { + PVStructure *pvTop = pvField->getParent(); + if(pvTop==0) { + pvTop = (PVStructure *)pvField; + } else { + while(pvTop->getParent()!=0) { + pvTop = pvTop->getParent(); + } + } + int offset = 0; + int nextOffset = 1; + PVFieldArrayPtr pvFields = pvTop->getPVFields(); + for(int i=0; i < pvTop->getStructure()->getNumberFields(); i++) { + offset = nextOffset; + PVField *pvField = pvFields[i]; + FieldConstPtr field = pvField->getField(); + switch(field->getType()) { + case scalar: + case scalarArray: + case structureArray:{ + nextOffset++; + pvField->pImpl->fieldOffset = offset; + pvField->pImpl->nextFieldOffset = nextOffset; + break; + } + case structure: { + pvField->computeOffset(pvField,offset); + nextOffset = pvField->getNextFieldOffset(); + } + } + } + PVField *top = (PVField *)pvTop; + top->pImpl->fieldOffset = 0; + top->pImpl->nextFieldOffset = nextOffset; + } + + void PVField::computeOffset(PVField const * const pvField,int offset) { + int beginOffset = offset; + int nextOffset = offset + 1; + PVStructure *pvStructure = (PVStructure *)pvField; + PVFieldArrayPtr pvFields = pvStructure->getPVFields(); + for(int i=0; i < pvStructure->getStructure()->getNumberFields(); i++) { + offset = nextOffset; + PVField *pvSubField = pvFields[i]; + FieldConstPtr field = pvSubField->getField(); + switch(field->getType()) { + case scalar: + case scalarArray: + case structureArray: { + nextOffset++; + pvSubField->pImpl->fieldOffset = offset; + pvSubField->pImpl->nextFieldOffset = nextOffset; + break; + } + case structure: { + pvSubField->computeOffset(pvSubField,offset); + nextOffset = pvSubField->getNextFieldOffset(); + } + } + } + pvField->pImpl->fieldOffset = beginOffset; + pvField->pImpl->nextFieldOffset = nextOffset; + } }} #endif /* ABSTRACTPVFIELD_H */ diff --git a/pvDataApp/factory/AbstractPVScalar.h b/pvDataApp/factory/AbstractPVScalar.h index 95c8bd8..cf46f70 100644 --- a/pvDataApp/factory/AbstractPVScalar.h +++ b/pvDataApp/factory/AbstractPVScalar.h @@ -13,16 +13,13 @@ namespace epics { namespace pvData { PVScalar::~PVScalar() {} - class AbstractPVScalar : public AbstractPVField{ - public: - AbstractPVScalar(PVStructure *parent,ScalarConstPtr scalar) - : AbstractPVField(parent,scalar) {} - virtual ~AbstractPVScalar() {} - virtual Scalar *getScalar()const { - return (Scalar*)AbstractPVField::getField(); - } - }; + PVScalar::PVScalar(PVStructure *parent,ScalarConstPtr scalar) + : PVField(parent,scalar) {} + ScalarConstPtr PVScalar::getScalar() const + { + return (ScalarConstPtr) PVField::getField(); + } }} #endif /* ABSTRACTPVSCALAR_H */ diff --git a/pvDataApp/factory/AbstractPVScalarArray.h b/pvDataApp/factory/AbstractPVScalarArray.h new file mode 100644 index 0000000..a52ab2d --- /dev/null +++ b/pvDataApp/factory/AbstractPVScalarArray.h @@ -0,0 +1,25 @@ +/*AbstractPVScalarArray.h*/ +#ifndef ABSTRACTPVSCALARARRAY_H +#define ABSTRACTPVSCALARARRAY_H +#include +#include +#include +#include +#include "pvData.h" +#include "factory.h" +#include "AbstractPVArray.h" + +namespace epics { namespace pvData { + + PVScalarArray::~PVScalarArray() {} + + PVScalarArray::PVScalarArray(PVStructure *parent,ScalarArrayConstPtr scalarArray) + : PVArray(parent,scalarArray) {} + + ScalarArrayConstPtr PVScalarArray::getScalarArray() const + { + return (ScalarArrayConstPtr) PVField::getField(); + } + +}} +#endif /* ABSTRACTPVSCALARARRAY_H */ diff --git a/pvDataApp/factory/BasePVDouble.h b/pvDataApp/factory/BasePVDouble.h index 7dd7074..1d89ed3 100644 --- a/pvDataApp/factory/BasePVDouble.h +++ b/pvDataApp/factory/BasePVDouble.h @@ -7,62 +7,25 @@ #include #include "pvData.h" #include "factory.h" -#include "AbstractPVScalar.h" +#include "AbstractPVField.h" namespace epics { namespace pvData { PVDouble::~PVDouble() {} - class BasePVDouble : public AbstractPVScalar, public PVDouble { + class BasePVDouble : public PVDouble { public: BasePVDouble(PVStructure *parent,ScalarConstPtr scalar) - : AbstractPVScalar(parent,scalar),value(0.0) {} + : PVDouble(parent,scalar),value(0.0) {} virtual ~BasePVDouble() {} - // from Requester - virtual StringConstPtr getRequesterName() const{ - return AbstractPVField::getRequesterName();} - virtual void message(StringConstPtr message,MessageType messageType) const{ - AbstractPVField::message(message,messageType);} - // from PVScalar - virtual Scalar *getScalar() const{ - return (Scalar *)getField();} - // from PVField - virtual void setRequester(Requester *requester){ - AbstractPVField::setRequester(requester);} - virtual int getFieldOffset() const{ - return AbstractPVField::getFieldOffset();} - virtual int getNextFieldOffset() const{ - return AbstractPVField::getNextFieldOffset();} - virtual int getNumberFields() const{ - return AbstractPVField::getNumberFields();} - virtual PVAuxInfo * getPVAuxInfo() const{ - return AbstractPVField::getPVAuxInfo();} - virtual epicsBoolean isImmutable() const{ - return AbstractPVField::isImmutable();} - virtual void setImmutable(){ - AbstractPVField::setImmutable();} - virtual FieldConstPtr getField() const{ - return AbstractPVField::getField();} - virtual PVStructure * getParent() const{ - return AbstractPVField::getParent();} - virtual void replacePVField(PVField * newPVField){ - AbstractPVField::replacePVField(newPVField);} - virtual void renameField(StringConstPtr newName){ - AbstractPVField::renameField(newName);} - virtual void postPut() const{ - AbstractPVField::postPut();} - virtual void setPostHandler(PostHandler *postHandler){ - AbstractPVField::setPostHandler(postHandler);} - virtual void toString(StringPtr buf) const {toString(buf,0);} - virtual void toString(StringPtr buf,int indentLevel) const{ - AbstractPVField::toString(buf,indentLevel);} - // from PVDouble virtual double get()const { return value;} virtual void put(double val){value = val;} - // from Serializable - virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const{} - virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher){} + virtual void serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const{} + virtual void deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher){} + virtual void toString(StringPtr buf)const {} + virtual void toString(StringPtr buf,int indentLevel)const {} private: + BasePVDouble(); // not implemented double value; }; diff --git a/pvDataApp/factory/BasePVDoubleArray.h b/pvDataApp/factory/BasePVDoubleArray.h new file mode 100644 index 0000000..5e15cdd --- /dev/null +++ b/pvDataApp/factory/BasePVDoubleArray.h @@ -0,0 +1,94 @@ +/*BasePVDoubleArray.h*/ +#ifndef BASEPVDOUBLEARRAY_H +#define BASEPVDOUBLEARRAY_H +#include +#include +#include +#include +#include "pvData.h" +#include "factory.h" +#include "AbstractPVScalarArray.h" + +namespace epics { namespace pvData { + + PVDoubleArray::~PVDoubleArray() {} + + PVDoubleArray::PVDoubleArray(PVStructure *parent,ScalarArrayConstPtr scalar) + : PVScalarArray(parent,scalar) {} + + class BasePVDoubleArray : public PVDoubleArray { + public: + 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, + 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(StringPtr buf)const; + virtual void toString(StringPtr buf,int indentLevel)const; + private: + BasePVDoubleArray(); // not implemented + DoubleArrayPtr doubleArray; + }; + + BasePVDoubleArray::BasePVDoubleArray(PVStructure *parent,ScalarArrayConstPtr scalarArray) + : PVDoubleArray(parent,scalarArray),doubleArray(new double[0]) + { + } + + BasePVDoubleArray::~BasePVDoubleArray() + { + delete[] doubleArray; + } + + void BasePVDoubleArray::setCapacity(int capacity) + { + } + + int BasePVDoubleArray::get(int offset, int length, + DoubleArrayData *data) const + { + data->data = doubleArray; + return getLength(); + } + + int BasePVDoubleArray::put(int offset,int length, + DoubleArrayPtr from,int fromOffset) + { + return getLength(); + } + + void BasePVDoubleArray::shareData(DoubleArrayPtr from) + { + } + + void BasePVDoubleArray::serialize(ByteBuffer *pbuffer,SerializableControl *pflusher) const + { + } + + void BasePVDoubleArray::deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) + { + } + + void BasePVDoubleArray::serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher, int offset, int count) const + { + } + + void BasePVDoubleArray::toString(StringPtr buf)const + { + } + + void BasePVDoubleArray::toString(StringPtr buf,int indentLevel)const + { + } + + +}} +#endif /* BASEPVDOUBLEARRAY_H */ diff --git a/pvDataApp/factory/BasePVStructure.h b/pvDataApp/factory/BasePVStructure.h new file mode 100644 index 0000000..151b712 --- /dev/null +++ b/pvDataApp/factory/BasePVStructure.h @@ -0,0 +1,199 @@ +/*BasePVStructure.h*/ +#ifndef BASEPVSTRUCTURE_H +#define BASEPVSTRUCTURE_H +#include +#include +#include +#include +#include "pvData.h" +#include "factory.h" + +namespace epics { namespace pvData { + + class PVStructurePvt { + public: + PVStructurePvt(); + ~PVStructurePvt(); + + int numberFields; + PVFieldArrayPtr pvFields; + std::string const extendsStructureName; + }; + + PVStructurePvt::PVStructurePvt() + : numberFields(0), pvFields(0),extendsStructureName(0) + { + } + + PVStructurePvt::~PVStructurePvt() + { + for(int i=0; igetNumberFields(); + pImpl->numberFields = numberFields; + pImpl->pvFields = new PVFieldPtr[numberFields]; + for(int i=0; ipvFields; + } + + PVFieldPtr PVStructure::getSubField(StringConstPtr fieldName) + { + return 0; + } + + PVFieldPtr PVStructure::getSubField(int fieldOffset) + { + return 0; + } + + void PVStructure::appendPVField(PVFieldPtr pvField) + { + } + + void PVStructure::appendPVFields(PVFieldArrayPtr pvFields) + { + } + + void PVStructure::removePVField(StringConstPtr fieldName) + { + } + + PVBoolean *PVStructure::getBooleanField(StringConstPtr fieldName) + { + return 0; + } + + PVByte *PVStructure::getByteField(StringConstPtr fieldName) + { + return 0; + } + + PVShort *PVStructure::getShortField(StringConstPtr fieldName) + { + return 0; + } + + PVInt *PVStructure::getIntField(StringConstPtr fieldName) + { + return 0; + } + + PVLong *PVStructure::getLongField(StringConstPtr fieldName) + { + return 0; + } + + PVFloat *PVStructure::getFloatField(StringConstPtr fieldName) + { + return 0; + } + + PVDouble *PVStructure::getDoubleField(StringConstPtr fieldName) + { + return 0; + } + + PVString *PVStructure::getStringField(StringConstPtr fieldName) + { + return 0; + } + + PVStructure *PVStructure::getStructureField(StringConstPtr fieldName) + { + return 0; + } + + PVScalarArray *PVStructure::getScalarArrayField( + StringConstPtr fieldName,ScalarType elementType) + { + return 0; + } + + PVStructureArray *PVStructure::getStructureArrayField( + StringConstPtr fieldName) + { + return 0; + } + + StringConstPtr PVStructure::getExtendsStructureName() + { + return 0; + } + + epicsBoolean PVStructure::putExtendsStructureName( + StringConstPtr extendsStructureName) + { + return epicsFalse; + } + + void PVStructure::toString(StringPtr buf) const {toString(buf,0);} + + void PVStructure::toString(StringPtr buf,int indentLevel) const + { + } + + void PVStructure::serialize( + ByteBuffer *pbuffer,SerializableControl *pflusher) const + { + } + + void PVStructure::deserialize( + ByteBuffer *pbuffer,DeserializableControl *pflusher) + { + } + + void PVStructure::serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher, int offset, int count) const + { + } + + void PVStructure::serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher,BitSet *pbitSet) const + { + } + + void PVStructure::deserialize(ByteBuffer *pbuffer, + DeserializableControl*pflusher,BitSet *pbitSet) + { + } + + class BasePVStructure : public PVStructure { + public: + BasePVStructure(PVStructure *parent,StructureConstPtr structure); + ~BasePVStructure(); + private: + BasePVStructure(); // not implemented + BasePVStructure(BasePVStructure const & ); // not implemented + BasePVStructure& operator=(BasePVStructure const &); //not implemented + + }; + + BasePVStructure::BasePVStructure(PVStructure *parent,StructureConstPtr structure) + : PVStructure(parent,structure) {} + + BasePVStructure::~BasePVStructure() {} + +}} +#endif /* BASEPVSTRUCTURE_H */ diff --git a/pvDataApp/factory/BasePVStructureArray.h b/pvDataApp/factory/BasePVStructureArray.h new file mode 100644 index 0000000..12e4dac --- /dev/null +++ b/pvDataApp/factory/BasePVStructureArray.h @@ -0,0 +1,95 @@ +/*BasePVStructureArray.h*/ +#ifndef BASEPVSTRUCTUREARRAY_H +#define BASEPVSTRUCTUREARRAY_H +#include +#include +#include +#include +#include "pvData.h" +#include "factory.h" + +namespace epics { namespace pvData { + + class PVStructureArrayPvt { + public: + PVStructureArrayPvt(StructureArrayConstPtr structureArray); + ~PVStructureArrayPvt(); + + StructureArrayConstPtr structureArray; + StructureArrayData *structureArrayData; + PVStructureArrayPtr pvStructureArray; + }; + PVStructureArrayPvt::PVStructureArrayPvt(StructureArrayConstPtr structureArray) + : structureArray(structureArray), + structureArrayData(new StructureArrayData()), + pvStructureArray(new PVStructurePtr[0]) + {} + + PVStructureArrayPvt::~PVStructureArrayPvt() + { + delete structureArrayData; + delete pvStructureArray; + } + + + PVStructureArray::PVStructureArray(PVStructure *parent,StructureArrayConstPtr structureArray) + : PVArray(parent,structureArray),pImpl(new PVStructureArrayPvt(structureArray)) + { + } + + PVStructureArray::~PVStructureArray() + { + delete pImpl; + } + + StructureArrayConstPtr PVStructureArray::getStructureArray() const + { + return pImpl->structureArray; + } + + int PVStructureArray::get(int offset, int length, StructureArrayData *data) const + { + return 0; + } + + int PVStructureArray::put(int offset,int length, PVStructureArrayPtr from, int fromOffset) + { + return 0; + } + + void PVStructureArray::shareData(PVStructureArrayPtr from) + { + } + + void PVStructureArray::serialize(ByteBuffer *pbuffer, SerializableControl *pflusher) const + { + } + + void PVStructureArray::deserialize(ByteBuffer *pbuffer, DeserializableControl *pflusher) + { + } + + void PVStructureArray::serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher, int offset, int count) const + { + } + + void PVStructureArray::toString(StringPtr buf) const {toString(buf,0);} + + void PVStructureArray::toString(StringPtr buf,int indentLevel) const + { + } + + class BasePVStructureArray : public PVStructureArray { + public: + BasePVStructureArray(PVStructure *parent,StructureArrayConstPtr structureArray) + : PVStructureArray(parent,structureArray) {} + ~BasePVStructureArray(){} + private: + BasePVStructureArray(); // not implemented + BasePVStructureArray(BasePVStructureArray const & ); // not implemented + BasePVStructureArray & operator=(BasePVStructureArray const &); //not implemented + }; + +}} +#endif /* BASEPVSTRUCTUREARRAY_H */ diff --git a/pvDataApp/factory/Makefile b/pvDataApp/factory/Makefile index a75b605..80826ff 100644 --- a/pvDataApp/factory/Makefile +++ b/pvDataApp/factory/Makefile @@ -5,8 +5,15 @@ include $(TOP)/configure/CONFIG INC += factory.h INC += AbstractPVField.h INC += AbstractPVScalar.h +INC += AbstractPVArray.h +INC += AbstractPVScalarArray.h +INC += BasePVStructure.h INC += BasePVDouble.h +INC += BasePVDoubleArray.h +INC += BasePVStructure.h +INC += BasePVStructureArray.h LIBSRCS += TypeFunc.cpp +LIBSRCS += PVAuxInfoImpl.cpp LIBSRCS += FieldCreateFactory.cpp LIBSRCS += PVDataCreateFactory.cpp diff --git a/pvDataApp/factory/PVAuxInfoImpl.cpp b/pvDataApp/factory/PVAuxInfoImpl.cpp new file mode 100644 index 0000000..1c1feaf --- /dev/null +++ b/pvDataApp/factory/PVAuxInfoImpl.cpp @@ -0,0 +1,84 @@ +/*AbstractPVScalar.h*/ +#ifndef ABSTRACTPVSCALAR_H +#define ABSTRACTPVSCALAR_H +#include +#include +#include +#include +#include "pvData.h" +#include "factory.h" + +namespace epics { namespace pvData { + + static PVDataCreate *pvDataCreate =0; + + class PVAuxInfoPvt { + public: + PVAuxInfoPvt(PVField *pvField) + : pvField(pvField), + theMap(std::map()) + {} + PVField *pvField; + std::map theMap; + }; + + PVAuxInfo::PVAuxInfo(PVField *pvField) + : pImpl(new PVAuxInfoPvt(pvField)) + { } + + PVAuxInfo::~PVAuxInfo() { delete pImpl;} + + PVField * PVAuxInfo::getPVField() { + return pImpl->pvField; + } + + typedef std::map::const_iterator map_iterator; + + PVScalar * PVAuxInfo::createInfo(StringConstPtr key,ScalarType scalarType) + { + map_iterator i = pImpl->theMap.find(key); + if(i!=pImpl->theMap.end()) { + std::string message("AuxoInfo:create key "); + message += key->c_str(); + message += " already exists with scalarType "; + ScalarTypeFunc::toString(&message,scalarType); + pImpl->pvField->message(&message,errorMessage); + } + if(pvDataCreate==0) pvDataCreate = getPVDataCreate(); + PVScalar *pvScalar = pvDataCreate->createPVScalar(0,key,scalarType); + pImpl->theMap.insert(std::pair(key, pvScalar)); + return pvScalar; + + } + + std::map *PVAuxInfo::getInfos() + { + return &pImpl->theMap; + } + + PVScalar * PVAuxInfo::getInfo(StringConstPtr key) + { + map_iterator i = pImpl->theMap.find(key); + if(i!=pImpl->theMap.end()) return i->second; + return 0; + } + + void PVAuxInfo::toString(StringPtr buf) + { + return PVAuxInfo::toString(buf,0); + } + + void PVAuxInfo::toString(StringPtr buf,int indentLevel) + { + map_iterator i = pImpl->theMap.begin(); + while(i!=pImpl->theMap.end()) { + StringConstPtr key = i->first; + PVScalar *value = i->second; + *buf += " "; + *buf += key->c_str(); + *buf += " "; + value->toString(buf); + } + } +}} +#endif /* ABSTRACTPVSCALAR_H */ diff --git a/pvDataApp/factory/PVDataCreateFactory.cpp b/pvDataApp/factory/PVDataCreateFactory.cpp index 83c761f..4b73fdc 100644 --- a/pvDataApp/factory/PVDataCreateFactory.cpp +++ b/pvDataApp/factory/PVDataCreateFactory.cpp @@ -6,27 +6,66 @@ #include "pvData.h" #include "factory.h" #include "AbstractPVField.h" +#include "AbstractPVScalar.h" +#include "AbstractPVArray.h" +#include "AbstractPVScalarArray.h" #include "BasePVDouble.h" +#include "AbstractPVArray.h" +#include "BasePVDoubleArray.h" +#include "BasePVStructure.h" +#include "BasePVStructureArray.h" namespace epics { namespace pvData { static std::string notImplemented("not implemented"); + static FieldCreate * fieldCreate = 0; + static PVDataCreate* pvDataCreate = 0; + PVDataCreate::PVDataCreate(){}; PVField *PVDataCreate::createPVField(PVStructure *parent, - FieldConstPtr field) const + FieldConstPtr field) { - throw std::logic_error(notImplemented); + switch(field->getType()) { + case scalar: + return createPVScalar(parent,(ScalarConstPtr)field); + case scalarArray: + return (PVField *)createPVScalarArray(parent, + (ScalarArrayConstPtr)field); + case structure: + return (PVField *)createPVStructure(parent, + (StructureConstPtr)field); + case structureArray: + return createPVStructureArray(parent, + (StructureArrayConstPtr)field); + } + std::string message("PVDataCreate::createPVField"); + throw std::invalid_argument(message); }; PVField *PVDataCreate::createPVField(PVStructure *parent, - StringConstPtr fieldName,FieldConstPtr fieldToClone) const + StringConstPtr fieldName,PVField * fieldToClone) { - throw std::logic_error(notImplemented); + switch(fieldToClone->getField()->getType()) { + case scalar: + return createPVScalar(parent,fieldName,(PVScalar*)fieldToClone); + case scalarArray: + return (PVField *)createPVScalarArray(parent,fieldName, + (PVScalarArray *)fieldToClone); + case structure: + return (PVField *)createPVStructure(parent,fieldName, + (PVStructure *)fieldToClone); + case structureArray: + std::string message( + "PVDataCreate::createPVField structureArray not valid fieldToClone"); + throw std::invalid_argument(message); + } + std::string message("PVDataCreate::createPVField"); + throw std::logic_error(message); }; - PVScalar *PVDataCreate::createPVScalar(PVStructure *parent,ScalarConstPtr scalar) const + PVScalar *PVDataCreate::createPVScalar(PVStructure *parent,ScalarConstPtr scalar) { ScalarType scalarType = scalar->getScalarType(); switch(scalarType) { @@ -41,19 +80,37 @@ namespace epics { namespace pvData { PVScalar *PVDataCreate::createPVScalar(PVStructure *parent, StringConstPtr fieldName,ScalarType scalarType) { - throw std::logic_error(notImplemented); + if(fieldCreate==0) fieldCreate = getFieldCreate(); + ScalarConstPtr scalar = fieldCreate->createScalar(fieldName,scalarType); + return createPVScalar(parent,scalar); }; PVScalar *PVDataCreate::createPVScalar(PVStructure *parent, - StringConstPtr fieldName,ScalarConstPtr scalarToClone) const + StringConstPtr fieldName,PVScalar * scalarToClone) { - throw std::logic_error(notImplemented); + PVScalar *pvScalar = createPVScalar(parent,fieldName, + scalarToClone->getScalar()->getScalarType()); + //MARTY MUST CALL CONVERT + //MARTY MUST COPY AUXInfo + return pvScalar; }; PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent, - ScalarArrayConstPtr scalarArray) const + ScalarArrayConstPtr scalarArray) { + switch(scalarArray->getElementType()) { + case pvBoolean: break; + case pvByte: break; + case pvShort: break; + case pvInt: break; + case pvLong: break; + case pvFloat: break; + case pvDouble: + return new BasePVDoubleArray(parent,scalarArray); + case pvString: break; + } throw std::logic_error(notImplemented); + }; PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent, @@ -63,13 +120,13 @@ namespace epics { namespace pvData { }; PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent, - StringConstPtr fieldName,ScalarArrayConstPtr scalarArrayToClone) const + StringConstPtr fieldName,PVScalarArray * scalarArrayToClone) { throw std::logic_error(notImplemented); }; PVStructureArray *PVDataCreate::createPVStructureArray(PVStructure *parent, - StructureArrayConstPtr structureArray) const + StructureArrayConstPtr structureArray) { throw std::logic_error(notImplemented); }; @@ -77,7 +134,7 @@ namespace epics { namespace pvData { PVStructure *PVDataCreate::createPVStructure(PVStructure *parent, StructureConstPtr structure) { - throw std::logic_error(notImplemented); + return new BasePVStructure(parent,structure); }; PVStructure *PVDataCreate::createPVStructure(PVStructure *parent, @@ -92,7 +149,6 @@ namespace epics { namespace pvData { throw std::logic_error(notImplemented); }; - static PVDataCreate* instance = 0; class PVDataCreateExt : public PVDataCreate { public: @@ -100,8 +156,8 @@ namespace epics { namespace pvData { }; PVDataCreate * getPVDataCreate() { - if(instance==0) instance = new PVDataCreateExt(); - return instance; + if(pvDataCreate==0) pvDataCreate = new PVDataCreateExt(); + return pvDataCreate; } }} diff --git a/pvDataApp/pv/pvData.h b/pvDataApp/pv/pvData.h index 91699e5..fce174b 100644 --- a/pvDataApp/pv/pvData.h +++ b/pvDataApp/pv/pvData.h @@ -36,15 +36,19 @@ namespace epics { namespace pvData { class PVAuxInfo { public: - virtual ~PVAuxInfo(); - virtual PVField * getPVField() const = 0; - virtual PVScalar * createInfo(StringConstPtr key,ScalarType scalarType) = 0; - /* following caused compiler error - virtual map getInfos() = 0; - */ - virtual PVScalar * getInto(StringConstPtr key) = 0; - virtual void toString(StringPtr buf) const = 0; - virtual void toString(StringPtr buf,int indentLevel) const = 0; + PVAuxInfo(PVField *pvField); + ~PVAuxInfo(); + PVField * getPVField(); + PVScalar * createInfo(StringConstPtr key,ScalarType scalarType); + std::map *getInfos(); + PVScalar * getInfo(StringConstPtr key); + void toString(StringPtr buf); + void toString(StringPtr buf,int indentLevel); + private: + PVAuxInfo(); // not implemented + PVAuxInfo(PVAuxInfo const & ); // not implemented + PVAuxInfo & operator=(PVAuxInfo const &); //not implemented + class PVAuxInfoPvt *pImpl; }; class PostHandler { @@ -54,27 +58,180 @@ namespace epics { namespace pvData { class PVField : public Requester, public Serializable { public: virtual ~PVField(); - virtual void setRequester(Requester *prequester) = 0; - virtual int getFieldOffset() const = 0; - virtual int getNextFieldOffset() const = 0; - virtual int getNumberFields() const = 0; - virtual PVAuxInfo * getPVAuxInfo() const = 0; - virtual epicsBoolean isImmutable() const = 0; - virtual void setImmutable() = 0; - virtual FieldConstPtr getField() const = 0; - virtual PVStructure * getParent() const = 0; - virtual void replacePVField(PVField * newPVField) = 0; - virtual void renameField(StringConstPtr newName) = 0; - virtual void postPut() const = 0; - virtual void setPostHandler(PostHandler *ppostHandler) = 0; - virtual void toString(StringPtr buf) const = 0; - virtual void toString(StringPtr buf,int indentLevel) const = 0; - }; + StringConstPtr getRequesterName() const; + virtual void message(StringConstPtr message,MessageType messageType) const; + virtual void setRequester(Requester *prequester); + int getFieldOffset() const; + int getNextFieldOffset() const; + int getNumberFields() const; + PVAuxInfo * getPVAuxInfo(); + epicsBoolean isImmutable() const; + void setImmutable(); + FieldConstPtr getField() const; + PVStructure * getParent() const; + void replacePVField(PVField * newPVField); + void renameField(StringConstPtr newName); + void postPut() const; + void setPostHandler(PostHandler *postHandler); + virtual void toString(StringPtr buf) const; + virtual void toString(StringPtr buf,int indentLevel) const; + protected: + PVField(PVStructure *parent,FieldConstPtr field); + void replaceStructure(); + private: + PVField();//not implemented + PVField(PVField const & ); // not implemented + PVField & operator=(PVField const &); //not implemented + class PVFieldPvt *pImpl; + static void computeOffset(const PVField * const pvField); + static void computeOffset(const PVField * const pvField,int offset); + }; class PVScalar : public PVField { public: virtual ~PVScalar(); - virtual ScalarConstPtr getScalar() const = 0; + ScalarConstPtr getScalar() const; + virtual void toString(StringPtr buf) const = 0; + virtual void toString(StringPtr buf,int indentLevel) const = 0; + protected: + PVScalar(PVStructure *parent,ScalarConstPtr scalar); + private: + PVScalar(); // not implemented + PVScalar(PVScalar const & ); // not implemented + PVScalar & operator=(PVScalar const &); //not implemented + }; + + class PVArray : public PVField, public SerializableArray { + public: + virtual ~PVArray(); + int getLength() const; + void setLength(int length); + int getCapacity() const; + epicsBoolean isCapacityImmutable() const; + void setCapacityImmutable(epicsBoolean isMutable); + virtual void setCapacity(int capacity) = 0; + virtual void serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher) const = 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(StringPtr buf) const; + virtual void toString(StringPtr buf,int indentLevel) const = 0; + protected: + PVArray(PVStructure *parent,FieldConstPtr field); + private: + PVArray(); // not implemented + PVArray(PVArray const & ); // not implemented + PVArray & operator=(PVArray const &); //not implemented + class PVArrayPvt *pImpl; + }; + + + class PVScalarArray : public PVArray { + public: + virtual ~PVScalarArray(); + ScalarArrayConstPtr getScalarArray() const; + virtual void setCapacity(int capacity) = 0; + virtual void serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher) const = 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(StringPtr buf) const = 0; + virtual void toString(StringPtr buf,int indentLevel) const = 0; + protected: + PVScalarArray(PVStructure *parent,ScalarArrayConstPtr scalarArray); + private: + PVScalarArray(); // not implemented + PVScalarArray(PVScalarArray const & ); // not implemented + PVScalarArray & operator=(PVScalarArray const &); //not implemented + }; + + typedef PVStructure * PVStructurePtr; + typedef PVStructurePtr * PVStructureArrayPtr; + + class StructureArrayData { + public: + PVStructureArrayPtr data; + int offset; + }; + + class PVStructureArray : public PVArray { + public: + virtual ~PVStructureArray(); + virtual StructureArrayConstPtr getStructureArray() const; + virtual int get(int offset, int length, + StructureArrayData *data) const; + virtual int put(int offset,int length, + PVStructureArrayPtr from, int fromOffset); + virtual void shareData(PVStructureArrayPtr from); + 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(StringPtr buf) const; + virtual void toString(StringPtr buf,int indentLevel) const; + 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; + + class PVStructure : public PVField, public BitSetSerializable { + public: + virtual ~PVStructure(); + StructureConstPtr getStructure(); + PVFieldArrayPtr getPVFields(); + PVFieldPtr getSubField(StringConstPtr fieldName); + PVFieldPtr getSubField(int fieldOffset); + void appendPVField(PVField * pvField); + void appendPVFields(PVFieldArrayPtr pvFields); + void removePVField(StringConstPtr fieldName); + PVBoolean *getBooleanField(StringConstPtr fieldName); + PVByte *getByteField(StringConstPtr fieldName); + PVShort *getShortField(StringConstPtr fieldName); + PVInt *getIntField(StringConstPtr fieldName); + PVLong *getLongField(StringConstPtr fieldName); + PVFloat *getFloatField(StringConstPtr fieldName); + PVDouble *getDoubleField(StringConstPtr fieldName); + PVString *getStringField(StringConstPtr fieldName); + PVStructure *getStructureField(StringConstPtr fieldName); + PVScalarArray *getScalarArrayField( + StringConstPtr fieldName,ScalarType elementType); + PVStructureArray *getStructureArrayField(StringConstPtr fieldName); + StringConstPtr getExtendsStructureName(); + epicsBoolean putExtendsStructureName( + StringConstPtr extendsStructureName); + virtual void toString(StringPtr buf) const; + virtual void toString(StringPtr buf,int indentLevel) const; + 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 serialize(ByteBuffer *pbuffer, + SerializableControl *pflusher,BitSet *pbitSet) const; + virtual void deserialize(ByteBuffer *pbuffer, + DeserializableControl*pflusher,BitSet *pbitSet); + protected: + PVStructure(PVStructure *parent,StructureConstPtr structure); + private: + PVStructure(); // not implemented + PVStructure(PVStructure const & ); // not implemented + PVStructure& operator=(PVStructure const &); //not implemented + class PVStructurePvt *pImpl; }; class PVBoolean : public PVScalar { @@ -82,6 +239,13 @@ namespace epics { namespace pvData { virtual ~PVBoolean(); virtual epicsBoolean get() const = 0; virtual void put(epicsBoolean value) = 0; + protected: + PVBoolean(PVStructure *parent,ScalarConstPtr scalar) + : PVScalar(parent,scalar) {} + private: + PVBoolean(); // not implemented + PVBoolean(PVBoolean const & ); // not implemented + PVBoolean & operator=(PVBoolean const &); //not implemented }; class PVByte : public PVScalar { @@ -89,6 +253,13 @@ namespace epics { namespace pvData { virtual ~PVByte(); virtual epicsInt8 get() const = 0; virtual void put(epicsInt8 value) = 0; + protected: + PVByte(PVStructure *parent,ScalarConstPtr scalar) + : PVScalar(parent,scalar) {} + private: + PVByte(); // not implemented + PVByte(PVByte const & ); // not implemented + PVByte & operator=(PVByte const &); //not implemented }; class PVShort : public PVScalar { @@ -96,6 +267,13 @@ namespace epics { namespace pvData { virtual ~PVShort(); virtual epicsInt16 get() const = 0; virtual void put(epicsInt16 value) = 0; + protected: + PVShort(PVStructure *parent,ScalarConstPtr scalar) + : PVScalar(parent,scalar) {} + private: + PVShort(); // not implemented + PVShort(PVShort const & ); // not implemented + PVShort & operator=(PVShort const &); //not implemented }; class PVInt : public PVScalar { @@ -103,6 +281,13 @@ namespace epics { namespace pvData { virtual ~PVInt(); virtual epicsInt32 get() const = 0; virtual void put(epicsInt32 value) = 0; + protected: + PVInt(PVStructure *parent,ScalarConstPtr scalar) + : PVScalar(parent,scalar) {} + private: + PVInt(); // not implemented + PVInt(PVInt const & ); // not implemented + PVInt & operator=(PVInt const &); //not implemented }; class PVLong : public PVScalar { @@ -110,6 +295,13 @@ namespace epics { namespace pvData { virtual ~PVLong(); virtual epicsInt64 get() const = 0; virtual void put(epicsInt64 value) = 0; + protected: + PVLong(PVStructure *parent,ScalarConstPtr scalar) + : PVScalar(parent,scalar) {} + private: + PVLong(); // not implemented + PVLong(PVLong const & ); // not implemented + PVLong & operator=(PVLong const &); //not implemented }; class PVFloat : public PVScalar { @@ -117,6 +309,13 @@ namespace epics { namespace pvData { virtual ~PVFloat(); virtual float get() const = 0; virtual void put(float value) = 0; + protected: + PVFloat(PVStructure *parent,ScalarConstPtr scalar) + : PVScalar(parent,scalar) {} + private: + PVFloat(); // not implemented + PVFloat(PVFloat const & ); // not implemented + PVFloat & operator=(PVFloat const &); //not implemented }; class PVDouble : public PVScalar { @@ -124,6 +323,13 @@ namespace epics { namespace pvData { virtual ~PVDouble(); virtual double get() const = 0; virtual void put(double value) = 0; + protected: + PVDouble(PVStructure *parent,ScalarConstPtr scalar) + : PVScalar(parent,scalar) {} + private: + PVDouble(); // not implemented + PVDouble(PVScalar const & ); // not implemented + PVDouble & operator=(PVScalar const &); //not implemented }; class PVString : public PVScalar { @@ -131,28 +337,243 @@ namespace epics { namespace pvData { virtual ~PVString(); virtual StringConstPtr get() const = 0; virtual void put(StringConstPtr value) = 0; + protected: + PVString(PVStructure *parent,ScalarConstPtr scalar) + : PVScalar(parent,scalar) {} + private: + PVString(); // not implemented + PVString(PVString const & ); // not implemented + PVString & operator=(PVString const &); //not implemented + }; + + typedef epicsBoolean * EpicsBooleanArrayPtr; + + class BooleanArrayData { + public: + EpicsBooleanArrayPtr data; + int offset; + }; + + class PVBooleanArray : public PVScalarArray { + public: + virtual ~PVBooleanArray(); + virtual void toString(StringPtr buf) const; + virtual void toString(StringPtr 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 deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); + protected: + PVBooleanArray(PVStructure *parent,ScalarConstPtr scalar); + private: + PVBooleanArray(); // not implemented + PVBooleanArray(PVBooleanArray const & ); // not implemented + PVBooleanArray & operator=(PVBooleanArray const &); //not implemented + }; + + typedef signed char * ByteArrayPtr; + + class ByteArrayData { + public: + ByteArrayPtr data; + int offset; + }; + + class PVByteArray : public PVScalarArray { + public: + virtual ~PVByteArray(); + virtual void toString(StringPtr buf) const; + virtual void toString(StringPtr 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 deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); + protected: + PVByteArray(PVStructure *parent,ScalarConstPtr scalar); + private: + PVByteArray(); // not implemented + PVByteArray(PVByteArray const & ); // not implemented + PVByteArray & operator=(PVByteArray const &); //not implemented + }; + + typedef short * ShortArrayPtr; + + class ShortArrayData { + public: + ShortArrayPtr data; + int offset; + }; + + class PVShortArray : public PVScalarArray { + public: + virtual ~PVShortArray(); + virtual void toString(StringPtr buf) const; + virtual void toString(StringPtr 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 deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); + protected: + PVShortArray(PVStructure *parent,ScalarConstPtr scalar); + private: + PVShortArray(); // not implemented + PVShortArray(PVShortArray const & ); // not implemented + PVShortArray & operator=(PVShortArray const &); //not implemented + }; + + typedef int * IntArrayPtr; + + class IntArrayData { + public: + IntArrayPtr data; + int offset; + }; + + class PVIntArray : public PVScalarArray { + public: + virtual ~PVIntArray(); + virtual void toString(StringPtr buf) const; + virtual void toString(StringPtr 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 deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); + protected: + PVIntArray(PVStructure *parent,ScalarConstPtr scalar); + private: + PVIntArray(); // not implemented + PVIntArray(PVIntArray const & ); // not implemented + PVIntArray & operator=(PVIntArray const &); //not implemented + }; + + typedef long * LongArrayPtr; + + class LongArrayData { + public: + LongArrayPtr data; + int offset; + }; + + class PVLongArray : public PVScalarArray { + public: + virtual ~PVLongArray(); + virtual void toString(StringPtr buf) const; + virtual void toString(StringPtr 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 deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); + protected: + PVLongArray(PVStructure *parent,ScalarConstPtr scalar); + private: + PVLongArray(); // not implemented + PVLongArray(PVLongArray const & ); // not implemented + PVLongArray & operator=(PVLongArray const &); //not implemented + }; + + + typedef float * FloatArrayPtr; + + class FloatArrayData { + public: + FloatArrayPtr data; + int offset; + }; + + class PVFloatArray : public PVScalarArray { + public: + virtual ~PVFloatArray(); + virtual void toString(StringPtr buf) const; + virtual void toString(StringPtr 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 deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); + protected: + PVFloatArray(PVStructure *parent,ScalarConstPtr scalar); + private: + PVFloatArray(); // not implemented + PVFloatArray(PVFloatArray const & ); // not implemented + PVFloatArray & operator=(PVFloatArray const &); //not implemented + }; + + typedef double * DoubleArrayPtr; + + class DoubleArrayData { + public: + DoubleArrayPtr data; + int offset; + }; + + class PVDoubleArray : public PVScalarArray { + public: + virtual ~PVDoubleArray(); + virtual void toString(StringPtr buf) const = 0; + virtual void toString(StringPtr 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 deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher) = 0; + protected: + PVDoubleArray(PVStructure *parent,ScalarArrayConstPtr scalar); + private: + PVDoubleArray(); // not implemented + PVDoubleArray(PVDoubleArray const & ); // not implemented + PVDoubleArray & operator=(PVDoubleArray const &); //not implemented + }; + + typedef std::string * StringArrayPtr; + + class StringArrayData { + public: + StringArrayPtr data; + int offset; + }; + + class PVStringArray : public PVScalarArray { + public: + virtual ~PVStringArray(); + virtual void toString(StringPtr buf) const; + virtual void toString(StringPtr 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 deserialize(ByteBuffer *pbuffer,DeserializableControl *pflusher); + protected: + PVStringArray(PVStructure *parent,ScalarConstPtr scalar); + private: + PVStringArray(); // not implemented + PVStringArray(PVStringArray const & ); // not implemented + PVStringArray & operator=(PVStringArray const &); //not implemented }; - class PVDataCreate { public: PVField *createPVField(PVStructure *parent, - FieldConstPtr field) const; + FieldConstPtr field); PVField *createPVField(PVStructure *parent, - StringConstPtr fieldName,FieldConstPtr fieldToClone) const; - PVScalar *createPVScalar(PVStructure *parent,ScalarConstPtr scalar) const; + StringConstPtr fieldName,PVField * fieldToClone); + PVScalar *createPVScalar(PVStructure *parent,ScalarConstPtr scalar); PVScalar *createPVScalar(PVStructure *parent, StringConstPtr fieldName,ScalarType scalarType); PVScalar *createPVScalar(PVStructure *parent, - StringConstPtr fieldName,ScalarConstPtr scalarToClone) const; + StringConstPtr fieldName,PVScalar * scalarToClone); PVScalarArray *createPVScalarArray(PVStructure *parent, - ScalarArrayConstPtr scalarArray) const; + ScalarArrayConstPtr scalarArray); PVScalarArray *createPVScalarArray(PVStructure *parent, StringConstPtr fieldName,ScalarType elementType); PVScalarArray *createPVScalarArray(PVStructure *parent, - StringConstPtr fieldName,ScalarArrayConstPtr scalarArrayToClone) const; + StringConstPtr fieldName,PVScalarArray * scalarArrayToClone); PVStructureArray *createPVStructureArray(PVStructure *parent, - StructureArrayConstPtr structureArray) const; + StructureArrayConstPtr structureArray); PVStructure *createPVStructure(PVStructure *parent, StructureConstPtr structure); PVStructure *createPVStructure(PVStructure *parent, diff --git a/pvDataApp/pv/requester.h b/pvDataApp/pv/requester.h index 5ff87ec..ea105e4 100644 --- a/pvDataApp/pv/requester.h +++ b/pvDataApp/pv/requester.h @@ -5,7 +5,7 @@ #include "pvIntrospect.h" namespace epics { namespace pvData { - enum MessageType {info,warning,error,fatalError}; + enum MessageType {infoMessage,warningMessage,errorMessage,fatalErrorMessage}; static std::string messageTypeName[] = {"info","warning","error","fatalError"}; diff --git a/pvDataApp/pv/serialize.h b/pvDataApp/pv/serialize.h index 6fb5cfa..48eca82 100644 --- a/pvDataApp/pv/serialize.h +++ b/pvDataApp/pv/serialize.h @@ -17,8 +17,10 @@ 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 *pbuffer, + SerializableControl *pflusher) const = 0; + virtual void deserialize(ByteBuffer *pbuffer, + DeserializableControl *pflusher) = 0; }; class BitSetSerializable { diff --git a/pvDataApp/test/Makefile b/pvDataApp/test/Makefile index 63f2dcd..5f2b0a9 100644 --- a/pvDataApp/test/Makefile +++ b/pvDataApp/test/Makefile @@ -2,7 +2,7 @@ TOP=../.. include $(TOP)/configure/CONFIG -PROD_HOST = test +PROD_HOST += test test_SRCS += test.cpp test_LIBS += pvFactory @@ -10,6 +10,10 @@ PROD_HOST += testDumpStdString testDumpStdString_SRCS += testDumpStdString.cpp testDumpStdString_LIBS += pvFactory +PROD_HOST += testPVAuxInfo +testPVAuxInfo_SRCS += testPVAuxInfo.cpp +testPVAuxInfo_LIBS += pvFactory + PROD_HOST += testPVScalar testPVScalar_SRCS += testPVScalar.cpp testPVScalar_LIBS += pvFactory diff --git a/pvDataApp/test/testPVAuxInfo.cpp b/pvDataApp/test/testPVAuxInfo.cpp new file mode 100644 index 0000000..c362d79 --- /dev/null +++ b/pvDataApp/test/testPVAuxInfo.cpp @@ -0,0 +1,51 @@ +/* testPVAuxInfo.cpp */ +/* Author: Marty Kraimer Date: 2010.09.21 */ + +#include +#include +#include +#include +#include + +#include "pvData.h" + +using namespace epics::pvData; + +static FieldCreate * fieldCreate = 0; +static PVDataCreate *pvDataCreate = 0; +static std::string theBuffer(""); +static std::string *buffer = &theBuffer; + +void testDouble() { + printf("\ntestDouble\n"); + std::string valueName("value"); + ScalarConstPtr pscalar = fieldCreate->createScalar(&valueName,pvDouble); + PVScalar *pvScalar = pvDataCreate->createPVScalar(0,pscalar); + PVDouble *pvValue = dynamic_cast(pvScalar); + double value = 2; + pvValue->put(value); + double getValue = pvValue->get(); + if(value!=getValue) { + fprintf(stderr,"ERROR getValue put %f get %f\n",value,getValue); + } + PVAuxInfo *auxInfo = pvValue->getPVAuxInfo(); + std::string stringName("string"); + pvScalar = auxInfo->createInfo(&stringName,pvDouble); + PVDouble *doubleInfo = dynamic_cast(pvScalar); + doubleInfo->put(100.0); + pvScalar = auxInfo->getInfo(&stringName); + buffer->clear(); + *buffer += "stringInfo "; + pvScalar->toString(buffer); + printf("%s\n",buffer->c_str()); + delete pvValue; +} + +int main(int argc,char *argv[]) +{ + fieldCreate = getFieldCreate(); + pvDataCreate = getPVDataCreate(); + testDouble(); + return(0); +} +