ChimeraTK-DeviceAccess  03.18.00
ChimeraTK::DummyRegisterAccessor< T > Class Template Reference

Register accessor for accessing single word or 1D array registers internally of a DummyBackend implementation. More...

#include <DummyBackend.h>

+ Inheritance diagram for ChimeraTK::DummyRegisterAccessor< T >:
+ Collaboration diagram for ChimeraTK::DummyRegisterAccessor< T >:

Public Member Functions

 DummyRegisterAccessor (DummyBackend *dev, std::string const &module, std::string const &name)
 Constructor should normally be called in the constructor of the DummyBackend implementation. More...
 
 DummyRegisterAccessor (const DummyRegisterAccessor &)=default
 
void operator= (const DummyRegisterAccessor &rightHandSide) const =delete
 remove assignment operator since it will be confusing *‍/ More...
 
proxies::DummyRegisterElement< T > operator[] (unsigned int index)
 Get or set register content by [] operator. More...
 
unsigned int getNumberOfElements ()
 return number of elements More...
 
DummyBackendgetBackend () const
 Return the backend. More...
 
const RegisterPathgetRegisterPath () const
 Return the register path. More...
 
void setWriteCallback (const std::function< void()> &writeCallback)
 Set callback function which is called when the register is written to (through the normal Device interface) More...
 
const NumericAddressedRegisterInfogetRegisterInfo ()
 
std::unique_lock< std::mutex > getBufferLock ()
 Get a lock to safely modify the buffer in a multi-treaded environment. More...
 

Protected Member Functions

int32_t * getElement (unsigned int index)
 return element More...
 
proxies::DummyRegisterElement< T > getProxy (int index)
 return a proxy object More...
 

Protected Attributes

DummyBackend_dev
 pointer to VirtualDevice More...
 
NumericAddressedRegisterInfo registerInfo
 register map information More...
 
RegisterPath _path
 path of the register More...
 
FixedPointConverter fpc
 fixed point converter More...
 

Detailed Description

template<typename T>
class ChimeraTK::DummyRegisterAccessor< T >

Register accessor for accessing single word or 1D array registers internally of a DummyBackend implementation.

This accessor should be used to access the dummy registers through the "backdoor" when unit-testing e.g. a library or when implementing a device in the VirtualLab framework. A simple access is provided through the operators and implicit type conversions. The [] operator will return a temporary proxy class, which deals with converting read and write operations of a single word of the register. The temporary proxy implements all needed operators and the implicit type conversion to the type T, so it can be used as it were a variable of the type T in most places.

This class inherits from the DummyRegisterElement proxy, to avoid reimplementing the same interface again. It is thus possible to access through the DummyRegister class directly the first element of the register, without using the [0] operator.

Definition at line 20 of file DummyBackend.h.

Constructor & Destructor Documentation

◆ DummyRegisterAccessor() [1/2]

template<typename T >
ChimeraTK::DummyRegisterAccessor< T >::DummyRegisterAccessor ( DummyBackend dev,
std::string const &  module,
std::string const &  name 
)
inline

Constructor should normally be called in the constructor of the DummyBackend implementation.

dev must be the pointer to the DummyBackend to be accessed. A raw pointer is needed, as used inside the DummyBackend itself. module and name denominate the register entry in the map file.

Definition at line 138 of file DummyRegisterAccessor.h.

◆ DummyRegisterAccessor() [2/2]

template<typename T >
ChimeraTK::DummyRegisterAccessor< T >::DummyRegisterAccessor ( const DummyRegisterAccessor< T > &  )
default

Member Function Documentation

◆ getBackend()

template<typename T >
DummyBackend& ChimeraTK::DummyRegisterAccessor< T >::getBackend ( ) const
inline

Return the backend.

Definition at line 164 of file DummyRegisterAccessor.h.

◆ getBufferLock()

template<typename T >
std::unique_lock<std::mutex> ChimeraTK::DummyRegisterAccessor< T >::getBufferLock ( )
inline

Get a lock to safely modify the buffer in a multi-treaded environment.

You have to release it as soon as possible because it will block all other functionality of the Dummy and all application threads which use it.

Definition at line 183 of file DummyRegisterAccessor.h.

◆ getElement()

template<typename T >
int32_t* ChimeraTK::DummyRegisterAccessor< T >::getElement ( unsigned int  index)
inlineprotected

return element

Definition at line 199 of file DummyRegisterAccessor.h.

+ Here is the caller graph for this function:

◆ getNumberOfElements()

template<typename T >
unsigned int ChimeraTK::DummyRegisterAccessor< T >::getNumberOfElements ( )
inline

return number of elements

Definition at line 158 of file DummyRegisterAccessor.h.

◆ getProxy()

template<typename T >
proxies::DummyRegisterElement<T> ChimeraTK::DummyRegisterAccessor< T >::getProxy ( int  index)
inlineprotected

return a proxy object

Definition at line 204 of file DummyRegisterAccessor.h.

+ Here is the caller graph for this function:

◆ getRegisterInfo()

template<typename T >
const NumericAddressedRegisterInfo& ChimeraTK::DummyRegisterAccessor< T >::getRegisterInfo ( )
inline

Definition at line 178 of file DummyRegisterAccessor.h.

◆ getRegisterPath()

template<typename T >
const RegisterPath& ChimeraTK::DummyRegisterAccessor< T >::getRegisterPath ( ) const
inline

Return the register path.

Definition at line 167 of file DummyRegisterAccessor.h.

◆ operator=()

template<typename T >
void ChimeraTK::DummyRegisterAccessor< T >::operator= ( const DummyRegisterAccessor< T > &  rightHandSide) const
delete

remove assignment operator since it will be confusing *‍/

◆ operator[]()

template<typename T >
proxies::DummyRegisterElement<T> ChimeraTK::DummyRegisterAccessor< T >::operator[] ( unsigned int  index)
inline

Get or set register content by [] operator.

Definition at line 155 of file DummyRegisterAccessor.h.

◆ setWriteCallback()

template<typename T >
void ChimeraTK::DummyRegisterAccessor< T >::setWriteCallback ( const std::function< void()> &  writeCallback)
inline

Set callback function which is called when the register is written to (through the normal Device interface)

Definition at line 170 of file DummyRegisterAccessor.h.

Member Data Documentation

◆ _dev

template<typename T >
DummyBackend* ChimeraTK::DummyRegisterAccessor< T >::_dev
protected

pointer to VirtualDevice

Definition at line 187 of file DummyRegisterAccessor.h.

◆ _path

template<typename T >
RegisterPath ChimeraTK::DummyRegisterAccessor< T >::_path
protected

path of the register

Definition at line 193 of file DummyRegisterAccessor.h.

◆ fpc

template<typename T >
FixedPointConverter ChimeraTK::DummyRegisterAccessor< T >::fpc
protected

fixed point converter

Definition at line 196 of file DummyRegisterAccessor.h.

◆ registerInfo

template<typename T >
NumericAddressedRegisterInfo ChimeraTK::DummyRegisterAccessor< T >::registerInfo
protected

register map information

Definition at line 190 of file DummyRegisterAccessor.h.


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