OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Bool.cpp
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2// $RCSfile: Bool.cpp,v $
3// ------------------------------------------------------------------------
4// $Revision: 1.1.1.1 $
5// ------------------------------------------------------------------------
6// Copyright: see Copyright.readme
7// ------------------------------------------------------------------------
8//
9// Class Attributes::Bool
10// A class used to parse boolean attributes.
11//
12// ------------------------------------------------------------------------
13//
14// $Date: 2000/03/27 09:33:36 $
15// $Author: Andreas Adelmann $
16//
17// ------------------------------------------------------------------------
18
19#include "Attributes/Bool.h"
23#include "Expressions/SValue.h"
25#include "Parser/StringStream.h"
26#include "Parser/Token.h"
29
30using namespace Expressions;
31using std::cerr;
32using std::endl;
33
34
35// Class Attributes::Bool
36// ------------------------------------------------------------------------
37
38namespace Attributes {
39
40 Bool::Bool(const std::string &name, const std::string &help):
41 AttributeHandler(name, help, new SValue<bool>(true))
42 {}
43
44
46 {}
47
48 const std::string &Bool::getType() const {
49 static const std::string type("logical");
50 return type;
51 }
52
53 void Bool::parse(Attribute &attr, Statement &stat, bool eval) const {
54 PtrToScalar<bool> expr = parseBool(stat);
55
56 if(eval || expr->isConstant()) {
57 attr.set(new SValue<bool>(expr->evaluate()));
58 } else if(is_deferred) {
59 attr.set(new SDeferred<bool>(expr));
60 } else {
61 attr.set(new SAutomatic<bool>(expr));
62 }
63 }
64
65};
const std::string name
Representation objects and parsers for attribute expressions.
PtrToScalar< bool > parseBool(Statement &)
Parse boolean expression.
A collection of routines to construct object Attributes and retrieve.
A representation of an Object attribute.
Definition Attribute.h:52
void set(AttributeBase *newBase)
Define new value.
bool is_deferred
Defer flag.
AttributeHandler(const std::string &name, const std::string &help, AttributeBase *def)
Constructor.
A pointer to a scalar expression.
virtual const std::string & getType() const
Return attribute type string ``logical''.
Definition Bool.cpp:48
virtual ~Bool()
Definition Bool.cpp:45
virtual void parse(Attribute &, Statement &, bool) const
Parse the attribute.
Definition Bool.cpp:53
Interface for statements.
Definition Statement.h:38
Object attribute with an ``automatic'' scalar value.
Definition SAutomatic.h:38
Object attribute with a ``deferred'' scalar value.
Definition SDeferred.h:39
Object attribute with a constant scalar value.
Definition SValue.h:34