Skip to content
Snippets Groups Projects
Commit 4b6b3a81 authored by Christoph Kampmeyer's avatar Christoph Kampmeyer
Browse files

wip #150: Adapt to API changes in pre/postRead and -Write functions

parent 97fe50fa
No related branches found
No related tags found
No related merge requests found
......@@ -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; }
......
......@@ -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) {
......
......@@ -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:
......
......@@ -40,7 +40,7 @@ namespace ChimeraTK {
TransferFuture doReadTransferAsync() override;
void doPreWrite() override;
void doPreWrite(TransferType type) override;
DataValidity dataValidity() const override;
......
......@@ -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]);
}
......
......@@ -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;
......
......@@ -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:
......
......@@ -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>
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment