ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
ChimeraTK::ScalarRegisterAccessor< UserType, TAG > Class Template Reference

Accessor class to read and write scalar registers transparently by using the accessor object like a variable of the type UserType. More...

#include <ScalarRegisterAccessor.h>

+ Inheritance diagram for ChimeraTK::ScalarRegisterAccessor< UserType, TAG >:
+ Collaboration diagram for ChimeraTK::ScalarRegisterAccessor< UserType, TAG >:

Public Member Functions

 ScalarRegisterAccessor (boost::shared_ptr< NDRegisterAccessor< UserType > > impl)
 Create instance from pointer to implementation.
 
 ScalarRegisterAccessor ()
 Placeholder constructor, to allow late initialisation of the accessor, e.g.
 
 operator UserType & ()
 Implicit type conversion to UserType& to access the value as a reference.
 
 operator const UserType & () const
 Implicit type conversion to const UserType& to access the const reference.
 
template<typename OTHER_TAG >
 operator ScalarRegisterAccessor< UserType, OTHER_TAG > & ()
 Allow free conversion between different TAG template arguments (which is merely used to avoid code duplication in the template specialisation for ChimeraTK::Boolean).
 
template<typename OTHER_TAG >
 operator const ScalarRegisterAccessor< UserType, OTHER_TAG > & () const
 Allow free conversion between different TAG template arguments (which is merely used to avoid code duplication in the template specialisation for ChimeraTK::Boolean).
 
ScalarRegisterAccessoroperator= (UserType rightHandSide)
 Assignment operator, assigns the first element.
 
ScalarRegisterAccessoroperator++ ()
 Pre-increment operator for the first element.
 
ScalarRegisterAccessoroperator-- ()
 Pre-decrement operator for the first element.
 
UserType operator++ (int)
 Post-increment operator for the first element.
 
UserType operator-- (int)
 Post-decrement operator for the first element.
 
template<typename COOKED_TYPE >
COOKED_TYPE getAsCooked ()
 Get the cooked values in case the accessor is a raw accessor (which does not do data conversion).
 
template<typename COOKED_TYPE >
void setAsCooked (COOKED_TYPE value)
 Set the cooked values in case the accessor is a raw accessor (which does not do data conversion).
 
void writeIfDifferent (UserType newValue, VersionNumber versionNumber=VersionNumber{nullptr}, DataValidity validity=DataValidity::ok)
 Convenience function to set and write new value if it differes from the current value.
 
void setAndWrite (UserType newValue, VersionNumber versionNumber={})
 Convenience function to set and write new value.
 
UserType readAndGet ()
 Convenience function to read and return a value of UserType.
 
- Public Member Functions inherited from ChimeraTK::NDRegisterAccessorAbstractor< UserType >
 NDRegisterAccessorAbstractor ()=default
 Create an uninitialised abstractor - just for late initialisation.
 
 NDRegisterAccessorAbstractor (const NDRegisterAccessorAbstractor &)=default
 Declare that we want the default copy constructor although we delete the assigmnent operator.
 
void replace (const NDRegisterAccessorAbstractor< UserType > &newAccessor)
 Assign a new accessor to this NDRegisterAccessorAbstractor.
 
void replace (boost::shared_ptr< NDRegisterAccessor< UserType > > newImpl)
 Alternative signature of replace() with the same functionality, used when a pointer to the implementation has been obtained directly (instead of a NDRegisterAccessorAbstractor).
 
const NDRegisterAccessorAbstractoroperator= (const NDRegisterAccessorAbstractor &rightHandSide) const =delete
 Prevent copying by operator=, since it will be confusing (operator= may also be overloaded to access the content of the buffer!)
 
boost::shared_ptr< NDRegisterAccessor< UserType > > getImpl ()
 
- Public Member Functions inherited from ChimeraTK::TransferElementAbstractor
 TransferElementAbstractor (boost::shared_ptr< TransferElement > impl)
 Construct from TransferElement implementation.
 
 TransferElementAbstractor ()=default
 Create an uninitialised abstractor - just for late initialisation.
 
const std::string & getName () const
 Returns the name that identifies the process variable.
 
const std::string & getUnit () const
 Returns the engineering unit.
 
const std::string & getDescription () const
 Returns the description of this variable/register.
 
const std::type_info & getValueType () const
 Returns the std::type_info for the value type of this transfer element.
 
AccessModeFlags getAccessModeFlags () const
 Return the AccessModeFlags for this TransferElement.
 
void read ()
 Read the data from the device.
 
bool readNonBlocking ()
 Read the next value, if available in the input buffer.
 
bool readLatest ()
 Read the latest value, discarding any other update since the last read if present.
 
ChimeraTK::VersionNumber getVersionNumber () const
 Returns the version number that is associated with the last transfer (i.e.
 
bool write (ChimeraTK::VersionNumber versionNumber={})
 Write the data to device.
 
bool writeDestructively (ChimeraTK::VersionNumber versionNumber={})
 Just like write(), but allows the implementation to destroy the content of the user buffer in the process.
 
bool isReadOnly () const
 Check if transfer element is read only, i.e.
 
bool isReadable () const
 Check if transfer element is readable.
 
bool isWriteable () const
 Check if transfer element is writeable.
 
std::vector< boost::shared_ptr< TransferElement > > getHardwareAccessingElements ()
 Obtain the underlying TransferElements with actual hardware access.
 
std::list< boost::shared_ptr< TransferElement > > getInternalElements ()
 Obtain the full list of TransferElements internally used by this TransferElement.
 
const boost::shared_ptr< TransferElement > & getHighLevelImplElement ()
 Obtain the highest level implementation TransferElement.
 
bool isInitialised () const
 Return if the accessor is properly initialised.
 
void replace (const TransferElementAbstractor &newAccessor)
 Assign a new accessor to this TransferElementAbstractor.
 
void replace (boost::shared_ptr< TransferElement > newImpl)
 Alternative signature of relace() with the same functionality, used when a pointer to the implementation has been obtained directly (instead of a TransferElementAbstractor).
 
void replaceTransferElement (const boost::shared_ptr< TransferElement > &newElement)
 Search for all underlying TransferElements which are considered identical (see mayReplaceOther()) with the given TransferElement.
 
void setPersistentDataStorage (boost::shared_ptr< ChimeraTK::PersistentDataStorage > storage)
 Associate a persistent data storage object to be updated on each write operation of this ProcessArray.
 
TransferElementID getId () const
 Obtain unique ID for the actual implementation of this TransferElement.
 
void setDataValidity (DataValidity valid=DataValidity::ok)
 Set the current DataValidity for this TransferElement.
 
DataValidity dataValidity () const
 Return current validity of the data.
 
void interrupt ()
 Return from a blocking read immediately and throw boost::thread_interrupted.
 
ReadAnyGroupgetReadAnyGroup () const
 Obtain the ReadAnyGroup this TransferElement is part of, or nullptr if not in a ReadAnyGroup.
 

Friends

class TransferGroup
 

Additional Inherited Members

- Public Types inherited from ChimeraTK::NDRegisterAccessorAbstractor< UserType >
using value_type = UserType
 
- Protected Member Functions inherited from ChimeraTK::NDRegisterAccessorAbstractor< UserType >
 NDRegisterAccessorAbstractor (boost::shared_ptr< NDRegisterAccessor< UserType > > impl)
 
NDRegisterAccessor< UserType > * get ()
 
const NDRegisterAccessor< UserType > * get () const
 
- Protected Attributes inherited from ChimeraTK::TransferElementAbstractor
boost::shared_ptr< TransferElement_impl
 Untyped pointer to implementation.
 

Detailed Description

template<user_type UserType, typename TAG = std::nullptr_t>
class ChimeraTK::ScalarRegisterAccessor< UserType, TAG >

Accessor class to read and write scalar registers transparently by using the accessor object like a variable of the type UserType.

Conversion to and from the UserType will be handled by a data converter matching the register description in the map, if required. Obtain the accessor using the Device::getScalarRegisterAccessor() function.

Note: Transfers between the device and the internal buffer need to be triggered using the read() and write() functions before reading from resp. after writing to the buffer using the operators.

The second template argument TAG is only used to implement the template specialisation for ChimeraTK::Boolean without duplicating all code.

Examples
basic.cpp.

Definition at line 25 of file ScalarRegisterAccessor.h.

Constructor & Destructor Documentation

◆ ScalarRegisterAccessor() [1/2]

template<user_type UserType, typename TAG >
ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::ScalarRegisterAccessor ( boost::shared_ptr< NDRegisterAccessor< UserType > >  impl)

Create instance from pointer to implementation.

Attention
Do not normally use directly. Users should call Device::getScalarRegisterAccessor() to obtain an instance instead.

Definition at line 209 of file ScalarRegisterAccessor.h.

◆ ScalarRegisterAccessor() [2/2]

template<user_type UserType, typename TAG >
ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::ScalarRegisterAccessor ( )

Placeholder constructor, to allow late initialisation of the accessor, e.g.

in the open function.

Attention
Accessors created with this constructors will be dysfunctional, calling any member function will throw an exception (by the boost::shared_ptr)!

Definition at line 218 of file ScalarRegisterAccessor.h.

Member Function Documentation

◆ getAsCooked()

template<user_type UserType, typename TAG >
template<typename COOKED_TYPE >
COOKED_TYPE ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::getAsCooked ( )

Get the cooked values in case the accessor is a raw accessor (which does not do data conversion).

This returns the converted data from the user buffer. It does not do any read or write transfer.

Definition at line 262 of file ScalarRegisterAccessor.h.

◆ operator const ScalarRegisterAccessor< UserType, OTHER_TAG > &()

template<user_type UserType, typename TAG = std::nullptr_t>
template<typename OTHER_TAG >
ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::operator const ScalarRegisterAccessor< UserType, OTHER_TAG > & ( ) const
inline

Allow free conversion between different TAG template arguments (which is merely used to avoid code duplication in the template specialisation for ChimeraTK::Boolean).

Definition at line 66 of file ScalarRegisterAccessor.h.

◆ operator const UserType &()

template<user_type UserType, typename TAG = std::nullptr_t>
ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::operator const UserType & ( ) const
inline

Implicit type conversion to const UserType& to access the const reference.

Definition at line 50 of file ScalarRegisterAccessor.h.

◆ operator ScalarRegisterAccessor< UserType, OTHER_TAG > &()

template<user_type UserType, typename TAG >
template<typename OTHER_TAG >
ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::operator ScalarRegisterAccessor< UserType, OTHER_TAG > & ( )

Allow free conversion between different TAG template arguments (which is merely used to avoid code duplication in the template specialisation for ChimeraTK::Boolean).

Definition at line 228 of file ScalarRegisterAccessor.h.

◆ operator UserType &()

template<user_type UserType, typename TAG = std::nullptr_t>
ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::operator UserType & ( )
inline

Implicit type conversion to UserType& to access the value as a reference.

Definition at line 46 of file ScalarRegisterAccessor.h.

◆ operator++() [1/2]

template<user_type UserType, typename TAG = std::nullptr_t>
ScalarRegisterAccessor & ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::operator++ ( )
inline

Pre-increment operator for the first element.

Definition at line 74 of file ScalarRegisterAccessor.h.

◆ operator++() [2/2]

template<user_type UserType, typename TAG >
UserType ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::operator++ ( int  )

Post-increment operator for the first element.

Definition at line 243 of file ScalarRegisterAccessor.h.

◆ operator--() [1/2]

template<user_type UserType, typename TAG = std::nullptr_t>
ScalarRegisterAccessor & ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::operator-- ( )
inline

Pre-decrement operator for the first element.

Definition at line 77 of file ScalarRegisterAccessor.h.

◆ operator--() [2/2]

template<user_type UserType, typename TAG >
UserType ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::operator-- ( int  )

Post-decrement operator for the first element.

Definition at line 252 of file ScalarRegisterAccessor.h.

◆ operator=()

template<user_type UserType, typename TAG >
ScalarRegisterAccessor< UserType, TAG > & ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::operator= ( UserType  rightHandSide)

Assignment operator, assigns the first element.

Definition at line 235 of file ScalarRegisterAccessor.h.

◆ readAndGet()

template<user_type UserType, typename TAG >
UserType ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::readAndGet ( )

Convenience function to read and return a value of UserType.

Definition at line 301 of file ScalarRegisterAccessor.h.

◆ setAndWrite()

template<user_type UserType, typename TAG >
void ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::setAndWrite ( UserType  newValue,
VersionNumber  versionNumber = {} 
)

Convenience function to set and write new value.

The given version number. If versionNumber == {}, a new version number is generated.

Definition at line 293 of file ScalarRegisterAccessor.h.

◆ setAsCooked()

template<user_type UserType, typename TAG >
template<typename COOKED_TYPE >
void ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::setAsCooked ( COOKED_TYPE  value)

Set the cooked values in case the accessor is a raw accessor (which does not do data conversion).

This converts to raw and writes the data to the user buffer. It does not do any read or write transfer.

Definition at line 270 of file ScalarRegisterAccessor.h.

◆ writeIfDifferent()

template<user_type UserType, typename TAG >
void ChimeraTK::ScalarRegisterAccessor< UserType, TAG >::writeIfDifferent ( UserType  newValue,
VersionNumber  versionNumber = VersionNumber{nullptr},
DataValidity  validity = DataValidity::ok 
)

Convenience function to set and write new value if it differes from the current value.

The given version number is only used in case the value differs. If versionNumber == {nullptr}, a new version number is generated only if the write actually takes place.

Definition at line 277 of file ScalarRegisterAccessor.h.

Friends And Related Symbol Documentation

◆ TransferGroup

template<user_type UserType, typename TAG = std::nullptr_t>
friend class TransferGroup
friend

Definition at line 120 of file ScalarRegisterAccessor.h.


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