Commit 4022141e authored by ext-calvo_p's avatar ext-calvo_p
Browse files

Resolve "Extend the list of symbolic constant"

parent cefb9216
// ------------------------------------------------------------------------
// $RCSfile: BoolConstant.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.2 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
// //
// Class: BoolConstant // Class BoolConstant
// Implements a BOOL_CONSTANT definition. // The BOOL CONSTANT definition.
// //
// ------------------------------------------------------------------------ // Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
// //
// $Date: 2001/08/13 15:26:42 $ // This file is part of OPAL.
// $Author: jowett $ //
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
// ------------------------------------------------------------------------
#include "ValueDefinitions/BoolConstant.h" #include "ValueDefinitions/BoolConstant.h"
#include "Attributes/Attributes.h" #include "Attributes/Attributes.h"
#include "Utilities/Options.h" #include "Utilities/Options.h"
#include <iostream>
#include <iostream>
// Class BoolConstant
// ------------------------------------------------------------------------
BoolConstant::BoolConstant(): BoolConstant::BoolConstant():
ValueDefinition(1, "BOOL_CONSTANT", ValueDefinition(1, "BOOL_CONSTANT",
...@@ -67,4 +65,4 @@ void BoolConstant::print(std::ostream &os) const { ...@@ -67,4 +65,4 @@ void BoolConstant::print(std::ostream &os) const {
void BoolConstant::printValue(std::ostream &os) const { void BoolConstant::printValue(std::ostream &os) const {
os << itsAttr[0]; os << itsAttr[0];
} }
\ No newline at end of file
#ifndef OPAL_BoolConstant_HH
#define OPAL_BoolConstant_HH
// ------------------------------------------------------------------------
// $RCSfile: BoolConstant.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
// //
// Class: BoolConstant // Class BoolConstant
// The BOOL CONSTANT definition.
//
// Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// This file is part of OPAL.
// //
// ------------------------------------------------------------------------ // OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// $Date: 2000/03/27 09:33:49 $ // You should have received a copy of the GNU General Public License
// $Author: Andreas Adelmann $ // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
// ------------------------------------------------------------------------ #ifndef OPAL_BoolConstant_HH
#define OPAL_BoolConstant_HH
#include "AbstractObjects/ValueDefinition.h" #include "AbstractObjects/ValueDefinition.h"
// Class BoolConstant
// ------------------------------------------------------------------------
/// The BOOL CONSTANT definition.
class BoolConstant: public ValueDefinition { class BoolConstant: public ValueDefinition {
public: public:
...@@ -59,4 +56,4 @@ private: ...@@ -59,4 +56,4 @@ private:
BoolConstant(const std::string &name, BoolConstant *parent); BoolConstant(const std::string &name, BoolConstant *parent);
}; };
#endif // OPAL_BoolConstant_HH #endif // OPAL_BoolConstant_HH
\ No newline at end of file
// ------------------------------------------------------------------------
// $RCSfile: RealConstant.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.2 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
// //
// Class: RealConstant // Class RealConstant
// Implements a REAL_CONSTANT definition. // The REAL CONSTANT definition.
// //
// ------------------------------------------------------------------------ // Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
// //
// $Date: 2001/08/13 15:26:42 $ // This file is part of OPAL.
// $Author: jowett $ //
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
// ------------------------------------------------------------------------
#include "ValueDefinitions/RealConstant.h" #include "ValueDefinitions/RealConstant.h"
#include "AbstractObjects/OpalData.h" #include "AbstractObjects/OpalData.h"
#include "Attributes/Attributes.h" #include "Attributes/Attributes.h"
#include "Utilities/Options.h"
#include "Physics/Physics.h"
#include "OPALconfig.h" #include "OPALconfig.h"
#include "Physics/Physics.h"
#include "Utilities/Options.h"
#include "Utility/IpplInfo.h" #include "Utility/IpplInfo.h"
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
// Class RealConstant
// ------------------------------------------------------------------------
RealConstant::RealConstant(): RealConstant::RealConstant():
ValueDefinition(1, "REAL_CONSTANT", ValueDefinition(1, "REAL_CONSTANT",
...@@ -44,20 +41,23 @@ RealConstant::RealConstant(): ...@@ -44,20 +41,23 @@ RealConstant::RealConstant():
OpalData *opal = OpalData::getInstance(); OpalData *opal = OpalData::getInstance();
opal->create(new RealConstant("PI", this, Physics::pi)); opal->create(new RealConstant("PI", this, Physics::pi));
opal->create(new RealConstant("TWOPI", this, Physics::two_pi)); opal->create(new RealConstant("TWOPI", this, Physics::two_pi));
opal->create(new RealConstant("RADDEG", this, 180.0 / Physics::pi)); opal->create(new RealConstant("RADDEG", this, Physics::rad2deg));
opal->create(new RealConstant("DEGRAD", this, Physics::pi / 180.0)); opal->create(new RealConstant("DEGRAD", this, Physics::deg2rad));
opal->create(new RealConstant("E", this, Physics::e)); opal->create(new RealConstant("E", this, Physics::e));
opal->create(new RealConstant("EMASS", this, Physics::m_e)); opal->create(new RealConstant("MUMASS", this, Physics::m_mu));
opal->create(new RealConstant("PMASS", this, Physics::m_p)); opal->create(new RealConstant("EMASS", this, Physics::m_e));
opal->create(new RealConstant("HMMASS", this, Physics::m_hm)); opal->create(new RealConstant("PMASS", this, Physics::m_p));
opal->create(new RealConstant("UMASS", this, Physics::m_u)); opal->create(new RealConstant("HMMASS", this, Physics::m_hm));
opal->create(new RealConstant("CMASS", this, Physics::m_c)); opal->create(new RealConstant("H2PMASS", this, Physics::m_h2p));
opal->create(new RealConstant("MMASS", this, Physics::m_mu)); opal->create(new RealConstant("DMASS", this, Physics::m_d));
opal->create(new RealConstant("DMASS", this, Physics::m_d)); opal->create(new RealConstant("ALPHAMASS", this, Physics::m_alpha));
opal->create(new RealConstant("XEMASS", this, Physics::m_xe)); opal->create(new RealConstant("CMASS", this, Physics::m_c));
opal->create(new RealConstant("XEMASS", this, Physics::m_xe));
opal->create(new RealConstant("UMASS", this, Physics::m_u));
opal->create(new RealConstant("CLIGHT", this, Physics::c)); opal->create(new RealConstant("CLIGHT", this, Physics::c));
opal->create(new RealConstant("AMU", this, Physics::amu));
opal->create(new RealConstant("OPALVERSION", this, OPAL_VERSION_MAJOR * 10000 opal->create(new RealConstant("OPALVERSION", this, OPAL_VERSION_MAJOR * 10000
+ OPAL_VERSION_MINOR * 100 + OPAL_VERSION_MINOR * 100
...@@ -106,4 +106,4 @@ void RealConstant::print(std::ostream &os) const { ...@@ -106,4 +106,4 @@ void RealConstant::print(std::ostream &os) const {
void RealConstant::printValue(std::ostream &os) const { void RealConstant::printValue(std::ostream &os) const {
os << itsAttr[0]; os << itsAttr[0];
} }
\ No newline at end of file
#ifndef OPAL_RealConstant_HH
#define OPAL_RealConstant_HH
// ------------------------------------------------------------------------
// $RCSfile: RealConstant.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
// //
// Class: RealConstant // Class RealConstant
// The REAL CONSTANT definition.
//
// Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// This file is part of OPAL.
// //
// ------------------------------------------------------------------------ // OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// $Date: 2000/03/27 09:33:49 $ // You should have received a copy of the GNU General Public License
// $Author: Andreas Adelmann $ // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
// ------------------------------------------------------------------------ #ifndef OPAL_RealConstant_HH
#define OPAL_RealConstant_HH
#include "AbstractObjects/ValueDefinition.h" #include "AbstractObjects/ValueDefinition.h"
// Class RealConstant
// ------------------------------------------------------------------------
/// The REAL CONSTANT definition.
class RealConstant: public ValueDefinition { class RealConstant: public ValueDefinition {
public: public:
...@@ -62,4 +59,4 @@ private: ...@@ -62,4 +59,4 @@ private:
RealConstant(const std::string &name, RealConstant *parent); RealConstant(const std::string &name, RealConstant *parent);
}; };
#endif // OPAL_RealConstant_HH #endif // OPAL_RealConstant_HH
\ No newline at end of file
// ------------------------------------------------------------------------
// $RCSfile: RealVariable.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.3 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
// //
// Class: RealVariable // Class RealVariable
// Implements a OPAL REAL_VARIABLE definition. // The REAL VARIABLE definition.
// //
// ------------------------------------------------------------------------ // Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
// //
// $Date: 2001/08/13 15:26:42 $ // This file is part of OPAL.
// $Author: jowett $ //
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
// ------------------------------------------------------------------------
#include "ValueDefinitions/RealVariable.h" #include "ValueDefinitions/RealVariable.h"
#include "AbstractObjects/OpalData.h" #include "AbstractObjects/OpalData.h"
#include "Attributes/Attributes.h" #include "Attributes/Attributes.h"
#include <iostream>
#include <iostream>
// Class RealVariable
// ------------------------------------------------------------------------
RealVariable::RealVariable(): RealVariable::RealVariable():
ValueDefinition(1, "REAL_VARIABLE", ValueDefinition(1, "REAL_VARIABLE",
...@@ -82,4 +80,4 @@ void RealVariable::print(std::ostream &os) const { ...@@ -82,4 +80,4 @@ void RealVariable::print(std::ostream &os) const {
void RealVariable::printValue(std::ostream &os) const { void RealVariable::printValue(std::ostream &os) const {
os << itsAttr[0]; os << itsAttr[0];
} }
\ No newline at end of file
#ifndef OPAL_RealVariable_HH
#define OPAL_RealVariable_HH
// ------------------------------------------------------------------------
// $RCSfile: RealVariable.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
// //
// Class: RealVariable // Class RealVariable
// The REAL VARIABLE definition.
//
// Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
// //
// ------------------------------------------------------------------------ // This file is part of OPAL.
// //
// $Date: 2000/03/27 09:33:49 $ // OPAL is free software: you can redistribute it and/or modify
// $Author: Andreas Adelmann $ // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// ------------------------------------------------------------------------ // You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef OPAL_RealVariable_HH
#define OPAL_RealVariable_HH
#include "AbstractObjects/ValueDefinition.h" #include "AbstractObjects/ValueDefinition.h"
// Class RealVariable
// ------------------------------------------------------------------------
/// The REAL VARIABLE definition.
class RealVariable: public ValueDefinition { class RealVariable: public ValueDefinition {
...@@ -61,4 +59,4 @@ private: ...@@ -61,4 +59,4 @@ private:
RealVariable(const std::string &name, RealVariable *parent); RealVariable(const std::string &name, RealVariable *parent);
}; };
#endif // OPAL_RealVariable_HH #endif // OPAL_RealVariable_HH
\ No newline at end of file
// ------------------------------------------------------------------------
// $RCSfile: RealVector.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
// //
// Class: RealVector // Class RealVector
// Implements a OPAL REAL_VECTOR definition. // The REAL VECTOR definition.
// //
// ------------------------------------------------------------------------ // Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
// //
// $Date: 2000/03/27 09:33:49 $ // This file is part of OPAL.
// $Author: Andreas Adelmann $ //
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
// ------------------------------------------------------------------------
#include "ValueDefinitions/RealVector.h" #include "ValueDefinitions/RealVector.h"
#include "Attributes/Attributes.h" #include "Attributes/Attributes.h"
#include "Utilities/Options.h" #include "Utilities/Options.h"
#include <iostream> #include <iostream>
#include <vector> #include <vector>
// Class RealVector
// ------------------------------------------------------------------------
RealVector::RealVector(): RealVector::RealVector():
ValueDefinition(1, "REAL_VECTOR", ValueDefinition(1, "REAL_VECTOR",
"The \"REAL VECTOR\" statement defines a global " "The \"REAL VECTOR\" statement defines a global "
...@@ -70,4 +68,4 @@ void RealVector::printValue(std::ostream &os) const { ...@@ -70,4 +68,4 @@ void RealVector::printValue(std::ostream &os) const {
double RealVector::getRealComponent(int index) const { double RealVector::getRealComponent(int index) const {
std::vector<double> array = Attributes::getRealArray(itsAttr[0]); std::vector<double> array = Attributes::getRealArray(itsAttr[0]);
return array[index-1]; return array[index-1];
} }
\ No newline at end of file
#ifndef OPAL_RealVector_HH
#define OPAL_RealVector_HH
// ------------------------------------------------------------------------
// $RCSfile: RealVector.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
// //
// Class: RealVector // Class RealVector
// The REAL VECTOR definition.
//
// Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// This file is part of OPAL.
// //
// ------------------------------------------------------------------------ // OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// //
// $Date: 2000/03/27 09:33:49 $ // You should have received a copy of the GNU General Public License
// $Author: Andreas Adelmann $ // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
// ------------------------------------------------------------------------ #ifndef OPAL_RealVector_HH
#define OPAL_RealVector_HH
#include "AbstractObjects/ValueDefinition.h" #include "AbstractObjects/ValueDefinition.h"
// Class RealVector
// ------------------------------------------------------------------------
/// The REAL VECTOR definition.
class RealVector: public ValueDefinition { class RealVector: public ValueDefinition {
public: public:
...@@ -59,4 +56,4 @@ private: ...@@ -59,4 +56,4 @@ private:
RealVector(const std::string &name, RealVector *parent); RealVector(const std::string &name, RealVector *parent);
}; };
#endif // OPAL_RealVector_HH #endif // OPAL_RealVector_HH
\ No newline at end of file
// ------------------------------------------------------------------------
// $RCSfile: StringConstant.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.2 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
// //
// Class: StringConstant // Class StringConstant
// Implements a OPAL STRING_CONSTANT definition. // The STRING CONSTANT definition.
// //
// ------------------------------------------------------------------------ // Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
// //
// $Date: 2001/08/13 15:26:42 $ // This file is part of OPAL.
// $Author: jowett $ //
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
// ------------------------------------------------------------------------
#include "ValueDefinitions/StringConstant.h" #include "ValueDefinitions/StringConstant.h"
#include "AbstractObjects/OpalData.h" #include "AbstractObjects/OpalData.h"
#include "Attributes/Attributes.h" #include "Attributes/Attributes.h"
#include "Utilities/Util.h" #include "Utilities/Util.h"
#include <iostream>
#include <iostream>
// Class StringConstant
// ------------------------------------------------------------------------
StringConstant::StringConstant(): StringConstant::StringConstant():
ValueDefinition(1, "STRING_CONSTANT", ValueDefinition(1, "STRING_CONSTANT",
...@@ -68,13 +66,11 @@ StringConstant *StringConstant::clone(const std::string &name) { ...@@ -68,13 +66,11 @@ StringConstant *StringConstant::clone(const std::string &name) {
} }
std::string StringConstant::getString() const { std::string StringConstant::getString() const {
return Attributes::getString(itsAttr[0]); return Attributes::getString(itsAttr[0]);
} }
void StringConstant::print(std::ostream &os) const { void StringConstant::print(std::ostream &os) const {
os << "STRING " << getOpalName() << '=' << itsAttr[0] << ';'; os << "STRING " << getOpalName() << '=' << itsAttr[0] << ';';
os << std::endl; os << std::endl;
...@@ -82,4 +78,4 @@ void StringConstant::print(std::ostream &os) const { ...@@ -82,4 +78,4 @@ void StringConstant::print(std::ostream &os) const {
void StringConstant::printValue(std::ostream &os) const { void StringConstant::printValue(std::ostream &os) const {
os << itsAttr[0]; os << itsAttr[0];
} }
\ No newline at end of file