Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 5673a9d4 authored by ext-calvo_p's avatar ext-calvo_p
Browse files

Resolve "Regression test broken: string constant duplicated"

parent 23558441
No related branches found
No related tags found
1 merge request!651Resolve "Regression test broken: string constant duplicated"
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Class StringConstant // Class StringConstant
// The STRING CONSTANT definition. // The STRING CONSTANT definition.
// //
// Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland // Copyright (c) 2000 - 2023, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved // All rights reserved
// //
// This file is part of OPAL. // This file is part of OPAL.
...@@ -36,7 +36,7 @@ StringConstant::StringConstant(): ...@@ -36,7 +36,7 @@ StringConstant::StringConstant():
registerOwnership(AttributeHandler::STATEMENT); registerOwnership(AttributeHandler::STATEMENT);
OpalData *opal = OpalData::getInstance(); OpalData* opal = OpalData::getInstance();
opal->create(new StringConstant("GITREVISION", this, Util::getGitRevision())); opal->create(new StringConstant("GITREVISION", this, Util::getGitRevision()));
// NOTE: Strings that contain a hyphen can't be written without quotes and // NOTE: Strings that contain a hyphen can't be written without quotes and
...@@ -54,6 +54,7 @@ StringConstant::StringConstant(): ...@@ -54,6 +54,7 @@ StringConstant::StringConstant():
CREATE_STRINGCONSTANT("STANDING"); CREATE_STRINGCONSTANT("STANDING");
CREATE_STRINGCONSTANT("TEMPORAL"); CREATE_STRINGCONSTANT("TEMPORAL");
CREATE_STRINGCONSTANT("SPATIAL"); CREATE_STRINGCONSTANT("SPATIAL");
// Beam / PARTICLE // Beam / PARTICLE
CREATE_STRINGCONSTANT("ELECTRON"); CREATE_STRINGCONSTANT("ELECTRON");
CREATE_STRINGCONSTANT("PROTON"); CREATE_STRINGCONSTANT("PROTON");
...@@ -67,6 +68,7 @@ StringConstant::StringConstant(): ...@@ -67,6 +68,7 @@ StringConstant::StringConstant():
CREATE_STRINGCONSTANT("XENON"); CREATE_STRINGCONSTANT("XENON");
CREATE_STRINGCONSTANT("H2P"); CREATE_STRINGCONSTANT("H2P");
CREATE_STRINGCONSTANT("ALPHA"); CREATE_STRINGCONSTANT("ALPHA");
// Distribution / TYPE // Distribution / TYPE
CREATE_STRINGCONSTANT("FROMFILE"); CREATE_STRINGCONSTANT("FROMFILE");
CREATE_STRINGCONSTANT("GAUSS"); CREATE_STRINGCONSTANT("GAUSS");
...@@ -127,11 +129,11 @@ StringConstant::StringConstant(): ...@@ -127,11 +129,11 @@ StringConstant::StringConstant():
// OutputPlane / PLACEMENT_STYLE // OutputPlane / PLACEMENT_STYLE
CREATE_STRINGCONSTANT("CENTRE_NORMAL"); CREATE_STRINGCONSTANT("CENTRE_NORMAL");
CREATE_STRINGCONSTANT("PROBE"); // additionally: PROBE;
// OutputPlane / ALGORITHM // OutputPlane / ALGORITHM
CREATE_STRINGCONSTANT("INTERPOLATION"); CREATE_STRINGCONSTANT("INTERPOLATION");
// CREATE_STRINGCONSTANT("RK4"); // additionally: RK4;
// ParticleMatterInteraction / TYPE // ParticleMatterInteraction / TYPE
CREATE_STRINGCONSTANT("SCATTERING"); CREATE_STRINGCONSTANT("SCATTERING");
...@@ -274,44 +276,41 @@ StringConstant::StringConstant(): ...@@ -274,44 +276,41 @@ StringConstant::StringConstant():
CREATE_STRINGCONSTANT("CYLINDRICAL"); CREATE_STRINGCONSTANT("CYLINDRICAL");
} }
StringConstant::StringConstant(const std::string &name, StringConstant *parent): StringConstant::StringConstant(const std::string& name,
ValueDefinition(name, parent) StringConstant* parent)
{} : ValueDefinition(name, parent) {
}
StringConstant::StringConstant(const std::string& name,
StringConstant* parent,
const std::string& value)
: ValueDefinition(name, parent) {
StringConstant::StringConstant(const std::string &name, StringConstant *parent, const std::string &value):
ValueDefinition(name, parent)
{
Attributes::setString(itsAttr[0], value); Attributes::setString(itsAttr[0], value);
itsAttr[0].setReadOnly(true); itsAttr[0].setReadOnly(true);
builtin = true; builtin = true;
} }
StringConstant::~StringConstant() StringConstant::~StringConstant()
{} {}
bool StringConstant::canReplaceBy(Object*) {
bool StringConstant::canReplaceBy(Object *) {
return false; return false;
} }
StringConstant *StringConstant::clone(const std::string& name) {
StringConstant *StringConstant::clone(const std::string &name) {
return new StringConstant(name, this); return new StringConstant(name, this);
} }
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;
} }
void StringConstant::printValue(std::ostream &os) const { void StringConstant::printValue(std::ostream& os) const {
os << itsAttr[0]; os << itsAttr[0];
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Class StringConstant // Class StringConstant
// The STRING CONSTANT definition. // The STRING CONSTANT definition.
// //
// Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland // Copyright (c) 2000 - 2023, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved // All rights reserved
// //
// This file is part of OPAL. // This file is part of OPAL.
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
class StringConstant: public ValueDefinition { class StringConstant: public ValueDefinition {
public: public:
/// Exemplar constructor. /// Exemplar constructor.
StringConstant(); StringConstant();
...@@ -32,29 +31,28 @@ public: ...@@ -32,29 +31,28 @@ public:
/// Test if object can be replaced. /// Test if object can be replaced.
// True, if [b]rhs[/b] is a string constant. // True, if [b]rhs[/b] is a string constant.
virtual bool canReplaceBy(Object *object); virtual bool canReplaceBy(Object* object);
/// Make clone. /// Make clone.
virtual StringConstant *clone(const std::string &name); virtual StringConstant* clone(const std::string& name);
/// Print the constant. /// Print the constant.
virtual void print(std::ostream &) const; virtual void print(std::ostream&) const;
/// Print its value /// Print its value
virtual void printValue(std::ostream &os) const; virtual void printValue(std::ostream& os) const;
/// Return value. /// Return value.
virtual std::string getString() const; virtual std::string getString() const;
private: private:
// Not implemented. // Not implemented.
StringConstant(const StringConstant &); StringConstant(const StringConstant&);
void operator=(const StringConstant &); void operator=(const StringConstant&);
// Clone constructor. // Clone constructor.
StringConstant(const std::string &name, StringConstant *parent); StringConstant(const std::string& name, StringConstant* parent);
StringConstant(const std::string &name, StringConstant *parent, const std::string &value); StringConstant(const std::string& name, StringConstant* parent, const std::string& value);
}; };
#endif // OPAL_StringConstant_HH #endif // OPAL_StringConstant_HH
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment