OPALX (Object Oriented Parallel Accelerator Library for Exascal)
master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
IndexedChannel.h
Go to the documentation of this file.
1
#ifndef OPALX_IndexedChannel_HH
2
#define OPALX_IndexedChannel_HH
3
4
// ------------------------------------------------------------------------
5
// $RCSfile: IndexedChannel.h,v $
6
// ------------------------------------------------------------------------
7
// $Revision: 1.1.1.1 $
8
// ------------------------------------------------------------------------
9
// Copyright: see Copyright.readme
10
// ------------------------------------------------------------------------
11
//
12
// Class: IndexedChannel
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 IndexedChannel
26
// ------------------------------------------------------------------------
28
// Template class IndirectChannel allows access to an indexed [b]double[/b]
29
// data member of an object.
30
31
template
<
class
T>
32
class
IndexedChannel
:
public
Channel
{
33
public
:
35
// The constructed channel provides access to an array of an object
36
// of class [b]T[/b]. The channel keeps a reference to [b]object[/b],
37
// the pointers to member [b]getF[/b] and [b]setF[/b], and the index
38
// [b]index[/b].
39
// [p]
40
// Values set are transmitted via [tt] object.*setF(index,value)[/tt]
41
// and read via [tt]value = object.*getF(index)[/tt].
42
IndexedChannel
(
43
T
&
object
,
double
(
T
::*
getF
)(
int
)
const
, void (
T
::*
setF
)(
int
,
double
),
int
index);
44
45
IndexedChannel
(
46
T
&
object
,
double
(
T
::*
getF
)(
int
)
const
, void (
T
::*
setF
)(
unsigned
int
,
double
),
47
int
index);
48
49
IndexedChannel
(
const
IndexedChannel
&);
50
virtual
~IndexedChannel
();
51
53
virtual
IndexedChannel
*
clone
()
const
;
54
56
// If the channel can be read, set [b]value[/b] and return true,
57
// otherwise return false.
58
virtual
bool
get
(
double
&)
const
;
59
61
// If the channel can be written, store [b]value[/b] into it and return true,
62
// otherwise return false.
63
virtual
bool
set
(
double
);
64
66
// Return true, if the channel can receive values, i.e. if the [b]sefF[/b]
67
// pointer is not nullptr.
68
virtual
bool
isSettable
()
const
;
69
70
private
:
71
// Not implemented.
72
IndexedChannel
();
73
const
IndexedChannel
&
operator=
(
const
IndexedChannel
&);
74
75
// Reference to the object to be set.
76
T
&
itsObject
;
77
78
// The get and set functions for the channel.
79
double (
T
::*
getF
)(int) const;
80
void (
T
::*
setF
)(int, double);
81
82
// The bias to be transmitted to the set() or get() method.
83
int
bias
;
84
};
85
86
template
<
class
T>
87
IndexedChannel<T>::IndexedChannel
(
88
T
&
object
,
double
(
T
::*get)(int) const, void (
T
::*set)(int, double), int index)
89
: itsObject(object), getF(get), setF(set), bias(index) {}
90
91
template
<
class
T>
92
IndexedChannel<T>::IndexedChannel
(
93
T
&
object
,
double
(
T
::*get)(int) const, void (
T
::*set)(unsigned int, double), int index)
94
: itsObject(object), getF(get), setF(set), bias(index) {}
95
96
template
<
class
T>
97
IndexedChannel<T>::IndexedChannel
(
const
IndexedChannel
& rhs)
98
:
Channel
(), itsObject(rhs.itsObject), getF(rhs.getF), setF(rhs.setF), bias(rhs.bias) {}
99
100
template
<
class
T>
101
IndexedChannel<T>::~IndexedChannel
() {}
102
103
template
<
class
T>
104
IndexedChannel<T>
*
IndexedChannel<T>::clone
()
const
{
105
return
new
IndexedChannel
(*
this
);
106
}
107
108
template
<
class
T>
109
bool
IndexedChannel<T>::get
(
double
& value)
const
{
110
value = (itsObject.*getF)(bias);
111
return
true
;
112
}
113
114
template
<
class
T>
115
bool
IndexedChannel<T>::set
(
double
value) {
116
if
(setF != 0) {
117
(itsObject.*setF)(bias, value);
118
return
true
;
119
}
else
{
120
return
false
;
121
}
122
}
123
124
template
<
class
T>
125
bool
IndexedChannel<T>::isSettable
()
const
{
126
return
(setF != 0);
127
}
128
129
#endif
// OPALX_IndexedChannel_HH
Channel.h
T
double T
Definition
OPALTypes.h:8
Channel
Abstract interface for read/write access to variable.
Definition
Channel.h:30
IndexedChannel
Access to an indexed [b]double[/b] data member.
Definition
IndexedChannel.h:32
IndexedChannel::bias
int bias
Definition
IndexedChannel.h:83
IndexedChannel::clone
virtual IndexedChannel * clone() const
Duplicate the channel.
Definition
IndexedChannel.h:104
IndexedChannel::~IndexedChannel
virtual ~IndexedChannel()
Definition
IndexedChannel.h:101
IndexedChannel::itsObject
T & itsObject
Definition
IndexedChannel.h:76
IndexedChannel::IndexedChannel
IndexedChannel()
IndexedChannel::getF
double(T::* getF)(int) const
Definition
IndexedChannel.h:79
IndexedChannel::set
virtual bool set(double)
Store into channel.
Definition
IndexedChannel.h:115
IndexedChannel::operator=
const IndexedChannel & operator=(const IndexedChannel &)
IndexedChannel::isSettable
virtual bool isSettable() const
Test if settable.
Definition
IndexedChannel.h:125
IndexedChannel::get
virtual bool get(double &) const
Fetch from channel.
Definition
IndexedChannel.h:109
IndexedChannel::setF
void(T::* setF)(int, double)
Definition
IndexedChannel.h:80
src
Channels
IndexedChannel.h
Generated on Mon Jun 1 2026 10:40:52 for OPALX (Object Oriented Parallel Accelerator Library for Exascal) by
1.9.8