ChimeraTK-DeviceAccess  03.18.00
WriteCountingBackend.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 #pragma once
4 
5 #include "DummyBackend.h"
6 
7 using namespace ChimeraTK;
8 
9 /**********************************************************************************************************************/
10 
13 
14  static boost::shared_ptr<DeviceBackend> createInstance(std::string, std::map<std::string, std::string> parameters) {
15  return returnInstance<WriteCountingBackend>(
16  parameters.at("map"), convertPathRelativeToDmapToAbs(parameters.at("map")));
17  }
18 
19  size_t writeCount{0};
20 
21  void write(uint64_t bar, uint64_t address, int32_t const* data, size_t sizeInBytes) override {
22  ++writeCount;
23  DummyBackend::write(bar, address, data, sizeInBytes);
24  }
25 
29  "WriteCountingDummy", &WriteCountingBackend::createInstance, {"map"});
30  }
31  };
32 };
33 
34 static WriteCountingBackend::BackendRegisterer gWriteCountingBackendRegisterer;
35 
36 /**********************************************************************************************************************/
ChimeraTK::DummyBackend::write
void write(uint64_t bar, uint64_t address, int32_t const *data, size_t sizeInBytes) override
Write function to be implemented by backends.
Definition: DummyBackend.cc:61
ChimeraTK::DummyBackend::DummyBackend
DummyBackend(const std::string &mapFileName)
Definition: DummyBackend.cc:17
ChimeraTK::BackendFactory::getInstance
static BackendFactory & getInstance()
Static function to get an instance of factory.
Definition: BackendFactory.cc:191
DummyBackend.h
WriteCountingBackend::createInstance
static boost::shared_ptr< DeviceBackend > createInstance(std::string, std::map< std::string, std::string > parameters)
Definition: WriteCountingBackend.h:14
WriteCountingBackend::BackendRegisterer
Definition: WriteCountingBackend.h:26
WriteCountingBackend::BackendRegisterer::BackendRegisterer
BackendRegisterer()
Definition: WriteCountingBackend.h:27
WriteCountingBackend::write
void write(uint64_t bar, uint64_t address, int32_t const *data, size_t sizeInBytes) override
Write function to be implemented by backends.
Definition: WriteCountingBackend.h:21
ChimeraTK::DummyBackend
The dummy device opens a mapping file instead of a device, and implements all registers defined in th...
Definition: DummyBackend.h:45
ChimeraTK::BackendFactory::registerBackendType
void registerBackendType(const std::string &backendType, boost::shared_ptr< DeviceBackend >(*creatorFunction)(std::string address, std::map< std::string, std::string > parameters), const std::vector< std::string > &sdmParameterNames={}, const std::string &deviceAccessVersion=CHIMERATK_DEVICEACCESS_VERSION)
Register a backend by the name backendType with the given creatorFunction.
Definition: BackendFactory.cc:45
ChimeraTK
Definition: DummyBackend.h:16
WriteCountingBackend
Definition: WriteCountingBackend.h:11