ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
ChimeraTK::DummyRegisterAccessor< T > Class Template Reference

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

#include <DummyRegisterAccessor.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.
 
 DummyRegisterAccessor (const DummyRegisterAccessor &)=default
 
void operator= (const DummyRegisterAccessor &rightHandSide) const =delete
 remove assignment operator since it will be confusing *‍/
 
proxies::DummyRegisterElement< T > operator[] (unsigned int index)
 Get or set register content by [] operator.
 
unsigned int getNumberOfElements ()
 return number of elements
 
DummyBackendgetBackend () const
 Return the backend.
 
const RegisterPathgetRegisterPath () const
 Return the register path.
 
void setWriteCallback (const std::function< void()> &writeCallback)
 Set callback function which is called when the register is written to (through the normal Device interface)
 
const NumericAddressedRegisterInfogetRegisterInfo ()
 
std::unique_lock< std::mutex > getBufferLock ()
 Get a lock to safely modify the buffer in a multi-treaded environment.
 
- Public Member Functions inherited from ChimeraTK::proxies::DummyRegisterElement< T >
 DummyRegisterElement (FixedPointConverter< DEPRECATED_FIXEDPOINT_DEFAULT > *_fpc, int _nbytes, int32_t *_buffer)
 
 operator T () const
 Implicit type conversion to user type T.
 
DummyRegisterElement< T > & operator= (T rhs)
 assignment operator
 
DummyRegisterElement< T > operator++ ()
 pre-increment operator
 
DummyRegisterElement< T > operator-- ()
 pre-decrement operator
 
operator++ (int)
 post-increment operator
 
operator-- (int)
 post-decrement operator
 

Protected Member Functions

int32_t * getElement (unsigned int index)
 return element
 
proxies::DummyRegisterElement< T > getProxy (int index)
 return a proxy object
 
- Protected Member Functions inherited from ChimeraTK::proxies::DummyRegisterElement< T >
 DummyRegisterElement ()
 constructor when used as a base class in DummyRegister
 

Protected Attributes

DummyBackend_dev
 pointer to VirtualDevice
 
NumericAddressedRegisterInfo registerInfo
 register map information
 
RegisterPath _path
 path of the register
 
FixedPointConverter< DEPRECATED_FIXEDPOINT_DEFAULTfpc
 fixed point converter
 
- Protected Attributes inherited from ChimeraTK::proxies::DummyRegisterElement< T >
FixedPointConverter< DEPRECATED_FIXEDPOINT_DEFAULT > * fpcptr
 fixed point converter to be used for this element
 
int nbytes
 number of bytes per word
 
int32_t * buffer
 raw buffer of this element
 

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 133 of file DummyRegisterAccessor.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 139 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 165 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 184 of file DummyRegisterAccessor.h.

◆ getElement()

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

return element

Definition at line 200 of file DummyRegisterAccessor.h.

◆ getNumberOfElements()

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

return number of elements

Definition at line 159 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 205 of file DummyRegisterAccessor.h.

◆ getRegisterInfo()

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

Definition at line 179 of file DummyRegisterAccessor.h.

◆ getRegisterPath()

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

Return the register path.

Definition at line 168 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 156 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 171 of file DummyRegisterAccessor.h.

Member Data Documentation

◆ _dev

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

pointer to VirtualDevice

Definition at line 188 of file DummyRegisterAccessor.h.

◆ _path

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

path of the register

Definition at line 194 of file DummyRegisterAccessor.h.

◆ fpc

fixed point converter

Definition at line 197 of file DummyRegisterAccessor.h.

◆ registerInfo

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

register map information

Definition at line 191 of file DummyRegisterAccessor.h.


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