From 0af5599457b1d37683c938dbee18a6807469e806 Mon Sep 17 00:00:00 2001 From: Dave Hickin Date: Fri, 24 Jul 2015 15:00:25 +0100 Subject: [PATCH 1/2] Remove calls of deprecated getScalarArrayField --- pvtoolsSrc/eget.cpp | 8 ++++---- src/ca/caChannel.cpp | 18 ++++++------------ testApp/remote/testServer.cpp | 4 ++-- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/pvtoolsSrc/eget.cpp b/pvtoolsSrc/eget.cpp index 910a77d..fd96c1a 100644 --- a/pvtoolsSrc/eget.cpp +++ b/pvtoolsSrc/eget.cpp @@ -328,7 +328,7 @@ void formatTable(std::ostream& o, void formatNTTable(std::ostream& o, PVStructurePtr const & pvStruct) { - PVStringArrayPtr labels = dynamic_pointer_cast(pvStruct->getScalarArrayField("labels", pvString)); + PVStringArrayPtr labels = pvStruct->getSubField("labels"); if (labels.get() == 0) { std::cerr << "no string[] 'labels' field in NTTable" << std::endl; @@ -371,7 +371,7 @@ void formatNTTable(std::ostream& o, PVStructurePtr const & pvStruct) void formatNTMatrix(std::ostream& o, PVStructurePtr const & pvStruct) { - PVDoubleArrayPtr value = dynamic_pointer_cast(pvStruct->getScalarArrayField("value", pvDouble)); + PVDoubleArrayPtr value = pvStruct->getSubField("value"); if (value.get() == 0) { std::cerr << "no double[] 'value' field in NTMatrix" << std::endl; @@ -380,7 +380,7 @@ void formatNTMatrix(std::ostream& o, PVStructurePtr const & pvStruct) int32 rows, cols; - PVIntArrayPtr dim = dynamic_pointer_cast(pvStruct->getScalarArrayField("dim", pvInt)); + PVIntArrayPtr dim = pvStruct->getSubField("dim"); if (dim.get() != 0) { // dim[] = { rows, columns } @@ -479,7 +479,7 @@ void formatNTMatrix(std::ostream& o, PVStructurePtr const & pvStruct) // TODO use formatNTTable void formatNTNameValue(std::ostream& o, PVStructurePtr const & pvStruct) { - PVStringArrayPtr name = dynamic_pointer_cast(pvStruct->getScalarArrayField("name", pvString)); + PVStringArrayPtr name = pvStruct->getSubField("name"); if (name.get() == 0) { std::cerr << "no string[] 'name' field in NTNameValue" << std::endl; diff --git a/src/ca/caChannel.cpp b/src/ca/caChannel.cpp index 10c8468..66403a6 100644 --- a/src/ca/caChannel.cpp +++ b/src/ca/caChannel.cpp @@ -107,8 +107,7 @@ static PVStructure::shared_pointer createPVStructure(CAChannel::shared_pointer c PVStructure::shared_pointer pvStructure = getPVDataCreate()->createPVStructure(createStructure(channel, properties)); if (channel->getNativeType() == DBR_ENUM) { - - PVScalarArrayPtr pvScalarArray = pvStructure->getScalarArrayField("value.choices", pvString); + PVScalarArrayPtr pvScalarArray = pvStructure->getSubField("value.choices"); // TODO avoid getting labels if DBR_GR_ENUM or DBR_CTRL_ENUM is used in subsequent get int result = ca_array_get_callback(DBR_GR_ENUM, 1, channel->getChannelID(), ca_get_labels_handler, pvScalarArray.get()); @@ -569,8 +568,7 @@ void copy_DBR(const void * dbr, unsigned count, PVStructure::shared_pointer cons } else { - std::tr1::shared_ptr value = - std::tr1::static_pointer_cast(pvStructure->getScalarArrayField("value", sT)); + std::tr1::shared_ptr value = pvStructure->getSubField("value"); typename aF::svector temp(value->reuse()); temp.resize(count); std::copy(static_cast(dbr), static_cast(dbr) + count, temp.begin()); @@ -591,8 +589,7 @@ void copy_DBR(const void * dbr, unsigned c } else { - std::tr1::shared_ptr value = - std::tr1::static_pointer_cast(pvStructure->getScalarArrayField("value", pvInt)); + std::tr1::shared_ptr value = pvStructure->getSubField("value"); PVIntArray::svector temp(value->reuse()); temp.resize(count); std::copy(static_cast(dbr), static_cast(dbr) + count, temp.begin()); @@ -612,8 +609,7 @@ void copy_DBR(const void * dbr, unsig } else { - std::tr1::shared_ptr value = - std::tr1::static_pointer_cast(pvStructure->getScalarArrayField("value", pvString)); + std::tr1::shared_ptr value = pvStructure->getSubField("value"); const dbr_string_t* dbrStrings = static_cast(dbr); PVStringArray::svector sA(value->reuse()); sA.resize(count); @@ -1022,8 +1018,7 @@ int doPut_pvStructure(CAChannel::shared_pointer const & channel, void *usrArg, P } else { - std::tr1::shared_ptr value = - std::tr1::static_pointer_cast(pvStructure->getScalarArrayField("value", sT)); + std::tr1::shared_ptr value = pvStructure->getSubField("value"); const pT* val = value->view().data(); int result = ca_array_put_callback(channel->getNativeType(), static_cast(value->getLength()), @@ -1063,8 +1058,7 @@ int doPut_pvStructure(CAChannel::shar } else { - std::tr1::shared_ptr value = - std::tr1::static_pointer_cast(pvStructure->getScalarArrayField("value", pvString)); + std::tr1::shared_ptr value = pvStructure->getSubField("value"); PVStringArray::const_svector stringArray(value->view()); diff --git a/testApp/remote/testServer.cpp b/testApp/remote/testServer.cpp index 58d65ad..cacbb26 100644 --- a/testApp/remote/testServer.cpp +++ b/testApp/remote/testServer.cpp @@ -381,7 +381,7 @@ static epics::pvData::PVStructure::shared_pointer createNTHistogram() static void generateNTTableDoubleValues(epics::pvData::PVStructure::shared_pointer result) { - PVStringArray::shared_pointer pvLabels = (static_pointer_cast(result->getScalarArrayField("labels", pvString))); + PVStringArray::shared_pointer pvLabels = result->getSubField("labels"); PVStringArray::const_svector ld(pvLabels->view()); PVStructure::shared_pointer resultValue = result->getSubField("value"); @@ -2110,7 +2110,7 @@ protected: string allProperties(""); // string allProperties("alarm,timeStamp,display,control"); m_pvStructure = getStandardPVField()->scalarArray(pvDouble,allProperties); - PVDoubleArrayPtr pvField = static_pointer_cast(m_pvStructure->getScalarArrayField(std::string("value"), pvDouble)); + PVDoubleArrayPtr pvField = m_pvStructure->getSubField("value"); int specCount = 0; char postfix[64]; int done = sscanf(m_name.c_str(), "testArray%d%s", &specCount, postfix); From f983e34d4e4bae7eeb284b7c1374cc43f3f8025d Mon Sep 17 00:00:00 2001 From: Dave Hickin Date: Fri, 24 Jul 2015 15:22:41 +0100 Subject: [PATCH 2/2] Remove unused template parameter in copy_DBR functions --- src/ca/caChannel.cpp | 114 +++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/ca/caChannel.cpp b/src/ca/caChannel.cpp index 66403a6..fa385a8 100644 --- a/src/ca/caChannel.cpp +++ b/src/ca/caChannel.cpp @@ -557,8 +557,8 @@ static void ca_get_handler(struct event_handler_args args) typedef void (*copyDBRtoPVStructure)(const void * from, unsigned count, PVStructure::shared_pointer const & to); -// template -template +// template +template void copy_DBR(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) { if (count == 1) @@ -578,9 +578,9 @@ void copy_DBR(const void * dbr, unsigned count, PVStructure::shared_pointer cons #if defined(__vxworks) || defined(__rtems__) // dbr_long_t is defined as "int", pvData uses int32 which can be defined as "long int" (32-bit) -// template +// template template<> -void copy_DBR(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) +void copy_DBR(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) { if (count == 1) { @@ -600,7 +600,7 @@ void copy_DBR(const void * dbr, unsigned c // string specialization template<> -void copy_DBR(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) +void copy_DBR(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) { if (count == 1) { @@ -620,7 +620,7 @@ void copy_DBR(const void * dbr, unsig // enum specialization template<> -void copy_DBR(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) +void copy_DBR(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) { if (count == 1) { @@ -634,8 +634,8 @@ void copy_DBR(const void * dbr, u } } -// template -template +// template +template void copy_DBR_STS(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) { const T* data = static_cast(dbr); @@ -645,11 +645,11 @@ void copy_DBR_STS(const void * dbr, unsigned count, PVStructure::shared_pointer alarm->getSubField("severity")->put(data->severity); alarm->getSubField("message")->put(dbrStatus2alarmMessage[data->status]); - copy_DBR(&data->value, count, pvStructure); + copy_DBR(&data->value, count, pvStructure); } -// template -template +// template +template void copy_DBR_TIME(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) { const T* data = static_cast(dbr); @@ -660,7 +660,7 @@ void copy_DBR_TIME(const void * dbr, unsigned count, PVStructure::shared_pointer ts->getSubField("secondsPastEpoch")->put(spe); ts->getSubField("nanoseconds")->put(data->stamp.nsec); - copy_DBR_STS(dbr, count, pvStructure); + copy_DBR_STS(dbr, count, pvStructure); } @@ -701,8 +701,8 @@ COPY_FORMAT_FOR(dbr_ctrl_double) #undef COPY_FORMAT_FOR -// template -template +// template +template void copy_DBR_GR(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) { const T* data = static_cast(dbr); @@ -725,22 +725,22 @@ void copy_DBR_GR(const void * dbr, unsigned count, PVStructure::shared_pointer c va->getSubField("lowWarningLimit")->put(data->lower_warning_limit); va->getSubField("lowAlarmLimit")->put(data->lower_alarm_limit); - copy_DBR(&data->value, count, pvStructure); + copy_DBR(&data->value, count, pvStructure); } // enum specialization template<> -void copy_DBR_GR +void copy_DBR_GR (const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) { const dbr_gr_enum* data = static_cast(dbr); - copy_DBR_STS(data, count, pvStructure); + copy_DBR_STS(data, count, pvStructure); } -// template -template +// template +template void copy_DBR_CTRL(const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) { const T* data = static_cast(dbr); @@ -767,61 +767,61 @@ void copy_DBR_CTRL(const void * dbr, unsigned count, PVStructure::shared_pointer ctrl->getSubField("limitHigh")->put(data->upper_ctrl_limit); ctrl->getSubField("limitLow")->put(data->lower_ctrl_limit); - copy_DBR(&data->value, count, pvStructure); + copy_DBR(&data->value, count, pvStructure); } // enum specialization template<> -void copy_DBR_CTRL +void copy_DBR_CTRL (const void * dbr, unsigned count, PVStructure::shared_pointer const & pvStructure) { const dbr_ctrl_enum* data = static_cast(dbr); - copy_DBR_STS(data, count, pvStructure); + copy_DBR_STS(data, count, pvStructure); } static copyDBRtoPVStructure copyFuncTable[] = { - copy_DBR, // DBR_STRING - copy_DBR, // DBR_INT, DBR_SHORT - copy_DBR, // DBR_FLOAT - copy_DBR, // DBR_ENUM - copy_DBR, // DBR_CHAR - copy_DBR, // DBR_LONG - copy_DBR, // DBR_DOUBLE + copy_DBR, // DBR_STRING + copy_DBR, // DBR_INT, DBR_SHORT + copy_DBR, // DBR_FLOAT + copy_DBR, // DBR_ENUM + copy_DBR, // DBR_CHAR + copy_DBR, // DBR_LONG + copy_DBR, // DBR_DOUBLE - copy_DBR_STS, // DBR_STS_STRING - copy_DBR_STS, // DBR_STS_INT, DBR_STS_SHORT - copy_DBR_STS, // DBR_STS_FLOAT - copy_DBR_STS, // DBR_STS_ENUM - copy_DBR_STS, // DBR_STS_CHAR - copy_DBR_STS, // DBR_STS_LONG - copy_DBR_STS, // DBR_STS_DOUBLE + copy_DBR_STS, // DBR_STS_STRING + copy_DBR_STS, // DBR_STS_INT, DBR_STS_SHORT + copy_DBR_STS, // DBR_STS_FLOAT + copy_DBR_STS, // DBR_STS_ENUM + copy_DBR_STS, // DBR_STS_CHAR + copy_DBR_STS, // DBR_STS_LONG + copy_DBR_STS, // DBR_STS_DOUBLE - copy_DBR_TIME, // DBR_TIME_STRING - copy_DBR_TIME, // DBR_TIME_INT, DBR_TIME_SHORT - copy_DBR_TIME, // DBR_TIME_FLOAT - copy_DBR_TIME, // DBR_TIME_ENUM - copy_DBR_TIME, // DBR_TIME_CHAR - copy_DBR_TIME, // DBR_TIME_LONG - copy_DBR_TIME, // DBR_TIME_DOUBLE + copy_DBR_TIME, // DBR_TIME_STRING + copy_DBR_TIME, // DBR_TIME_INT, DBR_TIME_SHORT + copy_DBR_TIME, // DBR_TIME_FLOAT + copy_DBR_TIME, // DBR_TIME_ENUM + copy_DBR_TIME, // DBR_TIME_CHAR + copy_DBR_TIME, // DBR_TIME_LONG + copy_DBR_TIME, // DBR_TIME_DOUBLE - copy_DBR_STS, // DBR_GR_STRING -> DBR_STS_STRING - copy_DBR_GR, // DBR_GR_INT, DBR_GR_SHORT - copy_DBR_GR, // DBR_GR_FLOAT - copy_DBR_GR, // DBR_GR_ENUM - copy_DBR_GR, // DBR_GR_CHAR - copy_DBR_GR, // DBR_GR_LONG - copy_DBR_GR, // DBR_GR_DOUBLE + copy_DBR_STS, // DBR_GR_STRING -> DBR_STS_STRING + copy_DBR_GR, // DBR_GR_INT, DBR_GR_SHORT + copy_DBR_GR, // DBR_GR_FLOAT + copy_DBR_GR, // DBR_GR_ENUM + copy_DBR_GR, // DBR_GR_CHAR + copy_DBR_GR, // DBR_GR_LONG + copy_DBR_GR, // DBR_GR_DOUBLE - copy_DBR_STS, // DBR_CTRL_STRING -> DBR_STS_STRING - copy_DBR_CTRL, // DBR_CTRL_INT, DBR_CTRL_SHORT - copy_DBR_CTRL, // DBR_CTRL_FLOAT - copy_DBR_CTRL, // DBR_CTRL_ENUM - copy_DBR_CTRL, // DBR_CTRL_CHAR - copy_DBR_CTRL, // DBR_CTRL_LONG - copy_DBR_CTRL // DBR_CTRL_DOUBLE + copy_DBR_STS, // DBR_CTRL_STRING -> DBR_STS_STRING + copy_DBR_CTRL, // DBR_CTRL_INT, DBR_CTRL_SHORT + copy_DBR_CTRL, // DBR_CTRL_FLOAT + copy_DBR_CTRL, // DBR_CTRL_ENUM + copy_DBR_CTRL, // DBR_CTRL_CHAR + copy_DBR_CTRL, // DBR_CTRL_LONG + copy_DBR_CTRL // DBR_CTRL_DOUBLE }; void CAChannelGet::getDone(struct event_handler_args &args)