OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
BoolConstant.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: BoolConstant.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.2 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: BoolConstant
10 // Implements a BOOL_CONSTANT definition.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2001/08/13 15:26:42 $
15 // $Author: jowett $
16 //
17 // ------------------------------------------------------------------------
18 
20 #include "Attributes/Attributes.h"
21 #include "Utilities/Options.h"
22 #include <iostream>
23 
24 
25 // Class BoolConstant
26 // ------------------------------------------------------------------------
27 
29  ValueDefinition(1, "BOOL_CONSTANT",
30  "The \"BOOL CONSTANT\" statement defines a global "
31  "logical constant:\n"
32  "\tBOOL CONSTANT <name> = <Bool-expression>;\n") {
33  itsAttr[0] = Attributes::makeBool("VALUE", "The constant value");
34 
36 }
37 
38 
39 BoolConstant::BoolConstant(const std::string &name, BoolConstant *parent):
40  ValueDefinition(name, parent)
41 {}
42 
43 
45 {}
46 
47 
49  return false;
50 }
51 
52 
53 BoolConstant *BoolConstant::clone(const std::string &name) {
54  return new BoolConstant(name, this);
55 }
56 
57 
58 bool BoolConstant::getBool() const {
59  return Attributes::getBool(itsAttr[0]);
60 }
61 
62 
63 void BoolConstant::print(std::ostream &os) const {
64  os << "BOOL CONST " << getOpalName() << '=' << itsAttr[0] << ';';
65  os << std::endl;
66 }
67 
68 void BoolConstant::printValue(std::ostream &os) const {
69  os << itsAttr[0];
70 }
virtual void print(std::ostream &) const
Print the constant.
virtual BoolConstant * clone(const std::string &name)
Make clone.
virtual void printValue(std::ostream &os) const
Print its value.
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
BoolConstant()
Exemplar constructor.
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:66
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:284
virtual bool getBool() const
Return value.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:194
The base class for all OPAL objects.
Definition: Object.h:48
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:56
The base class for all OPAL value definitions.
The BOOL CONSTANT definition.
Definition: BoolConstant.h:27
const std::string name
virtual bool canReplaceBy(Object *object)
Test if object can be replaced.
virtual ~BoolConstant()
Inform & endl(Inform &inf)
Definition: Inform.cpp:42