ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
DeviceBackend.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 "AccessMode.h"
6#include "Exception.h"
8#include "MetadataCatalogue.h"
9#include "RegisterCatalogue.h"
11
12#include <boost/enable_shared_from_this.hpp>
13
14#include <cstdint>
15#include <string>
16
17namespace ChimeraTK {
18 namespace async {
19 class MuxedInterruptDistributor;
20 template<typename BackendSpecificDataType>
21 class SubDomain;
22 } // namespace async
23
29 class DeviceBackend : public boost::enable_shared_from_this<DeviceBackend> {
30 public:
32 virtual ~DeviceBackend() = default;
33
35 virtual void open() = 0;
36
38 virtual void close() = 0;
39
41 virtual bool isOpen() = 0;
42
44 [[deprecated]] virtual bool isConnected() = 0;
45
55 virtual bool isFunctional() const noexcept = 0;
56
61
66
68 template<typename UserType>
69 boost::shared_ptr<NDRegisterAccessor<UserType>> getRegisterAccessor(
70 const RegisterPath& registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags);
72 boost::shared_ptr<NDRegisterAccessor<T>>(const RegisterPath&, size_t, size_t, AccessModeFlags));
73
80 virtual std::string readDeviceInfo() = 0;
81
88 virtual void setException(const std::string& message) noexcept = 0;
89
98 virtual void activateAsyncRead() noexcept {}
99
104 virtual void checkActiveException() = 0;
105
106 using BackendID = std::uintptr_t;
107
112 return reinterpret_cast<DeviceBackend::BackendID>(this); // NOLINT cppcoreguidelines-pro-type-reinterpret-cast
113 }
114
120 virtual std::set<BackendID> getInvolvedBackendIDs() = 0;
121 };
122
123 /********************************************************************************************************************/
124
125 template<typename UserType>
126 boost::shared_ptr<NDRegisterAccessor<UserType>> DeviceBackend::getRegisterAccessor(
127 const RegisterPath& registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) {
129 getRegisterAccessor_impl, UserType, registerPathName, numberOfWords, wordOffsetInRegister, flags);
130 }
131
132 /********************************************************************************************************************/
133
134} // namespace ChimeraTK
#define CALL_VIRTUAL_FUNCTION_TEMPLATE(functionName, templateArgument,...)
Execute the virtual function template call using the vtable defined with the DEFINE_VIRTUAL_FUNCTION_...
#define DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(functionName,...)
Define a virtual function template with the given function name and signature in the base class.
Set of AccessMode flags with additional functionality for an easier handling.
Definition AccessMode.h:48
The base class for backends providing IO functionality for the Device class.
virtual bool isConnected()=0
Deprecated since 2022-03-03.
virtual void activateAsyncRead() noexcept
Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set.
virtual RegisterCatalogue getRegisterCatalogue() const =0
Return the register catalogue with detailed information on all registers.
virtual bool isFunctional() const noexcept=0
Return whether a device is working as intended, usually this means it is opened and does not have any...
virtual ~DeviceBackend()=default
Every virtual class needs a virtual desctructor.
virtual void close()=0
Close the device.
boost::shared_ptr< NDRegisterAccessor< UserType > > getRegisterAccessor(const RegisterPath &registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags)
Get a NDRegisterAccessor object from the register name.
BackendID getBackendID()
Get a unique ID for this backend instance.
virtual bool isOpen()=0
Return whether a device has been opened or not.
virtual MetadataCatalogue getMetadataCatalogue() const =0
Return the device metadata catalogue.
virtual void open()=0
Open the device.
virtual void setException(const std::string &message) noexcept=0
Set the backend into an exception state.
virtual void checkActiveException()=0
Function to be called by backends when needing to check for an active exception.
virtual std::string readDeviceInfo()=0
Return a device information string containing hardware details like the firmware version number or th...
virtual std::set< BackendID > getInvolvedBackendIDs()=0
Get the backend IDs of all involved backends.
Container for backend metadata.
N-dimensional register accessor.
Catalogue of register information.
Class to store a register path name.
STL namespace.