ChimeraTK-DeviceAccess
03.18.00
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
5
#include "
ForwardDeclarations.h
"
6
#include "
NDRegisterAccessor.h
"
7
#include "
TransferElementAbstractor.h
"
8
9
namespace
ChimeraTK
{
10
11
/********************************************************************************************************************/
12
18
template
<
typename
UserType>
19
class
NDRegisterAccessorAbstractor
:
public
TransferElementAbstractor
{
20
public
:
24
NDRegisterAccessorAbstractor
() =
default
;
25
29
NDRegisterAccessorAbstractor
(
const
NDRegisterAccessorAbstractor
&) =
default
;
30
37
void
replace
(
const
NDRegisterAccessorAbstractor<UserType>
& newAccessor);
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
protected
:
54
explicit
NDRegisterAccessorAbstractor
(boost::shared_ptr<
NDRegisterAccessor<UserType>
> impl);
55
56
/*
57
* Obtain the plain pointer to the implementation. Use the pointer carefully only inside this class, since it is not
58
* a shared pointer!
59
*/
60
NDRegisterAccessor<UserType>
*
get
();
61
const
NDRegisterAccessor<UserType>
*
get
()
const
;
62
};
63
64
/********************************************************************************************************************/
65
66
template
<
typename
UserType>
67
void
NDRegisterAccessorAbstractor<UserType>::replace
(
const
NDRegisterAccessorAbstractor<UserType>
& newAccessor) {
68
_impl = newAccessor.
_impl
;
69
}
70
/********************************************************************************************************************/
71
72
template
<
typename
UserType>
73
void
NDRegisterAccessorAbstractor<UserType>::replace
(boost::shared_ptr<
NDRegisterAccessor<UserType>
> newImpl) {
74
_impl = boost::static_pointer_cast<TransferElement>(newImpl);
75
}
76
77
/********************************************************************************************************************/
78
79
template
<
typename
UserType>
80
NDRegisterAccessor<UserType>
*
NDRegisterAccessorAbstractor<UserType>::get
() {
81
return
static_cast<
NDRegisterAccessor<UserType>
*
>
(
TransferElementAbstractor::_impl
.get());
82
}
83
84
/********************************************************************************************************************/
85
86
template
<
typename
UserType>
87
const
NDRegisterAccessor<UserType>
*
NDRegisterAccessorAbstractor<UserType>::get
()
const
{
88
return
static_cast<
NDRegisterAccessor<UserType>
*
>
(
TransferElementAbstractor::_impl
.get());
89
}
90
91
/********************************************************************************************************************/
92
93
template
<
typename
UserType>
94
NDRegisterAccessorAbstractor<UserType>::NDRegisterAccessorAbstractor
(
95
boost::shared_ptr<
NDRegisterAccessor<UserType>
> impl)
96
:
TransferElementAbstractor
(impl) {}
97
98
/********************************************************************************************************************/
99
100
template
<
typename
UserType>
101
boost::shared_ptr<NDRegisterAccessor<UserType>>
NDRegisterAccessorAbstractor<UserType>::getImpl
() {
102
return
boost::dynamic_pointer_cast<NDRegisterAccessor<UserType>>(_impl);
103
}
104
105
/********************************************************************************************************************/
106
107
// Do not declare the template for all user types as extern here.
108
// This could avoid optimisation of the inline code.
109
110
}
// namespace ChimeraTK
ForwardDeclarations.h
ChimeraTK::TransferElementAbstractor
Base class for register accessors abstractors independent of the UserType.
Definition:
TransferElementAbstractor.h:28
ChimeraTK::NDRegisterAccessorAbstractor::replace
void replace(const NDRegisterAccessorAbstractor< UserType > &newAccessor)
Assign a new accessor to this NDRegisterAccessorAbstractor.
Definition:
NDRegisterAccessorAbstractor.h:67
ChimeraTK::NDRegisterAccessorAbstractor::getImpl
boost::shared_ptr< NDRegisterAccessor< UserType > > getImpl()
Definition:
NDRegisterAccessorAbstractor.h:101
NDRegisterAccessor.h
TransferElementAbstractor.h
ChimeraTK::NDRegisterAccessorAbstractor
Base class for the register accessor abstractors (ScalarRegisterAccessor, OneDRegisterAccessor and Tw...
Definition:
NDRegisterAccessorAbstractor.h:19
ChimeraTK::NDRegisterAccessorAbstractor::operator=
const NDRegisterAccessorAbstractor & operator=(const NDRegisterAccessorAbstractor &rightHandSide) const =delete
Prevent copying by operator=, since it will be confusing (operator= may also be overloaded to access ...
ChimeraTK::NDRegisterAccessorAbstractor::NDRegisterAccessorAbstractor
NDRegisterAccessorAbstractor()=default
Create an uninitialised abstractor - just for late initialisation.
ChimeraTK::NDRegisterAccessorAbstractor::get
NDRegisterAccessor< UserType > * get()
Definition:
NDRegisterAccessorAbstractor.h:80
ChimeraTK::TransferElementAbstractor::_impl
boost::shared_ptr< TransferElement > _impl
Untyped pointer to implementation.
Definition:
TransferElementAbstractor.h:225
ChimeraTK
Definition:
DummyBackend.h:16
ChimeraTK::NDRegisterAccessor
N-dimensional register accessor.
Definition:
ForwardDeclarations.h:17
sources
ChimeraTK-DeviceAccess
include
NDRegisterAccessorAbstractor.h
Generated by
1.8.17