OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
AttributeHandler.h
Go to the documentation of this file.
1#ifndef OPAL_AttributeHandler_HH
2#define OPAL_AttributeHandler_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: AttributeHandler.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.1.1.1 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Class: AttributeHandler
13//
14// ------------------------------------------------------------------------
15//
16// $Date: 2000/03/27 09:33:34 $
17// $Author: Andreas Adelmann $
18//
19// ------------------------------------------------------------------------
20
21#include <memory.h>
22#include <cstring>
23#include <map>
24#include <memory>
25#include <set>
26#include <string>
28
29class Attribute;
30class Statement;
31
32// Class AttributeHandler
33// ------------------------------------------------------------------------
35// An attribute parser defines the data type for an attribute. It is
36// used to parse the attribute, to read the attribute from the DOOM data
37// base, and to write it to that data base. It contains the name and
38// help text for the attribute. Optionally it may also contain a default
39// value for the attribute.
40// [p]
41// When ``is_readonly'' is true, the attribute cannot be redefined by
42// the user.
43// [p]
44// When ``is_deferred'' is true, the attribute must be re-evaluated
45// whenever it is used. This is the case for random error values.
46// When ``is_deferred'' is false, any expression for the attribute is
47// cached. It is re-evaluated only when any other definition has changed.
48
50public:
52 // Assigns the attribute name [b]name[/b] and the help text [b]help[/b],
53 // as well as a possible default value [b]def[/b]for the attribute.
54 AttributeHandler(const std::string& name, const std::string& help, AttributeBase* def);
55
56 virtual ~AttributeHandler();
57
59 // Return the default value stored in this parser.
60 virtual AttributeBase* getDefault() const;
61
63 virtual const std::string& getHelp() const;
64
66 virtual const std::string& getName() const;
67
69 // Return a string describing the attribute type
70 // ("logical", "real", etc.).
71 virtual const std::string& getType() const = 0;
72
74 // Parse value from the statement [b]s[/b] and assign it to the
75 // attribute [b]a[/b].
76 virtual void parse(Attribute& a, Statement& s, bool eval) const = 0;
77
79 // Parse value from the statement [b]s[/b] and assign it to the
80 // attribute [b]a[/b], indexed by [b]i[/b].
81 // The default version assumes that the value is scalar,
82 // and it throws [b]OpalException[/b].
83 virtual void parseComponent(Attribute& a, Statement& s, bool eval, int i) const;
84
86 // True, if any expression evaluation is to be deferred.
87 // See [b]Expressions::ADeferred[/b] and [b]Expressions::SDeferred[/b]
88 // for details.
89 bool isDeferred() const;
90
92 // If the flag is set, expressions are evaluated only when the value
93 // is fetched.
94 void setDeferred(bool);
95
97 // If [b]parse[/b] is called with this flag set,
98 // then [b]OpalException[/b] is thrown.
99 bool isReadOnly() const;
100
102 // If [b]parse[/b] is called with the flag set,
103 // then [b]OpalException[/b] is thrown.
104 void setReadOnly(bool);
105
107 void setPredefinedValues(const std::set<std::string>&, const std::string&);
108
110
111 static std::multimap<OwnerType, std::string> getOwner(const std::string& att);
112 static void addAttributeOwner(
113 const std::string& owner, const OwnerType& type, const std::string& name);
114
115protected:
117 const std::string itsName;
118
120 const std::string itsHelp;
121
123 std::shared_ptr<AttributeBase> itsDefault;
124
127
130
131private:
132 // Not implemented.
136
137 static std::multimap<std::string, std::pair<OwnerType, std::string> >
139};
140
141#endif // OPAL_AttributeHandler_HH
Abstract base class for attribute values of different types.
Abstract base class for attribute parsers.
AttributeHandler(const AttributeHandler &)
void setDeferred(bool)
Set or reset defer flag.
const std::string itsHelp
Help text.
virtual AttributeBase * getDefault() const
Return default value.
bool isDeferred() const
Return defer flag.
static void addAttributeOwner(const std::string &owner, const OwnerType &type, const std::string &name)
bool is_deferred
Defer flag.
void setReadOnly(bool)
Set or reset read-only flag.
static std::multimap< std::string, std::pair< OwnerType, std::string > > attributeOwnerDictionary_s
virtual const std::string & getName() const
Return attribute name.
const std::string itsName
Attribute name.
virtual const std::string & getHelp() const
Return help string.
virtual const std::string & getType() const =0
Return attribute type.
virtual void parseComponent(Attribute &a, Statement &s, bool eval, int i) const
Parse component value.
bool isReadOnly() const
Return read-only flag.
virtual void parse(Attribute &a, Statement &s, bool eval) const =0
Parse new value.
void operator=(const AttributeHandler &)
static std::multimap< OwnerType, std::string > getOwner(const std::string &att)
bool is_readonly
Read-only flag.
void setPredefinedValues(const std::set< std::string > &, const std::string &)
Add predefined strings values to the help.
std::shared_ptr< AttributeBase > itsDefault
Default value.
A representation of an Object attribute.
Definition Attribute.h:52
Interface for statements.
Definition Statement.h:37