OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
DirectChannel.h
Go to the documentation of this file.
1#ifndef OPALX_DirectChannel_HH
2#define OPALX_DirectChannel_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: DirectChannel.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.1.1.1 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Class: DirectChannel
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 DirectChannel
26// ------------------------------------------------------------------------
28// Class DirectChannel allows direct access to a [b]double[/b] variable.
29
30class DirectChannel : public Channel {
31public:
33 // The constructed channel gives read/write access to the variable
34 // [b]value[/b]. The variable [b]value[/b] must not be destroyed as
35 // long as this channel is active.
36 explicit DirectChannel(double& value);
37
39 virtual ~DirectChannel();
40
42 virtual DirectChannel* clone() const;
43
45 // If the channel can be written,
46 // store [b]value[/b] into it and return true,
47 // otherwise return false.
48 virtual bool set(double);
49
51 // If the channel can be read, set [b]value[/b] and return true,
52 // otherwise return false.
53 virtual bool get(double&) const;
54
55private:
56 // Not implemented.
59
60 // The address of the variable to be read or written.
61 double& reference;
62};
63
64inline DirectChannel::DirectChannel(double& value) : reference(value) {}
65
67 : Channel(), reference(rhs.reference) {}
68
70
71inline DirectChannel* DirectChannel::clone() const { return new DirectChannel(*this); }
72
73inline bool DirectChannel::set(double value) {
74 reference = value;
75 return true;
76}
77
78inline bool DirectChannel::get(double& value) const {
79 value = reference;
80 return true;
81}
82
83#endif // OPALX_DirectChannel_HH
Abstract interface for read/write access to variable.
Definition Channel.h:30
Direct access to a [b]double[/b] variable.
const DirectChannel & operator=(const DirectChannel &)
virtual ~DirectChannel()
virtual DirectChannel * clone() const
Duplicate the channel.
virtual bool set(double)
Store into channel.
double & reference
virtual bool get(double &) const
Fetch from channel.