ChimeraTK-DeviceAccess  03.18.00
ChimeraTK::DeviceBackendImpl Class Reference

DeviceBackendImpl implements some basic functionality which should be available for all backends. More...

#include <DeviceBackendImpl.h>

+ Inheritance diagram for ChimeraTK::DeviceBackendImpl:
+ Collaboration diagram for ChimeraTK::DeviceBackendImpl:

Public Member Functions

bool isOpen () override
 Return whether a device has been opened or not. More...
 
bool isConnected () final
 Deprecated since 2022-03-03. More...
 
MetadataCatalogue getMetadataCatalogue () const override
 Return the device metadata catalogue. More...
 
virtual void setExceptionImpl () noexcept
 Function to be (optionally) implemented by backends if additional actions are needed when switching to the exception state. More...
 
void checkActiveException () final
 Function to be called by backends when needing to check for an active exception. More...
 
void setException (const std::string &message) noexcept final
 Set the backend into an exception state. More...
 
bool isFunctional () const noexcept final
 Return whether a device is working as intended, usually this means it is opened and does not have any errors. More...
 
std::string getActiveExceptionMessage () noexcept
 
- Public Member Functions inherited from ChimeraTK::DeviceBackend
virtual ~DeviceBackend ()=default
 Every virtual class needs a virtual desctructor. More...
 
virtual void open ()=0
 Open the device. More...
 
virtual void close ()=0
 Close the device. More...
 
virtual RegisterCatalogue getRegisterCatalogue () const =0
 Return the register catalogue with detailed information on all registers. More...
 
template<typename UserType >
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. More...
 
 DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE (getRegisterAccessor_impl, boost::shared_ptr< NDRegisterAccessor< T >>(const RegisterPath &, size_t, size_t, AccessModeFlags))
 
virtual std::string readDeviceInfo ()=0
 Return a device information string containing hardware details like the firmware version number or the slot number used by the board. More...
 
virtual void activateAsyncRead () noexcept
 Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set. More...
 

Protected Member Functions

void setOpenedAndClearException () noexcept
 Backends should call this function at the end of a (successful) open() call. More...
 

Protected Attributes

std::atomic< bool > _opened {false}
 flag if backend is opened More...
 
async::DomainsContainer _asyncDomainsContainer
 Container for async::Domains to support wait_for_new_data. More...
 

Detailed Description

DeviceBackendImpl implements some basic functionality which should be available for all backends.

This is required to allow proper decorator patterns which should not have this functionality in the decorator itself.

Definition at line 25 of file DeviceBackendImpl.h.

Member Function Documentation

◆ checkActiveException()

void ChimeraTK::DeviceBackendImpl::checkActiveException ( )
inlinefinalvirtual

Function to be called by backends when needing to check for an active exception.

If an active exception is found, the appropriate ChimeraTK::runtime_error is thrown by this function.

Implements ChimeraTK::DeviceBackend.

Definition at line 94 of file DeviceBackendImpl.h.

+ Here is the caller graph for this function:

◆ getActiveExceptionMessage()

std::string ChimeraTK::DeviceBackendImpl::getActiveExceptionMessage ( )
noexcept

Definition at line 50 of file DeviceBackendImpl.cc.

+ Here is the caller graph for this function:

◆ getMetadataCatalogue()

MetadataCatalogue ChimeraTK::DeviceBackendImpl::getMetadataCatalogue ( ) const
inlineoverridevirtual

Return the device metadata catalogue.

Implements ChimeraTK::DeviceBackend.

Reimplemented in ChimeraTK::NumericAddressedBackend.

Definition at line 35 of file DeviceBackendImpl.h.

◆ isConnected()

bool ChimeraTK::DeviceBackendImpl::isConnected ( )
inlinefinalvirtual

Deprecated since 2022-03-03.

Do not use.

Implements ChimeraTK::DeviceBackend.

Definition at line 29 of file DeviceBackendImpl.h.

◆ isFunctional()

bool ChimeraTK::DeviceBackendImpl::isFunctional ( ) const
inlinefinalvirtualnoexcept

Return whether a device is working as intended, usually this means it is opened and does not have any errors.

The default implementation in DeviceBackendImpl reports (_opened && !_hasErrors). Backends can overload it to implement a more sophisticated error reporting. The implementation might involve a communication attempt with the device.

Notice: isFunctional() shall only return false if there are known errors (or the device is closed). If the working state is unknown, the response should be true. Client code will then try to read/write and might get an exception, while isFunctional()==false means you surely will get an exception.

Implements ChimeraTK::DeviceBackend.

Definition at line 85 of file DeviceBackendImpl.h.

+ Here is the caller graph for this function:

◆ isOpen()

bool ChimeraTK::DeviceBackendImpl::isOpen ( )
inlineoverridevirtual

Return whether a device has been opened or not.

Implements ChimeraTK::DeviceBackend.

Definition at line 27 of file DeviceBackendImpl.h.

+ Here is the caller graph for this function:

◆ setException()

void ChimeraTK::DeviceBackendImpl::setException ( const std::string &  message)
finalvirtualnoexcept

Set the backend into an exception state.

All backends must remember this, turn off asyncronous reads and all accessors will throw a ChimeraTK::runtime_error on read and write operations with the provided message string, until open() has been called successfully.

Implements ChimeraTK::DeviceBackend.

Definition at line 26 of file DeviceBackendImpl.cc.

+ Here is the caller graph for this function:

◆ setExceptionImpl()

virtual void ChimeraTK::DeviceBackendImpl::setExceptionImpl ( )
inlinevirtualnoexcept

Function to be (optionally) implemented by backends if additional actions are needed when switching to the exception state.

Reimplemented in ChimeraTK::UnifiedBackendTest< VECTOR_OF_REGISTERS_T >::ExceptionReportingBackend, ChimeraTK::SubdeviceBackend, ChimeraTK::NumericAddressedBackend, AsyncTestDummy, ChimeraTK::ExceptionDummy, and ChimeraTK::LogicalNameMappingBackend.

Definition at line 41 of file DeviceBackendImpl.h.

◆ setOpenedAndClearException()

void ChimeraTK::DeviceBackendImpl::setOpenedAndClearException ( )
protectednoexcept

Backends should call this function at the end of a (successful) open() call.

Definition at line 12 of file DeviceBackendImpl.cc.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _asyncDomainsContainer

async::DomainsContainer ChimeraTK::DeviceBackendImpl::_asyncDomainsContainer
protected

Container for async::Domains to support wait_for_new_data.

Used here to handle exception distribution.

Definition at line 66 of file DeviceBackendImpl.h.

◆ _opened

std::atomic<bool> ChimeraTK::DeviceBackendImpl::_opened {false}
protected

flag if backend is opened

Definition at line 60 of file DeviceBackendImpl.h.


The documentation for this class was generated from the following files: