ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
NDRegisterAccessorAbstractor.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
8
9namespace ChimeraTK {
10
11 /********************************************************************************************************************/
12
18 template<user_type UserType>
20 public:
25
30
38
43 void replace(boost::shared_ptr<NDRegisterAccessor<UserType>> newImpl);
44
49 const NDRegisterAccessorAbstractor& operator=(const NDRegisterAccessorAbstractor& rightHandSide) const = delete;
50
51 boost::shared_ptr<NDRegisterAccessor<UserType>> getImpl();
52
53 using value_type = UserType;
54
55 protected:
57
58 /*
59 * Obtain the plain pointer to the implementation. Use the pointer carefully only inside this class, since it is not
60 * a shared pointer!
61 */
64 };
65
66 /********************************************************************************************************************/
67
68 template<user_type UserType>
72 /********************************************************************************************************************/
73
74 template<user_type UserType>
76 _impl = boost::static_pointer_cast<TransferElement>(newImpl);
77 }
78
79 /********************************************************************************************************************/
80
81 template<user_type UserType>
85
86 /********************************************************************************************************************/
87
88 template<user_type UserType>
92
93 /********************************************************************************************************************/
94
95 template<user_type UserType>
99
100 /********************************************************************************************************************/
101
102 template<user_type UserType>
103 boost::shared_ptr<NDRegisterAccessor<UserType>> NDRegisterAccessorAbstractor<UserType>::getImpl() {
104 return boost::dynamic_pointer_cast<NDRegisterAccessor<UserType>>(_impl);
105 }
106
107 /********************************************************************************************************************/
108 /********************************************************************************************************************/
109
113 template<typename T>
114 concept accessor_abstractor = requires {
115 typename T::value_type;
116 requires std::is_base_of<NDRegisterAccessorAbstractor<typename T::value_type>, T>::value;
118 };
119
120 /********************************************************************************************************************/
121 /********************************************************************************************************************/
122
123 // Do not declare the template for all user types as extern here.
124 // This could avoid optimisation of the inline code.
125
126} // namespace ChimeraTK
Base class for the register accessor abstractors (ScalarRegisterAccessor, OneDRegisterAccessor and Tw...
NDRegisterAccessorAbstractor(boost::shared_ptr< NDRegisterAccessor< UserType > > impl)
boost::shared_ptr< NDRegisterAccessor< UserType > > getImpl()
NDRegisterAccessorAbstractor(const NDRegisterAccessorAbstractor &)=default
Declare that we want the default copy constructor although we delete the assigmnent operator.
void replace(boost::shared_ptr< NDRegisterAccessor< UserType > > newImpl)
Alternative signature of replace() with the same functionality, used when a pointer to the implementa...
const NDRegisterAccessorAbstractor & operator=(const NDRegisterAccessorAbstractor &rightHandSide) const =delete
Prevent copying by operator=, since it will be confusing (operator= may also be overloaded to access ...
const NDRegisterAccessor< UserType > * get() const
NDRegisterAccessorAbstractor()=default
Create an uninitialised abstractor - just for late initialisation.
void replace(const NDRegisterAccessorAbstractor< UserType > &newAccessor)
Assign a new accessor to this NDRegisterAccessorAbstractor.
N-dimensional register accessor.
Base class for register accessors abstractors independent of the UserType.
boost::shared_ptr< TransferElement > _impl
Untyped pointer to implementation.
Concept requiring a type to be an NDRegisterAccessorAbstractor-derived type.
Concept requiring a type to be one of the supported ChimeraTK UserTypes.