OPALX (Object Oriented Parallel Accelerator Library for Exascal)
master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
IndirectChannel.h
Go to the documentation of this file.
1
#ifndef OPALX_IndirectChannel_HH
2
#define OPALX_IndirectChannel_HH
3
4
// ------------------------------------------------------------------------
5
// $RCSfile: IndirectChannel.h,v $
6
// ------------------------------------------------------------------------
7
// $Revision: 1.1.1.1 $
8
// ------------------------------------------------------------------------
9
// Copyright: see Copyright.readme
10
// ------------------------------------------------------------------------
11
//
12
// Class: IndirectChannel
13
//
14
// ------------------------------------------------------------------------
15
// Class category: Channels
16
// ------------------------------------------------------------------------
17
//
18
// $Date: 2000/03/27 09:32:35 $
19
// $Author: fci $
20
//
21
// ------------------------------------------------------------------------
22
23
#include "
Channels/Channel.h
"
24
25
// Class IndirectChannel
26
// ------------------------------------------------------------------------
28
// Template class IndirectChannel allows access to a [b]double[/b] data
29
// member of an object.
30
31
template
<
class
T>
32
class
IndirectChannel
:
public
Channel
{
33
public
:
35
// The constructed channel provides access to a member of an object
36
// of class [b]T[/b]. The channel keeps a reference to [b]object[/b]
37
// and the pointers to member [b]getF[/b] and [b]setF[/b].
38
// Values set are transmitted via object.*setF(value)
39
// and read via value = object.*getF().
40
IndirectChannel
(
T
&
object
,
double
(
T
::*
getF
)()
const
, void (
T
::*
setF
)(
double
));
41
42
IndirectChannel
(
const
IndirectChannel
&);
43
virtual
~IndirectChannel
();
44
46
virtual
IndirectChannel
*
clone
()
const
;
47
49
// If the channel can be read, set [b]value[/b] and return true,
50
// otherwise return false.
51
virtual
bool
get
(
double
&)
const
;
52
54
// If the channel can be written,
55
// store [b]value[/b] into it and return true,
56
// otherwise return false.
57
virtual
bool
set
(
double
);
58
60
// Return true, if the channel can be written, i.e. if the set
61
// method pointer is not nullptr
62
virtual
bool
isSettable
()
const
;
63
64
private
:
65
// Not implemented.
66
IndirectChannel
();
67
const
IndirectChannel
&
operator=
(
const
IndirectChannel
&);
68
69
// Reference to the object to be set.
70
T
&
itsObject
;
71
72
// The get and set functions for the channel.
73
double (
T
::*
getF
)() const;
74
void (
T
::*
setF
)(double);
75
};
76
77
template
<
class
T>
78
IndirectChannel<T>::IndirectChannel
(
T
&
object
,
double
(
T
::*get)() const, void (
T
::*set)(double))
79
: itsObject(object), getF(get), setF(set) {}
80
81
template
<
class
T>
82
IndirectChannel<T>::IndirectChannel
(
const
IndirectChannel
& rhs)
83
:
Channel
(), itsObject(rhs.itsObject), getF(rhs.getF), setF(rhs.setF) {}
84
85
template
<
class
T>
86
IndirectChannel<T>::~IndirectChannel
() {}
87
88
template
<
class
T>
89
IndirectChannel<T>
*
IndirectChannel<T>::clone
()
const
{
90
return
new
IndirectChannel
(*
this
);
91
}
92
93
template
<
class
T>
94
bool
IndirectChannel<T>::get
(
double
& value)
const
{
95
value = (itsObject.*getF)();
96
return
true
;
97
}
98
99
template
<
class
T>
100
bool
IndirectChannel<T>::set
(
double
value) {
101
if
(setF != 0) {
102
(itsObject.*setF)(value);
103
return
true
;
104
}
else
{
105
return
false
;
106
}
107
}
108
109
template
<
class
T>
110
inline
bool
IndirectChannel<T>::isSettable
()
const
{
111
return
(setF != 0);
112
}
113
114
#endif
// OPALX_IndirectChannel_HH
Channel.h
T
double T
Definition
OPALTypes.h:8
Channel
Abstract interface for read/write access to variable.
Definition
Channel.h:30
IndirectChannel
Access to a [b]double[/b] data member.
Definition
IndirectChannel.h:32
IndirectChannel::get
virtual bool get(double &) const
Fetch from channel.
Definition
IndirectChannel.h:94
IndirectChannel::isSettable
virtual bool isSettable() const
Test if settable.
Definition
IndirectChannel.h:110
IndirectChannel::itsObject
T & itsObject
Definition
IndirectChannel.h:70
IndirectChannel::clone
virtual IndirectChannel * clone() const
Duplicate the channel.
Definition
IndirectChannel.h:89
IndirectChannel::setF
void(T::* setF)(double)
Definition
IndirectChannel.h:74
IndirectChannel::IndirectChannel
IndirectChannel()
IndirectChannel::getF
double(T::* getF)() const
Definition
IndirectChannel.h:73
IndirectChannel::set
virtual bool set(double)
Store into channel.
Definition
IndirectChannel.h:100
IndirectChannel::operator=
const IndirectChannel & operator=(const IndirectChannel &)
IndirectChannel::~IndirectChannel
virtual ~IndirectChannel()
Definition
IndirectChannel.h:86
src
Channels
IndirectChannel.h
Generated on Mon Jun 1 2026 10:40:52 for OPALX (Object Oriented Parallel Accelerator Library for Exascal) by
1.9.8