From 4b6b3a81878e8f49ea6d82f6c93b23d396d3da2a Mon Sep 17 00:00:00 2001 From: Christoph Kampmeyer <christoph.kampmeyer@desy.de> Date: Tue, 14 Apr 2020 11:56:45 +0200 Subject: [PATCH] wip #150: Adapt to API changes in pre/postRead and -Write functions --- include/ConstantAccessor.h | 2 +- include/ConsumingFanOut.h | 4 ++-- include/DebugPrintAccessorDecorator.h | 16 ++++++++-------- include/ExceptionHandlingDecorator.h | 2 +- include/FeedingFanOut.h | 16 ++++++++-------- include/MetaDataPropagatingRegisterDecorator.h | 8 ++++---- include/TestableModeAccessorDecorator.h | 4 ++-- src/ExceptionHandlingDecorator.cc | 4 ++-- src/MetaDataPropagatingRegisterDecorator.cc | 8 ++++---- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/ConstantAccessor.h b/include/ConstantAccessor.h index c0391da9..62c597a8 100644 --- a/include/ConstantAccessor.h +++ b/include/ConstantAccessor.h @@ -52,7 +52,7 @@ namespace ChimeraTK { bool doReadTransferLatest() override { return doReadTransferNonBlocking(); } - void doPostRead() override { ChimeraTK::NDRegisterAccessor<UserType>::buffer_2D[0] = _value; } + void doPostRead(TransferType /*type*/) override { ChimeraTK::NDRegisterAccessor<UserType>::buffer_2D[0] = _value; } bool doWriteTransfer(ChimeraTK::VersionNumber /*versionNumber*/ = {}) override { return true; } diff --git a/include/ConsumingFanOut.h b/include/ConsumingFanOut.h index d3bba3e7..7ccbff1a 100644 --- a/include/ConsumingFanOut.h +++ b/include/ConsumingFanOut.h @@ -26,8 +26,8 @@ namespace ChimeraTK { assert(feedingImpl->isReadable()); } - void doPostRead() override { - ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPostRead(); + void doPostRead(TransferType type) override { + ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPostRead(type); for(auto& slave : FanOut<UserType>::slaves) { // send out copies to slaves // do not send copy if no data is expected (e.g. trigger) if(slave->getNumberOfSamples() != 0) { diff --git a/include/DebugPrintAccessorDecorator.h b/include/DebugPrintAccessorDecorator.h index 44e59791..9c25ec4b 100644 --- a/include/DebugPrintAccessorDecorator.h +++ b/include/DebugPrintAccessorDecorator.h @@ -55,24 +55,24 @@ namespace ChimeraTK { return ChimeraTK::NDRegisterAccessorDecorator<UserType>::doReadTransferAsync(); } - void doPreRead() override { + void doPreRead(TransferType type) override { std::cout << "preRead() called on '" << _fullyQualifiedName << "'." << std::endl; - ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPreRead(); + ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPreRead(type); } - void doPostRead() override { + void doPostRead(TransferType type) override { std::cout << "postRead() called on '" << _fullyQualifiedName << "'." << std::endl; - ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPostRead(); + ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPostRead(type); } - void doPreWrite() override { + void doPreWrite(TransferType type) override { std::cout << "preWrite() called on '" << _fullyQualifiedName << "'." << std::endl; - ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPreWrite(); + ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPreWrite(type); } - void doPostWrite() override { + void doPostWrite(TransferType type) override { std::cout << "postWrite() called on '" << _fullyQualifiedName << "'." << std::endl; - ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPostWrite(); + ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPostWrite(type); } protected: diff --git a/include/ExceptionHandlingDecorator.h b/include/ExceptionHandlingDecorator.h index c7b6c233..2859cf87 100644 --- a/include/ExceptionHandlingDecorator.h +++ b/include/ExceptionHandlingDecorator.h @@ -40,7 +40,7 @@ namespace ChimeraTK { TransferFuture doReadTransferAsync() override; - void doPreWrite() override; + void doPreWrite(TransferType type) override; DataValidity dataValidity() const override; diff --git a/include/FeedingFanOut.h b/include/FeedingFanOut.h index bd2ce6e5..aa2e3fac 100644 --- a/include/FeedingFanOut.h +++ b/include/FeedingFanOut.h @@ -83,16 +83,16 @@ namespace ChimeraTK { return _returnSlave->readTransferLatest(); } - void doPreRead() override { + void doPreRead(TransferType type) override { if(!_withReturn) throw ChimeraTK::logic_error("Read operation called on write-only variable."); _returnSlave->accessChannel(0).swap(ChimeraTK::NDRegisterAccessor<UserType>::buffer_2D[0]); - _returnSlave->preRead(); + _returnSlave->preRead(type); } - void doPostRead() override { + void doPostRead(TransferType type) override { if(!_withReturn) throw ChimeraTK::logic_error("Read operation called on write-only variable."); assert(_hasReturnSlave); - _returnSlave->postRead(); + _returnSlave->postRead(type); _returnSlave->accessChannel(0).swap(ChimeraTK::NDRegisterAccessor<UserType>::buffer_2D[0]); // distribute return-channel update to the other slaves for(auto& slave : FanOut<UserType>::slaves) { // send out copies to slaves @@ -109,7 +109,7 @@ namespace ChimeraTK { return {_returnSlave->readTransferAsync(), this}; } - void doPreWrite() override { + void doPreWrite(TransferType type) override { for(auto& slave : FanOut<UserType>::slaves) { // send out copies to slaves if(slave->getNumberOfSamples() != 0) { // do not send copy if no data is expected (e.g. trigger) if(slave == FanOut<UserType>::slaves.front()) { // in case of first slave, swap instead of copy @@ -124,7 +124,7 @@ namespace ChimeraTK { // pre write may only be called on the target accessors after we have filled // them all, otherwise the first accessor might take us the data away... for(auto& slave : FanOut<UserType>::slaves) { - slave->preWrite(); + slave->preWrite(type); } } @@ -154,9 +154,9 @@ namespace ChimeraTK { return dataLost; } - void doPostWrite() override { + void doPostWrite(TransferType type) override { for(auto& slave : FanOut<UserType>::slaves) { - slave->postWrite(); + slave->postWrite(type); } FanOut<UserType>::slaves.front()->accessChannel(0).swap(ChimeraTK::NDRegisterAccessor<UserType>::buffer_2D[0]); } diff --git a/include/MetaDataPropagatingRegisterDecorator.h b/include/MetaDataPropagatingRegisterDecorator.h index 01eb4a1a..77e6e41f 100644 --- a/include/MetaDataPropagatingRegisterDecorator.h +++ b/include/MetaDataPropagatingRegisterDecorator.h @@ -28,13 +28,13 @@ namespace ChimeraTK { isNonblockingRead = true; return NDRegisterAccessorDecorator<T, T>::doReadTransferLatest(); } - void doPreRead() override { + void doPreRead(TransferType type) override { isNonblockingRead = false; - NDRegisterAccessorDecorator<T, T>::doPreRead(); + NDRegisterAccessorDecorator<T, T>::doPreRead(type); } - void doPostRead() override; - void doPreWrite() override; + void doPostRead(TransferType type) override; + void doPreWrite(TransferType type) override; protected: EntityOwner* _owner; diff --git a/include/TestableModeAccessorDecorator.h b/include/TestableModeAccessorDecorator.h index b41f83f2..f3969535 100644 --- a/include/TestableModeAccessorDecorator.h +++ b/include/TestableModeAccessorDecorator.h @@ -175,9 +175,9 @@ namespace ChimeraTK { return true; } - void doPostRead() override { + void doPostRead(TransferType type) override { if(_handleRead) obtainLockAndDecrementCounter(); - ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPostRead(); + ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPostRead(type); } protected: diff --git a/src/ExceptionHandlingDecorator.cc b/src/ExceptionHandlingDecorator.cc index 46e2dd3f..500bad80 100644 --- a/src/ExceptionHandlingDecorator.cc +++ b/src/ExceptionHandlingDecorator.cc @@ -130,7 +130,7 @@ namespace ChimeraTK { } template<typename UserType> - void ExceptionHandlingDecorator<UserType>::doPreWrite() { + void ExceptionHandlingDecorator<UserType>::doPreWrite(TransferType type) { /* For writable accessors, copy data to the recoveryAcessor before perfroming the write. * Otherwise, the decorated accessor may have swapped the data out of the user buffer already. * This obtains a shared lock from the DeviceModule, hence, the regular writing happeniin here @@ -154,7 +154,7 @@ namespace ChimeraTK { } // lock guard goes out of scope // Now delegate call to the generic decorator, which swaps the buffer, without adding our exception handling with the generic transfer - ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPreWrite(); + ChimeraTK::NDRegisterAccessorDecorator<UserType>::doPreWrite(type); } template<typename UserType> diff --git a/src/MetaDataPropagatingRegisterDecorator.cc b/src/MetaDataPropagatingRegisterDecorator.cc index 32323e90..45981e01 100644 --- a/src/MetaDataPropagatingRegisterDecorator.cc +++ b/src/MetaDataPropagatingRegisterDecorator.cc @@ -4,8 +4,8 @@ namespace ChimeraTK { template<typename T> - void MetaDataPropagatingRegisterDecorator<T>::doPostRead() { - NDRegisterAccessorDecorator<T, T>::doPostRead(); + void MetaDataPropagatingRegisterDecorator<T>::doPostRead(TransferType type) { + NDRegisterAccessorDecorator<T, T>::doPostRead(type); // update the version number if(!isNonblockingRead) { @@ -24,9 +24,9 @@ namespace ChimeraTK { } template<typename T> - void MetaDataPropagatingRegisterDecorator<T>::doPreWrite() { + void MetaDataPropagatingRegisterDecorator<T>::doPreWrite(TransferType type) { ChimeraTK::NDRegisterAccessorDecorator<T>::setDataValidity(_owner->getDataValidity()); - NDRegisterAccessorDecorator<T, T>::doPreWrite(); + NDRegisterAccessorDecorator<T, T>::doPreWrite(type); } } // namespace ChimeraTK -- GitLab