OPAL (Object Oriented Parallel Accelerator Library)
2024.2
OPAL
src
Classic
Channels
IndirectChannel.h
Go to the documentation of this file.
1
#ifndef CLASSIC_IndirectChannel_HH
2
#define CLASSIC_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
26
// Class IndirectChannel
27
// ------------------------------------------------------------------------
29
// Template class IndirectChannel allows access to a [b]double[/b] data
30
// member of an object.
31
32
template
<
class
T>
class
IndirectChannel
:
public
Channel
{
33
34
public
:
35
37
// The constructed channel provides access to a member of an object
38
// of class [b]T[/b]. The channel keeps a reference to [b]object[/b]
39
// and the pointers to member [b]getF[/b] and [b]setF[/b].
40
// Values set are transmitted via object.*setF(value)
41
// and read via value = object.*getF().
42
IndirectChannel
(T &
object
,
double
(T::*
getF
)()
const
,
43
void (T::*
setF
)(
double
));
44
45
IndirectChannel
(
const
IndirectChannel
&);
46
virtual
~IndirectChannel
();
47
49
virtual
IndirectChannel
*
clone
()
const
;
50
52
// If the channel can be read, set [b]value[/b] and return true,
53
// otherwise return false.
54
virtual
bool
get
(
double
&)
const
;
55
57
// If the channel can be written,
58
// store [b]value[/b] into it and return true,
59
// otherwise return false.
60
virtual
bool
set
(
double
);
61
63
// Return true, if the channel can be written, i.e. if the set
64
// method pointer is not nullptr
65
virtual
bool
isSettable
()
const
;
66
67
private
:
68
69
// Not implemented.
70
IndirectChannel
();
71
const
IndirectChannel
&
operator=
(
const
IndirectChannel
&);
72
73
// Reference to the object to be set.
74
T &
itsObject
;
75
76
// The get and set functions for the channel.
77
double(T::*
getF
)() const;
78
void (T::*
setF
)(double);
79
};
80
81
82
template
<
class
T>
83
IndirectChannel<T>::IndirectChannel
(T &
object
,
double
(T::*get)() const,
84
void (T::*set)(double)):
85
itsObject(object), getF(get), setF(set)
86
{}
87
88
89
template
<
class
T>
90
IndirectChannel<T>::IndirectChannel
(
const
IndirectChannel
&rhs):
91
Channel
(),
92
itsObject(rhs.itsObject), getF(rhs.getF), setF(rhs.setF)
93
{}
94
95
96
template
<
class
T>
97
IndirectChannel<T>::~IndirectChannel
()
98
{}
99
100
101
template
<
class
T>
102
IndirectChannel<T>
*
IndirectChannel<T>::clone
()
const
{
103
return
new
IndirectChannel
(*
this
);
104
}
105
106
107
template
<
class
T>
108
bool
IndirectChannel<T>::get
(
double
&value)
const
{
109
value = (itsObject.*getF)();
110
return
true
;
111
}
112
113
114
template
<
class
T>
115
bool
IndirectChannel<T>::set
(
double
value) {
116
if
(setF != 0) {
117
(itsObject.*setF)(value);
118
return
true
;
119
}
else
{
120
return
false
;
121
}
122
}
123
124
125
template
<
class
T>
inline
126
bool
IndirectChannel<T>::isSettable
()
const
{
127
return
(setF != 0);
128
}
129
130
#endif
// CLASSIC_IndirectChannel_HH
Channel.h
Channel
Abstract interface for read/write access to variable.
Definition
Channel.h:32
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:108
IndirectChannel::isSettable
virtual bool isSettable() const
Test if settable.
Definition
IndirectChannel.h:126
IndirectChannel::itsObject
T & itsObject
Definition
IndirectChannel.h:74
IndirectChannel::clone
virtual IndirectChannel * clone() const
Duplicate the channel.
Definition
IndirectChannel.h:102
IndirectChannel::setF
void(T::* setF)(double)
Definition
IndirectChannel.h:78
IndirectChannel::IndirectChannel
IndirectChannel()
IndirectChannel::getF
double(T::* getF)() const
Definition
IndirectChannel.h:77
IndirectChannel::set
virtual bool set(double)
Store into channel.
Definition
IndirectChannel.h:115
IndirectChannel::operator=
const IndirectChannel & operator=(const IndirectChannel &)
IndirectChannel::~IndirectChannel
virtual ~IndirectChannel()
Definition
IndirectChannel.h:97
Generated on Tue Apr 14 2026 07:18:45 for OPAL (Object Oriented Parallel Accelerator Library) by
1.9.8