OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
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 
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.
72 
73  // Reference to the object to be set.
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>
91  Channel(),
92  itsObject(rhs.itsObject), getF(rhs.getF), setF(rhs.setF)
93 {}
94 
95 
96 template <class T>
98 {}
99 
100 
101 template <class T>
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
127  return (setF != 0);
128 }
129 
130 #endif // CLASSIC_IndirectChannel_HH
const IndirectChannel & operator=(const IndirectChannel &)
virtual bool set(double)
Store into channel.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE:162
virtual IndirectChannel * clone() const
Duplicate the channel.
virtual bool isSettable() const
Test if settable.
set(_SRCS Action.cpp Attribute.cpp AttributeBase.cpp AttributeHandler.cpp BeamSequence.cpp Definition.cpp Directory.cpp Element.cpp Invalidator.cpp OpalData.cpp Object.cpp ObjectFunction.cpp PlaceRep.cpp RangeRep.cpp Table.cpp TableRowRep.cpp ValueDefinition.cpp) include_directories($
Definition: CMakeLists.txt:1
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Access to a [b]double[/b] data member.
void(T::* setF)(double)
double(T::* getF)() const
virtual ~IndirectChannel()
virtual bool get(double &) const
Fetch from channel.