OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
AAutomatic.h
Go to the documentation of this file.
1#ifndef OPAL_AAutomatic_HH
2#define OPAL_AAutomatic_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: AAutomatic.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.1.1.1.4.1 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Template class: AAutomatic<T>
13//
14// ------------------------------------------------------------------------
15//
16// $Date: 2004/11/18 22:52:40 $
17// $Author: jsberg $
18//
19// ------------------------------------------------------------------------
20
24
25namespace Expressions {
26
27 // Template class AAutomatic
28 // ----------------------------------------------------------------------
30 // An automatic expression is marked as unknown and registered in a list
31 // when it is created. When its value is required, it is evaluated,
32 // marked as known, and the new value is cached. Whenever a new
33 // definition is read, or an existing one is changed, the expressions
34 // are all marked as unknown. This forces a new evaluation when an
35 // exoression is used the next time.
36
37 template <class T>
38 class AAutomatic : public ADeferred<T> {
39 public:
41 // From array of expressions.
42 explicit AAutomatic(PtrToArray<T> expr);
43
45 // From array expression.
46 explicit AAutomatic(ArrayOfPtrs<T> expr);
47
49 virtual ~AAutomatic();
50
52 virtual AAutomatic<T>* clone() const;
53
55 // The resulting value is cached.
56 virtual std::vector<T> evaluate();
57
59 // Mark as unknown to force re-evaluation of expression.
60 virtual void invalidate();
61
62 private:
63 // Not implemented.
65 void operator=(const AAutomatic&);
66
67 // Is the expression known ?
68 mutable bool is_known;
69 };
70
71 // Implementation
72 // ----------------------------------------------------------------------
73
74 template <class T>
75 AAutomatic<T>::AAutomatic(const AAutomatic<T>& rhs) : ADeferred<T>(rhs), is_known(false) {
77 }
78
79 template <class T>
83
84 template <class T>
88
89 template <class T>
91 // Unlink expression from expression list.
93 }
94
95 template <class T>
97 return new AAutomatic<T>(*this);
98 }
99
100 template <class T>
101 std::vector<T> AAutomatic<T>::evaluate() {
102 if (!is_known) {
104 is_known = true;
105 }
106
107 return this->value;
108 }
109
110 template <class T>
112 is_known = false;
113 }
114
115} // namespace Expressions
116
117#endif // OPAL_AAutomatic_HH
double T
Definition OPALTypes.h:8
Object attribute with an `‘automatic’' array value.
Definition AAutomatic.h:38
virtual std::vector< T > evaluate()
Evaluate.
Definition AAutomatic.h:101
virtual void invalidate()
Invalidate.
Definition AAutomatic.h:111
AAutomatic(const AAutomatic &)
virtual AAutomatic< T > * clone() const
Make a clone.
Definition AAutomatic.h:96
void operator=(const AAutomatic &)
Object attribute with a `‘deferred’' array value.
Definition ADeferred.h:40
virtual std::vector< T > evaluate()
Evaluate.
Definition ADeferred.h:136
An array of pointers to scalar expressions.
A pointer to an array expression.
void registerExpression(AttributeBase *)
Register expression.
Definition OpalData.cpp:553
void unregisterExpression(AttributeBase *)
Unregister expression.
Definition OpalData.cpp:555
static OpalData * getInstance()
Definition OpalData.cpp:193
Representation objects and parsers for attribute expressions.