diff --git a/src/nt/ntfield.cpp b/src/nt/ntfield.cpp index ecb4575..526d694 100644 --- a/src/nt/ntfield.cpp +++ b/src/nt/ntfield.cpp @@ -8,16 +8,18 @@ #include #include +using std::tr1::static_pointer_cast; + namespace epics { namespace pvData { - - -NTField *NTField::get() +NTFieldPtr NTField::get() { static Mutex mutex; - static NTField *ntstructureField = 0; + static NTFieldPtr ntstructureField; Lock xx(mutex); - if(ntstructureField==0) ntstructureField = new NTField(); + if(ntstructureField.get()==NULL) { + ntstructureField = NTFieldPtr(new NTField()); + } return ntstructureField; } @@ -27,189 +29,195 @@ NTField::NTField() { } -bool NTField::isEnumerated(FieldConstPtr field) +bool NTField::isEnumerated(FieldConstPtr const & field) { if(field->getType()!=structure) return false; - const Structure *st = static_cast(field.get()); - FieldConstPtrArray fields = st->getFields(); - int n = st->getNumberFields(); + StructureConstPtr structurePtr = static_pointer_cast(field); + FieldConstPtrArray fields = structurePtr->getFields(); + StringArray names = structurePtr->getFieldNames(); + size_t n = structurePtr->getNumberFields(); if(n!=2) return false; FieldConstPtr f = fields[0]; - if(f->getFieldName().compare("index")!=0) return false; + if(names[0].compare("index")!=0) return false; if(f->getType()!=scalar) return false; - const Scalar* s = static_cast(f.get()); + ScalarConstPtr s = static_pointer_cast(f); if(s->getScalarType()!=pvInt) return false; f = fields[1]; - if(f->getFieldName().compare("choices")!=0) return false; + if(names[1].compare("choices")!=0) return false; if(f->getType()!=scalarArray) return false; - const ScalarArray* sa = static_cast(f.get()); - if(sa->getElementType()!=pvString) return false; + ScalarConstPtr sa = static_pointer_cast(f); + if(sa->getScalarType()!=pvString) return false; return true; } -bool NTField::isTimeStamp(FieldConstPtr field) +bool NTField::isTimeStamp(FieldConstPtr const & field) { if(field->getType()!=structure) return false; - const Structure *st = static_cast(field.get()); - if(field->getFieldName().compare("timeStamp")!=0) return false; - FieldConstPtrArray fields = st->getFields(); - int n = st->getNumberFields(); + StructureConstPtr structurePtr = static_pointer_cast(field); + FieldConstPtrArray fields = structurePtr->getFields(); + StringArray names = structurePtr->getFieldNames(); + size_t n = structurePtr->getNumberFields(); if(n!=3) return false; FieldConstPtr f = fields[0]; - if(f->getFieldName().compare("secondsPastEpoch")!=0) return false; + if(names[0].compare("secondsPastEpoch")!=0) return false; if(f->getType()!=scalar) return false; - const Scalar* s = static_cast(f.get()); + ScalarConstPtr s = static_pointer_cast(f); if(s->getScalarType()!=pvLong) return false; f = fields[1]; - if(f->getFieldName().compare("nanoSeconds")!=0) return false; + if(names[1].compare("nanoSeconds")!=0) return false; if(f->getType()!=scalar) return false; - s = static_cast(f.get()); + s = static_pointer_cast(f); if(s->getScalarType()!=pvInt) return false; f = fields[2]; - if(f->getFieldName().compare("userTag")!=0) return false; + if(names[2].compare("userTag")!=0) return false; if(f->getType()!=scalar) return false; - s = static_cast(f.get()); + s = static_pointer_cast(f); if(s->getScalarType()!=pvInt) return false; return true; } -bool NTField::isAlarm(FieldConstPtr field) +bool NTField::isAlarm(FieldConstPtr const & field) { if(field->getType()!=structure) return false; - const Structure *st = static_cast(field.get()); - if(field->getFieldName().compare("alarm")!=0) return false; - FieldConstPtrArray fields = st->getFields(); - int n = st->getNumberFields(); + StructureConstPtr structurePtr = static_pointer_cast(field); + FieldConstPtrArray fields = structurePtr->getFields(); + StringArray names = structurePtr->getFieldNames(); + size_t n = structurePtr->getNumberFields(); if(n!=3) return false; FieldConstPtr f = fields[0]; - if(f->getFieldName().compare("severity")!=0) return false; + if(names[0].compare("severity")!=0) return false; if(f->getType()!=scalar) return false; - const Scalar* s = static_cast(f.get()); + ScalarConstPtr s = static_pointer_cast(f); if(s->getScalarType()!=pvInt) return false; f = fields[1]; - if(f->getFieldName().compare("status")!=0) return false; + if(names[1].compare("status")!=0) return false; if(f->getType()!=scalar) return false; - s = static_cast(f.get()); + s = static_pointer_cast(f); if(s->getScalarType()!=pvInt) return false; f = fields[2]; - if(f->getFieldName().compare("message")!=0) return false; + if(names[2].compare("message")!=0) return false; if(f->getType()!=scalar) return false; - s = static_cast(f.get()); + s = static_pointer_cast(f); if(s->getScalarType()!=pvString) return false; return true; } -bool NTField::isDisplay(FieldConstPtr field) +bool NTField::isDisplay(FieldConstPtr const & field) { if(field->getType()!=structure) return false; - const Structure *st = static_cast(field.get()); - if(field->getFieldName().compare("display")!=0) return false; - FieldConstPtrArray fields = st->getFields(); - int n = st->getNumberFields(); - if(n!=4) return false; - // look at limit first - FieldConstPtr f = fields[3]; - if(f->getFieldName().compare("limit")!=0) return false; - if(f->getType()!=structure) return false; - const Structure* s = static_cast(f.get()); - FieldConstPtrArray subfields = s->getFields(); - n = s->getNumberFields(); - if(n!=2) return false; - f = subfields[0]; - if(f->getFieldName().compare("low")!=0) return false; - if(f->getType()!=scalar) return false; - const Scalar* sc = static_cast(f.get()); - if(sc->getScalarType()!=pvDouble) return false; - f = subfields[1]; - if(f->getFieldName().compare("high")!=0) return false; - if(f->getType()!=scalar) return false; - sc = static_cast(f.get()); - if(sc->getScalarType()!=pvDouble) return false; - f = fields[0]; - if(f->getFieldName().compare("description")!=0) return false; - if(f->getType()!=scalar) return false; - sc = static_cast(f.get()); - if(sc->getScalarType()!=pvString) return false; - f = fields[1]; - if(f->getFieldName().compare("format")!=0) return false; - if(f->getType()!=scalar) return false; - sc = static_cast(f.get()); - if(sc->getScalarType()!=pvString) return false; - f = fields[2]; - if(f->getFieldName().compare("units")!=0) return false; - if(f->getType()!=scalar) return false; - sc = static_cast(f.get()); - if(sc->getScalarType()!=pvString) return false; - return true; -} - -bool NTField::isAlarmLimit(FieldConstPtr field) -{ - if(field->getType()!=structure) return false; - const Structure *st = static_cast(field.get()); - if(field->getFieldName().compare("alarmLimit")!=0) return false; - FieldConstPtrArray fields = st->getFields(); - int n = st->getNumberFields(); - if(n!=4) return false; + StructureConstPtr structurePtr = static_pointer_cast(field); + FieldConstPtrArray fields = structurePtr->getFields(); + StringArray names = structurePtr->getFieldNames(); + size_t n = structurePtr->getNumberFields(); + if(n!=5) return false; FieldConstPtr f = fields[0]; - if(f->getFieldName().compare("highAlarm")!=0) return false; + if(names[0].compare("limitLow")!=0) return false; if(f->getType()!=scalar) return false; - const Scalar *sc = static_cast(f.get()); - if(sc->getScalarType()!=pvDouble) return false; + ScalarConstPtr s = static_pointer_cast(f); + if(s->getScalarType()!=pvDouble) return false; f = fields[1]; - if(f->getFieldName().compare("highWarning")!=0) return false; + if(names[1].compare("limitHigh")!=0) return false; if(f->getType()!=scalar) return false; - sc = static_cast(f.get()); - if(sc->getScalarType()!=pvDouble) return false; + s = static_pointer_cast(f); + if(s->getScalarType()!=pvDouble) return false; f = fields[2]; - if(f->getFieldName().compare("lowWarning")!=0) return false; + if(names[2].compare("description")!=0) return false; if(f->getType()!=scalar) return false; - sc = static_cast(f.get()); - if(sc->getScalarType()!=pvDouble) return false; + s = static_pointer_cast(f); + if(s->getScalarType()!=pvString) return false; f = fields[3]; - if(f->getFieldName().compare("lowAlarm")!=0) return false; + if(names[3].compare("format")!=0) return false; if(f->getType()!=scalar) return false; - sc = static_cast(f.get()); - if(sc->getScalarType()!=pvDouble) return false; + s = static_pointer_cast(f); + if(s->getScalarType()!=pvString) return false; + f = fields[4]; + if(names[4].compare("units")!=0) return false; + if(f->getType()!=scalar) return false; + s = static_pointer_cast(f); + if(s->getScalarType()!=pvString) return false; return true; } -bool NTField::isControl(FieldConstPtr field) +bool NTField::isAlarmLimit(FieldConstPtr const & field) { if(field->getType()!=structure) return false; - const Structure *st = static_cast(field.get()); - if(field->getFieldName().compare("control")!=0) return false; - FieldConstPtrArray fields = st->getFields(); - int n = st->getNumberFields(); - if(n!=2) return false; - FieldConstPtr f = fields[1]; - if(f->getFieldName().compare("minStep")!=0) return false; + StructureConstPtr structurePtr = static_pointer_cast(field); + FieldConstPtrArray fields = structurePtr->getFields(); + StringArray names = structurePtr->getFieldNames(); + size_t n = structurePtr->getNumberFields(); + if(n!=10) return false; + FieldConstPtr f = fields[0]; + if(names[0].compare("active")!=0) return false; if(f->getType()!=scalar) return false; - const Scalar* sc = static_cast(f.get()); - if(sc->getScalarType()!=pvDouble) return false; - f = fields[0]; - if(f->getFieldName().compare("limit")!=0) return false; - if(f->getType()!=structure) return false; - const Structure* s = static_cast(f.get()); - fields = s->getFields(); - n = s->getNumberFields(); - if(n!=2) return false; - f = fields[0]; - if(f->getFieldName().compare("low")!=0) return false; - if(f->getType()!=scalar) return false; - sc = static_cast(f.get()); - if(sc->getScalarType()!=pvDouble) return false; + ScalarConstPtr s = static_pointer_cast(f); + if(s->getScalarType()!=pvDouble) return false; f = fields[1]; - if(f->getFieldName().compare("high")!=0) return false; + if(names[1].compare("lowAlarmLimit")!=0) return false; + if(f->getType()!=scalar) return false; + f = fields[2]; + if(names[2].compare("lowWarningLimit")!=0) return false; + if(f->getType()!=scalar) return false; + f = fields[3]; + if(names[3].compare("highWarningLimit")!=0) return false; + if(f->getType()!=scalar) return false; + f = fields[4]; + if(names[4].compare("highAlarmLimit")!=0) return false; + if(f->getType()!=scalar) return false; + f = fields[5]; + if(names[5].compare("lowAlarmSeverity")!=0) return false; + if(f->getType()!=scalar) return false; + s = static_pointer_cast(f); + if(s->getScalarType()!=pvInt) return false; + f = fields[6]; + if(names[6].compare("lowWarningSeverity")!=0) return false; + if(f->getType()!=scalar) return false; + s = static_pointer_cast(f); + if(s->getScalarType()!=pvInt) return false; + f = fields[7]; + if(names[7].compare("highWarningSeverity")!=0) return false; + if(f->getType()!=scalar) return false; + s = static_pointer_cast(f); + if(s->getScalarType()!=pvInt) return false; + f = fields[8]; + if(names[8].compare("highAlarmSeverity")!=0) return false; + if(f->getType()!=scalar) return false; + s = static_pointer_cast(f); + if(s->getScalarType()!=pvInt) return false; + f = fields[9]; + if(names[9].compare("hystersis")!=0) return false; if(f->getType()!=scalar) return false; - sc = static_cast(f.get()); - if(sc->getScalarType()!=pvDouble) return false; return true; } -StructureConstPtr NTField::createEnumerated(String fieldName) +bool NTField::isControl(FieldConstPtr const & field) { - return standardField->enumerated(fieldName); + if(field->getType()!=structure) return false; + StructureConstPtr structurePtr = static_pointer_cast(field); + FieldConstPtrArray fields = structurePtr->getFields(); + StringArray names = structurePtr->getFieldNames(); + size_t n = structurePtr->getNumberFields(); + if(n!=3) return false; + FieldConstPtr f = fields[0]; + if(names[0].compare("limitLow")!=0) return false; + if(f->getType()!=scalar) return false; + ScalarConstPtr s = static_pointer_cast(f); + if(s->getScalarType()!=pvDouble) return false; + f = fields[1]; + if(names[1].compare("limitHigh")!=0) return false; + if(f->getType()!=scalar) return false; + s = static_pointer_cast(f); + if(s->getScalarType()!=pvDouble) return false; + f = fields[2]; + if(names[2].compare("minStep")!=0) return false; + if(f->getType()!=scalar) return false; + s = static_pointer_cast(f); + if(s->getScalarType()!=pvDouble) return false; + return true; +} + +StructureConstPtr NTField::createEnumerated() +{ + return standardField->enumerated(); } StructureConstPtr NTField::createTimeStamp() @@ -229,13 +237,7 @@ StructureConstPtr NTField::createDisplay() StructureConstPtr NTField::createAlarmLimit() { - int numFields = 4; - FieldConstPtrArray fields = new FieldConstPtr[numFields]; - fields[0] = fieldCreate->createScalar(String("highAlarm"),pvDouble); - fields[1] = fieldCreate->createScalar(String("highWarning"),pvDouble); - fields[2] = fieldCreate->createScalar(String("lowWarning"),pvDouble); - fields[3] = fieldCreate->createScalar(String("lowAlarm"),pvDouble); - return fieldCreate->createStructure(String("alarmLimit"),numFields,fields); + return standardField->doubleAlarm(); } StructureConstPtr NTField::createControl() @@ -243,35 +245,37 @@ StructureConstPtr NTField::createControl() return standardField->control(); } -StructureArrayConstPtr NTField::createEnumeratedArray(String fieldName) +StructureArrayConstPtr NTField::createEnumeratedArray() { - StructureConstPtr st = createEnumerated(fieldName); - return fieldCreate->createStructureArray(fieldName,st); + return fieldCreate->createStructureArray(createEnumerated()); } -StructureArrayConstPtr NTField::createTimeStampArray(String fieldName) +StructureArrayConstPtr NTField::createTimeStampArray() { StructureConstPtr st = createTimeStamp(); - return fieldCreate->createStructureArray(fieldName,st); + return fieldCreate->createStructureArray(st); } -StructureArrayConstPtr NTField::createAlarmArray(String fieldName) +StructureArrayConstPtr NTField::createAlarmArray() { StructureConstPtr st = createAlarm(); - return fieldCreate->createStructureArray(fieldName,st); + return fieldCreate->createStructureArray(st); } -PVNTField *PVNTField::get() +PVNTFieldPtr PVNTField::get() { static Mutex mutex; - static PVNTField *pvntstructureField = 0; + static PVNTFieldPtr pvntstructureField; Lock xx(mutex); - if(pvntstructureField==0) pvntstructureField = new PVNTField(); + if(pvntstructureField.get()==NULL) { + pvntstructureField = PVNTFieldPtr(new PVNTField()); + } return pvntstructureField; } PVNTField::PVNTField() : pvDataCreate(getPVDataCreate()), + standardField(getStandardField()), standardPVField(getStandardPVField()), ntstructureField(NTField::get()) { @@ -279,60 +283,60 @@ PVNTField::PVNTField() PVStructurePtr PVNTField::createEnumerated( - PVStructurePtr parent, - String fieldName, - StringArray choices, - int numberChoices) + StringArray const & choices) { - return standardPVField->enumerated(parent,fieldName,choices,numberChoices); + return standardPVField->enumerated(choices); } -PVStructurePtr PVNTField::createTimeStamp(PVStructurePtr parent) +PVStructurePtr PVNTField::createTimeStamp() { - return standardPVField->timeStamp(parent); + StructureConstPtr timeStamp = standardField->timeStamp(); + return pvDataCreate->createPVStructure(timeStamp); } -PVStructurePtr PVNTField::createAlarm(PVStructurePtr parent) +PVStructurePtr PVNTField::createAlarm() { - return standardPVField->alarm(parent); + StructureConstPtr alarm = standardField->alarm(); + return pvDataCreate->createPVStructure(alarm); } -PVStructurePtr PVNTField::createDisplay(PVStructurePtr parent) +PVStructurePtr PVNTField::createDisplay() { - return standardPVField->display(parent); + StructureConstPtr display = standardField->display(); + return pvDataCreate->createPVStructure(display); } -PVStructurePtr PVNTField::createAlarmLimit(PVStructurePtr parent) +PVStructurePtr PVNTField::createAlarmLimit() { StructureConstPtr structure = NTField::get()->createAlarmLimit(); - return pvDataCreate->createPVStructure(parent,structure); + return pvDataCreate->createPVStructure(structure); } -PVStructurePtr PVNTField::createControl(PVStructurePtr parent) +PVStructurePtr PVNTField::createControl() { - return standardPVField->control(parent); + StructureConstPtr control = standardField->control(); + return pvDataCreate->createPVStructure(control); } -PVStructureArray *PVNTField::createEnumeratedArray( - PVStructurePtr parent,String fieldName) +PVStructureArrayPtr PVNTField::createEnumeratedArray() { - StructureArrayConstPtr sa = ntstructureField->createEnumeratedArray(fieldName); - return pvDataCreate->createPVStructureArray(parent,sa); + StructureArrayConstPtr sa = + ntstructureField->createEnumeratedArray(); + return pvDataCreate->createPVStructureArray(sa); } -PVStructureArray *PVNTField::createTimeStampArray( - PVStructurePtr parent,String fieldName) +PVStructureArrayPtr PVNTField::createTimeStampArray() { - StructureArrayConstPtr sa = ntstructureField->createTimeStampArray(fieldName); - return pvDataCreate->createPVStructureArray(parent,sa); + StructureArrayConstPtr sa = + ntstructureField->createTimeStampArray(); + return pvDataCreate->createPVStructureArray(sa); } -PVStructureArray *PVNTField::createAlarmArray( - PVStructurePtr parent,String fieldName) +PVStructureArrayPtr PVNTField::createAlarmArray() { - StructureArrayConstPtr sa = ntstructureField->createAlarmArray(fieldName); - return pvDataCreate->createPVStructureArray(parent,sa); + StructureArrayConstPtr sa = ntstructureField->createAlarmArray(); + return pvDataCreate->createPVStructureArray(sa); } }} diff --git a/src/nt/ntfield.h b/src/nt/ntfield.h index b495d40..e7fc73f 100644 --- a/src/nt/ntfield.h +++ b/src/nt/ntfield.h @@ -22,13 +22,23 @@ namespace epics { namespace pvData { * @author mrk * */ -class NTField: NoDefaultMethods { + +typedef std::tr1::shared_ptr StringArrayPtr; + +class NTField; +typedef std::tr1::shared_ptr NTFieldPtr; + +class PVNTField; +typedef std::tr1::shared_ptr PVNTFieldPtr; + +class NTField { public: + POINTER_DEFINITIONS(NTField); /** * get the single implementation of this class. * @return the implementation */ - static NTField * get(); + static NTFieldPtr get(); /** * destructor */ @@ -38,44 +48,43 @@ public: * @param field The field to test. * @return (false,true) if field (is not,is) an enumerated structure. */ - bool isEnumerated(FieldConstPtr field); + bool isEnumerated(FieldConstPtr const & field); /** * Is field a timeStamp structure. * @param field The field to test. * @return (false,true) if field (is not,is) a timeStamp structure. */ - bool isTimeStamp(FieldConstPtr field); + bool isTimeStamp(FieldConstPtr const & field); /** * Is field an alarm structure. * @param field The field to test. * @return (false,true) if field (is not,is) an alarm structure. */ - bool isAlarm(FieldConstPtr field); + bool isAlarm(FieldConstPtr const & field); /** * Is field a display structure. * @param field The field to test. * @return (false,true) if field (is not,is) a display structure. */ - bool isDisplay(FieldConstPtr field); + bool isDisplay(FieldConstPtr const & field); /** * Is field an alarmLimit structure. * @param field The field to test. * @return (false,true) if field (is not,is) an alarmLimit structure. */ - bool isAlarmLimit(FieldConstPtr field); + bool isAlarmLimit(FieldConstPtr const & field); /** * Is field a control structure. * @param field The field to test. * @return (false,true) if field (is not,is) a control structure. */ - bool isControl(FieldConstPtr field); + bool isControl(FieldConstPtr const & field); /** * Create an enumerated structure. - * @param fieldName The fieldName for the structure. * @return an enumerated structure. */ - StructureConstPtr createEnumerated(String fieldName); + StructureConstPtr createEnumerated(); /** * Create a timeStamp structure. * @return a timeStamp structure. @@ -104,26 +113,23 @@ public: /** * Create an array of enumerated structures. - * @param fieldName The fieldName for the array. * @return an array of enumerated structures. */ - StructureArrayConstPtr createEnumeratedArray(String fieldName); + StructureArrayConstPtr createEnumeratedArray(); /** * Create an array of timeStamp structures. - * @param fieldName The fieldName for the array. * @return an array of timeStamp structures. */ - StructureArrayConstPtr createTimeStampArray(String fieldName); + StructureArrayConstPtr createTimeStampArray(); /** * Create an array of alarm structures. - * @param fieldName The fieldName for the array. * @return an array of alarm structures. */ - StructureArrayConstPtr createAlarmArray(String fieldName); + StructureArrayConstPtr createAlarmArray(); private: NTField(); - FieldCreate *fieldCreate; - StandardField *standardField; + FieldCreatePtr fieldCreate; + StandardFieldPtr standardField; }; /** @@ -131,90 +137,72 @@ private: * @author mrk * */ -class PVNTField: NoDefaultMethods { +class PVNTField { public: + POINTER_DEFINITIONS(PVNTField); /** * get the single implementation of this class. * @return the implementation */ - static PVNTField * get(); + static PVNTFieldPtr get(); /** * destructor */ ~PVNTField() {} /** * Create an enumerated PVStructure. - * @param parent The parent structure. - * @param fieldName The fieldName for the structure. * @param choices The array of choices. - * @param numberChoices The number of choices. * @return an enumerated PVStructure.. */ PVStructurePtr createEnumerated( - PVStructurePtr parent, - String fieldName, - StringArray choices, - int numberChoices); + StringArray const & choices); /** * Create a timeStamp PVStructure. - * @param parent The parent structure. * @return a timeStamp PVStructure.. */ - PVStructurePtr createTimeStamp(PVStructurePtr parent); + PVStructurePtr createTimeStamp(); /** * Create an alarm PVStructure. - * @param parent The parent structure. * @return an alarm PVStructure.. */ - PVStructurePtr createAlarm(PVStructurePtr parent); + PVStructurePtr createAlarm(); /** * Create a display PVStructure. - * @param parent The parent structure. * @return a display PVStructure.. */ - PVStructurePtr createDisplay(PVStructurePtr parent); + PVStructurePtr createDisplay(); /** * Create an alarmLimit PVStructure. - * @param parent The parent structure. * @return an alarmLimit PVStructure.. */ - PVStructurePtr createAlarmLimit(PVStructurePtr parent); + PVStructurePtr createAlarmLimit(); /** * Create a control PVStructure. - * @param parent The parent structure. * @return a control PVStructure.. */ - PVStructurePtr createControl(PVStructurePtr parent); + PVStructurePtr createControl(); /** * Create an enumerated PVStructureArray. - * @param parent The parent structure. - * @param fieldName The fieldName for the structure. * @return an enumerated PVStructureArray.. */ - PVStructureArray * createEnumeratedArray( - PVStructurePtr parent,String fieldName); + PVStructureArrayPtr createEnumeratedArray(); /** * Create a timeStamp PVStructureArray. - * @param parent The parent structure. - * @param fieldName The fieldName for the structure. * @return a timeStamp PVStructureArray */ - PVStructureArray * createTimeStampArray( - PVStructurePtr parent,String fieldName); + PVStructureArrayPtr createTimeStampArray(); /** * Create an alarm PVStructureArray. - * @param parent The parent structure. - * @param fieldName The fieldName for the structure. * @return an alarm PVStructureArray.. */ - PVStructureArray * createAlarmArray( - PVStructurePtr parent,String fieldName); + PVStructureArrayPtr createAlarmArray(); private: PVNTField(); - PVDataCreate *pvDataCreate; - StandardPVField *standardPVField; - NTField *ntstructureField; + PVDataCreatePtr pvDataCreate; + StandardFieldPtr standardField; + StandardPVFieldPtr standardPVField; + NTFieldPtr ntstructureField; }; }} diff --git a/src/nt/ntnameValue.h b/src/nt/ntnameValue.h index 81f2257..c4256d3 100644 --- a/src/nt/ntnameValue.h +++ b/src/nt/ntnameValue.h @@ -17,6 +17,9 @@ namespace epics { namespace pvData { * */ +class NTNameValue +typedef std::tr1::shared_ptr NTNameValuePtr; + class NTNameValue { public: @@ -26,7 +29,7 @@ public: * @param pvStructure The pvStructure to test. * @return (false,true) if (is not, is) an NTNameValue. */ - static bool isNTNameValue(PVStructurePtr pvStructure); + static bool isNTNameValue(PVStructurePtr const & pvStructure); /** * Create an NTNameValue pvStructure. * @param hasFunction Create a PVString field named function. @@ -34,14 +37,14 @@ public: * @param hasAlarm Create an alarm structure field. * @return a NTNameValue pvStructure. */ - static PVStructure::shared_pointer create( + static PVStructurePtr create( bool hasFunction,bool hasTimeStamp, bool hasAlarm); /** * Constructor * @param pvStructure The pvStructure to which to attach. * @return A NTNameValue that is attached to the pvStructure */ - NTNameValue(PVStructure::shared_pointer const & pvStructure); + NTNameValue(PVStructurePtr const & pvStructure); /** * Destructor */ @@ -50,7 +53,7 @@ public: * Get the function field. * @return The pvString or null if no function field. */ - PVString* getFunction(); + PVStringPtr getFunction(); /** * Attach a pvTimeStamp. * @param pvTimeStamp The pvTimeStamp that will be attached. @@ -67,7 +70,7 @@ public: * Get the pvStructure. * @return PVStructurePtr. */ - PVStructurePtr getPVStructure(){return pvNTNameValue.get();} + PVStructurePtr getPVStructure(){return pvNTNameValue;} /** * Get the timeStamp. * @return PVStructurePtr which may be null. @@ -82,19 +85,19 @@ public: * Get the string array on names. * @return The array of names. */ - PVStringArray *getNames(); + PVStringArrayPtr getNames(); /** * Get the string array on values. * @return The array of values. */ - PVStringArray *getValues(); + PVStringArrayPtr getValues(); private: - PVStructure::shared_pointer pvNTNameValue; - PVString * pvFunction; + PVStructurePtr pvNTNameValue; + PVStringPtr pvFunction; PVStructurePtr pvTimeStamp; PVStructurePtr pvAlarm; - PVStringArray *pvNames; - PVStringArray *pvValues; + PVStringArrayPtr pvNames; + PVStringArrayPtr pvValues; }; }} diff --git a/src/nt/nttable.h b/src/nt/nttable.h index b3ac1e3..dd7e54f 100644 --- a/src/nt/nttable.h +++ b/src/nt/nttable.h @@ -17,6 +17,9 @@ namespace epics { namespace pvData { * */ +class NTTable +typedef std::tr1::shared_ptr NTTablePtr; + class NTTable { public: @@ -26,7 +29,7 @@ public: * @param pvStructure The pvStructure to test. * @return (false,true) if (is not, is) an NTNameValuePair. */ - static bool isNTTable(PVStructurePtr pvStructure); + static bool isNTTable(PVStructurePtr const &pvStructure); /** * Create an NTTable pvStructure. * @param hasFunction Create a PVString field named function. @@ -36,16 +39,16 @@ public: * @param valueFields The fields that follow the label field. * @return an NTTable pvStructure. */ - static PVStructure::shared_pointer create( + static PVStructurePtr create( bool hasFunction,bool hasTimeStamp, bool hasAlarm, - int numberValues, - FieldConstPtrArray valueFields); + size_t numberValues, + FieldConstPtrArray const &valueFields); /** * Constructor * @param pvStructure The pvStructure to which to attach. * @return A NTTable that is attached to the pvStructure */ - NTTable(PVStructure::shared_pointer const & pvStructure); + NTTable(PVStructurePtr const & pvStructure); /** * Destructor */ @@ -54,7 +57,7 @@ public: * Get the function field. * @return The pvString or null if no function field. */ - PVString *getFunction(); + PVStringPtr getFunction(); /** * Attach a pvTimeStamp. * @param pvTimeStamp The pvTimeStamp that will be attached. @@ -71,7 +74,7 @@ public: * Get the pvStructure. * @return PVStructurePtr. */ - PVStructurePtr getPVStructure(){return pvNTTable.get();} + PVStructurePtr getPVStructure(){return pvNTTable;} /** * Get the timeStamp. * @return PVStructurePtr which may be null. @@ -86,7 +89,7 @@ public: * Get the label field. * @return The pvStringArray for the label. */ - PVStringArray *getLabel(); + PVStringArrayPtr getLabel(); /** * Get the the number of fields that follow the label field. * @return The number of fields. @@ -105,12 +108,12 @@ public: */ PVFieldPtr getPVField(int index); private: - PVStructure::shared_pointer pvNTTable; - PVString *pvFunction; + PVStructurePtr pvNTTable; + PVStringPtr pvFunction; PVStructurePtr pvTimeStamp; PVStructurePtr pvAlarm; - PVStringArray *pvLabel; - int offsetFields; + PVStringArrayPtr pvLabel; + size_t offsetFields; }; }}