OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
BoolConstant.cpp
Go to the documentation of this file.
1//
2// Class BoolConstant
3// The BOOL CONSTANT definition.
4//
5// Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
19
21#include "Utilities/Options.h"
22
23#include <iostream>
24
25
27 ValueDefinition(1, "BOOL_CONSTANT",
28 "The \"BOOL CONSTANT\" statement defines a global "
29 "logical constant:\n"
30 "\tBOOL CONSTANT <name> = <Bool-expression>;\n") {
31 itsAttr[0] = Attributes::makeBool("VALUE", "The constant value");
32
34}
35
36
37BoolConstant::BoolConstant(const std::string &name, BoolConstant *parent):
38 ValueDefinition(name, parent)
39{}
40
41
43{}
44
45
47 return false;
48}
49
50
52 return new BoolConstant(name, this);
53}
54
55
58}
59
60
61void BoolConstant::print(std::ostream &os) const {
62 os << "BOOL CONST " << getOpalName() << '=' << itsAttr[0] << ';';
63 os << std::endl;
64}
65
66void BoolConstant::printValue(std::ostream &os) const {
67 os << itsAttr[0];
68}
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
const std::string name
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:90
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:100
The base class for all OPAL objects.
Definition: Object.h:48
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:191
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:310
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
The base class for all OPAL value definitions.
virtual ~BoolConstant()
virtual void print(std::ostream &) const
Print the constant.
BoolConstant()
Exemplar constructor.
virtual bool canReplaceBy(Object *object)
Test if object can be replaced.
virtual BoolConstant * clone(const std::string &name)
Make clone.
virtual bool getBool() const
Return value.
virtual void printValue(std::ostream &os) const
Print its value.