ChimeraTK-DeviceAccess 03.29.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"
10#include "VersionNumber.h"
12
13#include <boost/enable_shared_from_this.hpp>
14
15#include <cstdint>
16#include <string>
17
18namespace ChimeraTK {
19 namespace async {
20 class MuxedInterruptDistributor;
21 template<typename BackendSpecificDataType>
22 class SubDomain;
23 } // namespace async
24
25 namespace detail {
26 class SharedAccessors;
27 } // namespace detail
28
34 class DeviceBackend : public boost::enable_shared_from_this<DeviceBackend> {
35 public:
37 virtual ~DeviceBackend() = default;
38
40 virtual void open() = 0;
41
43 virtual void close() = 0;
44
46 virtual bool isOpen() = 0;
47
49 [[deprecated]] virtual bool isConnected() = 0;
50
60 virtual bool isFunctional() const noexcept = 0;
61
66
71
73 template<typename UserType>
74 boost::shared_ptr<NDRegisterAccessor<UserType>> getRegisterAccessor(
75 const RegisterPath& registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags);
77 boost::shared_ptr<NDRegisterAccessor<T>>(const RegisterPath&, size_t, size_t, AccessModeFlags));
78
85 virtual std::string readDeviceInfo() = 0;
86
93 virtual void setException(const std::string& message) noexcept = 0;
94
103 virtual void activateAsyncRead() noexcept {}
104
109 virtual void checkActiveException() = 0;
110
111 using BackendID = std::uintptr_t;
112
117 return reinterpret_cast<DeviceBackend::BackendID>(this); // NOLINT cppcoreguidelines-pro-type-reinterpret-cast
118 }
119
125 virtual std::set<BackendID> getInvolvedBackendIDs() = 0;
126
133
137 virtual boost::shared_ptr<detail::SharedAccessors> getSharedAccessors() = 0;
138 };
139
140 /********************************************************************************************************************/
141
142 template<typename UserType>
143 boost::shared_ptr<NDRegisterAccessor<UserType>> DeviceBackend::getRegisterAccessor(
144 const RegisterPath& registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) {
146 getRegisterAccessor_impl, UserType, registerPathName, numberOfWords, wordOffsetInRegister, flags);
147 }
148
149 /********************************************************************************************************************/
150
151} // 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 ChimeraTK::VersionNumber getVersionOnOpen() const =0
Get the version number which was set during the open process.
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 boost::shared_ptr< detail::SharedAccessors > getSharedAccessors()=0
Get the SharedAccessors object of this backend instance.
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.
Class for generating and holding version numbers without exposing a numeric representation.
STL namespace.