From c8c0498cdfdfb68506862bb295b85454067466e0 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Wed, 18 Feb 2015 10:03:18 +0100 Subject: [PATCH] using new copy API --- pvtoolsSrc/eget.cpp | 3 +- pvtoolsSrc/pvput.cpp | 2 +- src/remote/serializationHelper.cpp | 137 -------------------- src/remote/serializationHelper.h | 17 --- src/remoteClient/clientContextImpl.cpp | 10 +- src/rpcClient/rpcClient.cpp | 1 - src/server/responseHandlers.cpp | 14 +- src/utils/introspectionRegistry.cpp | 1 - testApp/remote/channelAccessIFTest.cpp | 6 +- testApp/remote/testServer.cpp | 8 +- testApp/utils/introspectionRegistryTest.cpp | 1 - 11 files changed, 17 insertions(+), 183 deletions(-) diff --git a/pvtoolsSrc/eget.cpp b/pvtoolsSrc/eget.cpp index b7cdd30..fc5ae1d 100644 --- a/pvtoolsSrc/eget.cpp +++ b/pvtoolsSrc/eget.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -970,7 +969,7 @@ void printValues(shared_vector const & names, vector(getPVDataCreate()->createPVScalarArray(pvString)); PVStringArray::svector values; - values.push_back(getConvert()->toString(scalar)); + values.push_back(scalar->getAs()); StringArray->replace(freeze(values)); scalarArrays.push_back(StringArray); diff --git a/pvtoolsSrc/pvput.cpp b/pvtoolsSrc/pvput.cpp index 7ed9b05..fd183af 100644 --- a/pvtoolsSrc/pvput.cpp +++ b/pvtoolsSrc/pvput.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -19,7 +20,6 @@ #include #include "pvutils.cpp" -#include #include diff --git a/src/remote/serializationHelper.cpp b/src/remote/serializationHelper.cpp index fce5484..a4a9363 100644 --- a/src/remote/serializationHelper.cpp +++ b/src/remote/serializationHelper.cpp @@ -85,143 +85,6 @@ void SerializationHelper::serializeFull(ByteBuffer* buffer, SerializableControl* } } -ConvertPtr SerializationHelper::_convert(getConvert()); - -void SerializationHelper::copyUnchecked( - epics::pvData::PVField::shared_pointer const & from, - epics::pvData::PVField::shared_pointer const & to) -{ - switch(from->getField()->getType()) - { - case scalar: - { - PVScalar::shared_pointer fromS = std::tr1::static_pointer_cast(from); - PVScalar::shared_pointer toS = std::tr1::static_pointer_cast(to); - toS->assign(*fromS.get()); - break; - } - case scalarArray: - { - PVScalarArray::shared_pointer fromS = std::tr1::static_pointer_cast(from); - PVScalarArray::shared_pointer toS = std::tr1::static_pointer_cast(to); - toS->assign(*fromS.get()); - break; - } - case structure: - { - PVStructure::shared_pointer fromS = std::tr1::static_pointer_cast(from); - PVStructure::shared_pointer toS = std::tr1::static_pointer_cast(to); - copyStructureUnchecked(fromS, toS); - break; - } - case structureArray: - { - PVStructureArray::shared_pointer fromS = std::tr1::static_pointer_cast(from); - PVStructureArray::shared_pointer toS = std::tr1::static_pointer_cast(to); - toS->replace(fromS->view()); - break; - } - case union_: - { - PVUnion::shared_pointer fromS = std::tr1::static_pointer_cast(from); - PVUnion::shared_pointer toS = std::tr1::static_pointer_cast(to); - _convert->copyUnion(fromS, toS); - break; - } - case unionArray: - { - PVUnionArray::shared_pointer fromS = std::tr1::static_pointer_cast(from); - PVUnionArray::shared_pointer toS = std::tr1::static_pointer_cast(to); - toS->replace(fromS->view()); - break; - } - default: - { - throw std::logic_error("SerializationHelper::copyUnchecked unknown type"); - } - } -} - - -void SerializationHelper::copyStructureUnchecked( - PVStructure::shared_pointer const & from, - PVStructure::shared_pointer const & to) -{ - - if (from.get() == to.get()) - return; - - PVFieldPtrArray const & fromPVFields = from->getPVFields(); - PVFieldPtrArray const & toPVFields = to->getPVFields(); - - size_t fieldsSize = fromPVFields.size(); - for(size_t i = 0; i(pvField->getNumberFields()); - - // serialize field or fields - if(inumberFields==1) { - copyUnchecked(pvField, toPVFields[i]); - } else { - PVStructure::shared_pointer fromPVStructure = std::tr1::static_pointer_cast(pvField); - PVStructure::shared_pointer toPVStructure = std::tr1::static_pointer_cast(toPVFields[i]); - copyStructureUnchecked(fromPVStructure, toPVStructure); - } - } -} - -void SerializationHelper::partialCopy(PVStructure::shared_pointer const & from, - PVStructure::shared_pointer const & to, - BitSet::shared_pointer const & maskBitSet, - bool inverse) { - - if (from.get() == to.get()) - return; - - size_t numberFields = from->getNumberFields(); - size_t offset = from->getFieldOffset(); - int32 next = inverse ? - maskBitSet->nextClearBit(static_cast(offset)) : - maskBitSet->nextSetBit(static_cast(offset)); - - // no more changes or no changes in this structure - if(next<0||next>=static_cast(offset+numberFields)) return; - - // entire structure - if(static_cast(offset)==next) { - copyStructureUnchecked(from, to); - return; - } - - PVFieldPtrArray const & fromPVFields = from->getPVFields(); - PVFieldPtrArray const & toPVFields = to->getPVFields(); - - size_t fieldsSize = fromPVFields.size(); - for(size_t i = 0; igetFieldOffset(); - int32 inumberFields = static_cast(pvField->getNumberFields()); - next = inverse ? - maskBitSet->nextClearBit(static_cast(offset)) : - maskBitSet->nextSetBit(static_cast(offset)); - - // no more changes - if(next<0) return; - // no change in this pvField - if(next>=static_cast(offset+inumberFields)) continue; - - // serialize field or fields - if(inumberFields==1) { - copyUnchecked(pvField, toPVFields[i]); - } else { - PVStructure::shared_pointer fromPVStructure = std::tr1::static_pointer_cast(pvField); - PVStructure::shared_pointer toPVStructure = std::tr1::static_pointer_cast(toPVFields[i]); - partialCopy(fromPVStructure, toPVStructure, maskBitSet, inverse); - } - } -} - - }} diff --git a/src/remote/serializationHelper.h b/src/remote/serializationHelper.h index 34270a0..7768bc9 100644 --- a/src/remote/serializationHelper.h +++ b/src/remote/serializationHelper.h @@ -15,7 +15,6 @@ #include #include -#include #include #include #include @@ -35,7 +34,6 @@ namespace epics { public: static epics::pvData::PVDataCreatePtr _pvDataCreate; - static epics::pvData::ConvertPtr _convert; /** * Deserialize PVRequest. @@ -101,21 +99,6 @@ namespace epics { */ static void serializeFull(epics::pvData::ByteBuffer* buffer, epics::pvData::SerializableControl* control, epics::pvData::PVField::shared_pointer const & pvField); - static void copyUnchecked( - epics::pvData::PVField::shared_pointer const & from, - epics::pvData::PVField::shared_pointer const & to); - - static void copyStructureUnchecked( - epics::pvData::PVStructure::shared_pointer const & from, - epics::pvData::PVStructure::shared_pointer const & to); - - // TODO move somewhere else, to pvData? - static void partialCopy( - epics::pvData::PVStructure::shared_pointer const & from, - epics::pvData::PVStructure::shared_pointer const & to, - epics::pvData::BitSet::shared_pointer const & maskBitSet, - bool inverse = false); - }; } diff --git a/src/remoteClient/clientContextImpl.cpp b/src/remoteClient/clientContextImpl.cpp index 6f3eefe..27e2ac6 100644 --- a/src/remoteClient/clientContextImpl.cpp +++ b/src/remoteClient/clientContextImpl.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -53,7 +52,6 @@ namespace epics { Status ChannelImpl::channelDisconnected( Status::STATUSTYPE_WARNING, "channel disconnected"); string emptyString; - ConvertPtr convert = getConvert(); // TODO consider std::unordered_map //typedef std::tr1::unordered_map IOIDResponseRequestMap; @@ -984,7 +982,7 @@ namespace epics { try { lock(); *m_bitSet = *pvPutBitSet; - SerializationHelper::partialCopy(pvPutStructure, m_structure, m_bitSet); + m_structure->copyUnchecked(*pvPutStructure, *m_bitSet); unlock(); m_channel->checkAndGetTransport()->enqueueSendRequest(shared_from_this()); } catch (std::runtime_error &rte) { @@ -1250,7 +1248,7 @@ namespace epics { try { lock(); *m_putDataBitSet = *bitSet; - SerializationHelper::partialCopy(pvPutStructure, m_putData, m_putDataBitSet); + m_putData->copyUnchecked(*pvPutStructure, *m_putDataBitSet); unlock(); m_channel->checkAndGetTransport()->enqueueSendRequest(shared_from_this()); } catch (std::runtime_error &rte) { @@ -1799,7 +1797,7 @@ namespace epics { try { { Lock lock(m_structureMutex); - SerializationHelper::copyUnchecked(putArray, m_arrayData); + m_arrayData->copyUnchecked(*putArray); m_offset = offset; m_count = count; m_stride = stride; @@ -2291,7 +2289,7 @@ namespace epics { // deserialize changedBitSet and data, and overrun bit set changedBitSet->deserialize(payloadBuffer, transport.get()); if (m_up2datePVStructure && m_up2datePVStructure.get() != pvStructure.get()) - SerializationHelper::partialCopy(m_up2datePVStructure, pvStructure, changedBitSet, true); + pvStructure->copyUnchecked(*m_up2datePVStructure, *changedBitSet, true); pvStructure->deserialize(payloadBuffer, transport.get(), changedBitSet.get()); overrunBitSet->deserialize(payloadBuffer, transport.get()); diff --git a/src/rpcClient/rpcClient.cpp b/src/rpcClient/rpcClient.cpp index fccd51b..1b0a7d1 100644 --- a/src/rpcClient/rpcClient.cpp +++ b/src/rpcClient/rpcClient.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #define epicsExportSharedSymbols diff --git a/src/server/responseHandlers.cpp b/src/server/responseHandlers.cpp index 8be2ce4..72df798 100644 --- a/src/server/responseHandlers.cpp +++ b/src/server/responseHandlers.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include @@ -1116,7 +1115,7 @@ void ServerChannelGetRequesterImpl::getDone(const Status& status, ChannelGet::sh if (_status.isSuccess()) { *_bitSet = *bitSet; - SerializationHelper::partialCopy(pvStructure, _pvStructure, _bitSet); + _pvStructure->copyUnchecked(*pvStructure, *_bitSet); } } @@ -1398,7 +1397,7 @@ void ServerChannelPutRequesterImpl::getDone(const Status& status, ChannelPut::sh if (_status.isSuccess()) { *_bitSet = *bitSet; - SerializationHelper::partialCopy(pvStructure, _pvStructure, _bitSet); + _pvStructure->copyUnchecked(*pvStructure, *_bitSet); } } TransportSender::shared_pointer thisSender = shared_from_this(); @@ -1686,7 +1685,7 @@ void ServerChannelPutGetRequesterImpl::getGetDone(const Status& status, ChannelP if (_status.isSuccess()) { *_pvGetBitSet = *bitSet; - SerializationHelper::partialCopy(pvStructure, _pvGetStructure, _pvGetBitSet); + _pvGetStructure->copyUnchecked(*pvStructure, *_pvGetBitSet); } } TransportSender::shared_pointer thisSender = shared_from_this(); @@ -1702,7 +1701,7 @@ void ServerChannelPutGetRequesterImpl::getPutDone(const Status& status, ChannelP if (_status.isSuccess()) { *_pvPutBitSet = *bitSet; - SerializationHelper::partialCopy(pvStructure, _pvPutStructure, _pvPutBitSet); + _pvPutStructure->copyUnchecked(*pvStructure, *_pvPutBitSet); } } TransportSender::shared_pointer thisSender = shared_from_this(); @@ -1718,7 +1717,7 @@ void ServerChannelPutGetRequesterImpl::putGetDone(const Status& status, ChannelP if (_status.isSuccess()) { *_pvGetBitSet = *bitSet; - SerializationHelper::partialCopy(pvStructure, _pvGetStructure, _pvGetBitSet); + _pvGetStructure->copyUnchecked(*pvStructure, *_pvGetBitSet); } } TransportSender::shared_pointer thisSender = shared_from_this(); @@ -2304,8 +2303,7 @@ void ServerChannelArrayRequesterImpl::getArrayDone(const Status& status, Channel _status = status; if (_status.isSuccess()) { - // TODO cache convert - getConvert()->copy(pvArray, _pvArray); + _pvArray->copyUnchecked(*pvArray); } } TransportSender::shared_pointer thisSender = shared_from_this(); diff --git a/src/utils/introspectionRegistry.cpp b/src/utils/introspectionRegistry.cpp index 6b093e9..e2db703 100644 --- a/src/utils/introspectionRegistry.cpp +++ b/src/utils/introspectionRegistry.cpp @@ -5,7 +5,6 @@ */ #include -#include #include using namespace epics::pvData; diff --git a/testApp/remote/channelAccessIFTest.cpp b/testApp/remote/channelAccessIFTest.cpp index 7f90f0a..d12c558 100755 --- a/testApp/remote/channelAccessIFTest.cpp +++ b/testApp/remote/channelAccessIFTest.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include #include @@ -1757,8 +1756,7 @@ std::ostringstream oss; oss << *monitorReq->getPVStructure(); testDiag("%s:\n%s", CURRENT_FUNCTION, oss.str().c_str()); - ConvertPtr convert = getConvert(); - convert->copy(valueField, previousValue); + previousValue->copyUnchecked(*valueField); testOk(valueField->equals(*previousValue.get()) == true , "%s: value field equals to a previous value", CURRENT_FUNCTION); @@ -1801,7 +1799,7 @@ testDiag("%s:\n%s", CURRENT_FUNCTION, oss.str().c_str()); testOk(valueField->equals(*previousValue.get()) == false , "%s: value field not equals to a previous value", CURRENT_FUNCTION); - convert->copy(valueField, previousValue); + previousValue->copyUnchecked(*valueField); } diff --git a/testApp/remote/testServer.cpp b/testApp/remote/testServer.cpp index 49014ca..ff759c6 100644 --- a/testApp/remote/testServer.cpp +++ b/testApp/remote/testServer.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -24,7 +23,6 @@ #include #include -#include // TODO temp #include "testADCSim.cpp" @@ -1003,7 +1001,7 @@ public: if (putBitSet->cardinality()) { lock(); - getConvert()->copy(pvPutStructure, m_pvStructure); + m_pvStructure->copyUnchecked(*pvPutStructure); unlock(); } @@ -1125,7 +1123,7 @@ public: if (putBitSet->cardinality()) { lock(); - getConvert()->copy(pvPutStructure, m_putStructure); + m_putStructure->copyUnchecked(*pvPutStructure); unlock(); } @@ -1947,7 +1945,7 @@ public: { { lock(); - getConvert()->copyStructure(m_pvStructure, m_ccopy); + m_ccopy->copyUnchecked(*m_pvStructure); unlock(); } } diff --git a/testApp/utils/introspectionRegistryTest.cpp b/testApp/utils/introspectionRegistryTest.cpp index ed9e2c1..c7285b2 100644 --- a/testApp/utils/introspectionRegistryTest.cpp +++ b/testApp/utils/introspectionRegistryTest.cpp @@ -14,7 +14,6 @@ #include #include #include -#include using std::tr1::static_pointer_cast; using namespace epics::pvData;