ChimeraTK-DeviceAccess 03.26.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
30 class DeviceBackend : public boost::enable_shared_from_this<DeviceBackend> {
31 public:
33 virtual ~DeviceBackend() = default;
34
36 virtual void open() = 0;
37
39 virtual void close() = 0;
40
42 virtual bool isOpen() = 0;
43
45 [[deprecated]] virtual bool isConnected() = 0;
46
56 virtual bool isFunctional() const noexcept = 0;
57
62
67
69 template<typename UserType>
70 boost::shared_ptr<NDRegisterAccessor<UserType>> getRegisterAccessor(
71 const RegisterPath& registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags);
73 boost::shared_ptr<NDRegisterAccessor<T>>(const RegisterPath&, size_t, size_t, AccessModeFlags));
74
81 virtual std::string readDeviceInfo() = 0;
82
89 virtual void setException(const std::string& message) noexcept = 0;
90
99 virtual void activateAsyncRead() noexcept {}
100
105 virtual void checkActiveException() = 0;
106
107 using BackendID = std::uintptr_t;
108
113 return reinterpret_cast<DeviceBackend::BackendID>(this); // NOLINT cppcoreguidelines-pro-type-reinterpret-cast
114 }
115
121 virtual std::set<BackendID> getInvolvedBackendIDs() = 0;
122
129 };
130
131 /********************************************************************************************************************/
132
133 template<typename UserType>
134 boost::shared_ptr<NDRegisterAccessor<UserType>> DeviceBackend::getRegisterAccessor(
135 const RegisterPath& registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) {
137 getRegisterAccessor_impl, UserType, registerPathName, numberOfWords, wordOffsetInRegister, flags);
138 }
139
140 /********************************************************************************************************************/
141
142} // 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 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.