ChimeraTK-DeviceAccess  03.18.00
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"
7 #include "ForwardDeclarations.h"
8 #include "MetadataCatalogue.h"
9 #include "RegisterCatalogue.h"
11 
12 #include <boost/enable_shared_from_this.hpp>
13 
14 #include <string>
15 
16 namespace ChimeraTK {
17  namespace async {
18  class MuxedInterruptDistributor;
19  template<typename BackendSpecificDataType>
20  class SubDomain;
21  } // namespace async
22 
28  class DeviceBackend : public boost::enable_shared_from_this<DeviceBackend> {
29  public:
31  virtual ~DeviceBackend() = default;
32 
34  virtual void open() = 0;
35 
37  virtual void close() = 0;
38 
40  virtual bool isOpen() = 0;
41 
43  [[deprecated]] virtual bool isConnected() = 0;
44 
54  virtual bool isFunctional() const noexcept = 0;
55 
59  virtual RegisterCatalogue getRegisterCatalogue() const = 0;
60 
64  virtual MetadataCatalogue getMetadataCatalogue() const = 0;
65 
67  template<typename UserType>
68  boost::shared_ptr<NDRegisterAccessor<UserType>> getRegisterAccessor(
69  const RegisterPath& registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags);
70  DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(getRegisterAccessor_impl,
71  boost::shared_ptr<NDRegisterAccessor<T>>(const RegisterPath&, size_t, size_t, AccessModeFlags));
72 
79  virtual std::string readDeviceInfo() = 0;
80 
87  virtual void setException(const std::string& message) noexcept = 0;
88 
97  virtual void activateAsyncRead() noexcept {}
98 
103  virtual void checkActiveException() = 0;
104  };
105 
106  /********************************************************************************************************************/
107 
108  template<typename UserType>
109  boost::shared_ptr<NDRegisterAccessor<UserType>> DeviceBackend::getRegisterAccessor(
110  const RegisterPath& registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) {
112  getRegisterAccessor_impl, UserType, registerPathName, numberOfWords, wordOffsetInRegister, flags);
113  }
114 
115  /********************************************************************************************************************/
116 
117 } // namespace ChimeraTK
ForwardDeclarations.h
ChimeraTK::DeviceBackend::DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE
DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(getRegisterAccessor_impl, boost::shared_ptr< NDRegisterAccessor< T >>(const RegisterPath &, size_t, size_t, AccessModeFlags))
ChimeraTK::DeviceBackend::setException
virtual void setException(const std::string &message) noexcept=0
Set the backend into an exception state.
ChimeraTK::MetadataCatalogue
Container for backend metadata.
Definition: MetadataCatalogue.h:17
VirtualFunctionTemplate.h
ChimeraTK::DeviceBackend::activateAsyncRead
virtual void activateAsyncRead() noexcept
Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set.
Definition: DeviceBackend.h:97
ChimeraTK::DeviceBackend::isFunctional
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...
ChimeraTK::DeviceBackend::checkActiveException
virtual void checkActiveException()=0
Function to be called by backends when needing to check for an active exception.
ChimeraTK::DeviceBackend::isOpen
virtual bool isOpen()=0
Return whether a device has been opened or not.
ChimeraTK::DeviceBackend::~DeviceBackend
virtual ~DeviceBackend()=default
Every virtual class needs a virtual desctructor.
ChimeraTK::RegisterCatalogue
Catalogue of register information.
Definition: RegisterCatalogue.h:20
ChimeraTK::DeviceBackend
The base class for backends providing IO functionality for the Device class.
Definition: DeviceBackend.h:28
ChimeraTK::DeviceBackend::isConnected
virtual bool isConnected()=0
Deprecated since 2022-03-03.
ChimeraTK::DeviceBackend::readDeviceInfo
virtual std::string readDeviceInfo()=0
Return a device information string containing hardware details like the firmware version number or th...
RegisterCatalogue.h
ChimeraTK::DeviceBackend::open
virtual void open()=0
Open the device.
MetadataCatalogue.h
ChimeraTK::DeviceBackend::getRegisterCatalogue
virtual RegisterCatalogue getRegisterCatalogue() const =0
Return the register catalogue with detailed information on all registers.
ChimeraTK::DeviceBackend::getRegisterAccessor
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.
Definition: DeviceBackend.h:109
ChimeraTK::RegisterPath
Class to store a register path name.
Definition: RegisterPath.h:16
AccessMode.h
ChimeraTK::DeviceBackend::getMetadataCatalogue
virtual MetadataCatalogue getMetadataCatalogue() const =0
Return the device metadata catalogue.
ChimeraTK::DeviceBackend::close
virtual void close()=0
Close the device.
CALL_VIRTUAL_FUNCTION_TEMPLATE
#define CALL_VIRTUAL_FUNCTION_TEMPLATE(functionName, templateArgument,...)
Execute the virtual function template call using the vtable defined with the DEFINE_VIRTUAL_FUNCTION_...
Definition: VirtualFunctionTemplate.h:70
ChimeraTK::AccessModeFlags
Set of AccessMode flags with additional functionality for an easier handling.
Definition: AccessMode.h:48
Exception.h
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::NDRegisterAccessor< T >