Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
OPAL
src
Commits
482dc861
Commit
482dc861
authored
Feb 16, 2017
by
Christof Metzger-Kraus
Browse files
Second proposition for better error messages
parent
06e74873
Changes
132
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
101 additions
and
13 deletions
+101
-13
src/AbstractObjects/AttributeHandler.cpp
src/AbstractObjects/AttributeHandler.cpp
+30
-0
src/AbstractObjects/AttributeHandler.h
src/AbstractObjects/AttributeHandler.h
+13
-1
src/AbstractObjects/Object.cpp
src/AbstractObjects/Object.cpp
+10
-1
src/AbstractObjects/Object.h
src/AbstractObjects/Object.h
+2
-0
src/Aperture/Aperture.cpp
src/Aperture/Aperture.cpp
+2
-0
src/Aperture/Split.cpp
src/Aperture/Split.cpp
+3
-1
src/BasicActions/Call.cpp
src/BasicActions/Call.cpp
+2
-0
src/BasicActions/DumpFields.cpp
src/BasicActions/DumpFields.cpp
+3
-2
src/BasicActions/Echo.cpp
src/BasicActions/Echo.cpp
+2
-0
src/BasicActions/Help.cpp
src/BasicActions/Help.cpp
+3
-1
src/BasicActions/Option.cpp
src/BasicActions/Option.cpp
+2
-0
src/BasicActions/PSystem.cpp
src/BasicActions/PSystem.cpp
+2
-0
src/BasicActions/Save.cpp
src/BasicActions/Save.cpp
+2
-0
src/BasicActions/Select.cpp
src/BasicActions/Select.cpp
+2
-0
src/BasicActions/Show.cpp
src/BasicActions/Show.cpp
+3
-1
src/BasicActions/System.cpp
src/BasicActions/System.cpp
+2
-0
src/BasicActions/Title.cpp
src/BasicActions/Title.cpp
+3
-1
src/BasicActions/Value.cpp
src/BasicActions/Value.cpp
+3
-1
src/BasicActions/What.cpp
src/BasicActions/What.cpp
+3
-1
src/Classic/AbsBeamline/ElementBase.cpp
src/Classic/AbsBeamline/ElementBase.cpp
+9
-3
No files found.
src/AbstractObjects/AttributeHandler.cpp
View file @
482dc861
...
...
@@ -24,6 +24,11 @@
// Class AttributeHandler
// ------------------------------------------------------------------------
std
::
multimap
<
std
::
string
,
std
::
pair
<
AttributeHandler
::
OwnerType
,
std
::
string
>
>
AttributeHandler
::
attributeOwnerDictionary_s
;
AttributeHandler
::
AttributeHandler
(
const
std
::
string
&
name
,
const
std
::
string
&
help
,
AttributeBase
*
def
)
:
RCObject
(),
itsName
(
name
),
itsHelp
(
help
),
itsDefault
(
def
),
...
...
@@ -89,3 +94,28 @@ void AttributeHandler::setReadOnly(bool flag) {
is_readonly
=
flag
;
}
std
::
multimap
<
AttributeHandler
::
OwnerType
,
std
::
string
>
AttributeHandler
::
getOwner
(
const
std
::
string
&
att
)
{
std
::
multimap
<
OwnerType
,
std
::
string
>
possibleOwners
;
if
(
attributeOwnerDictionary_s
.
find
(
att
)
!=
attributeOwnerDictionary_s
.
end
())
{
auto
its
=
attributeOwnerDictionary_s
.
equal_range
(
att
);
for
(
auto
it
=
its
.
first
;
it
!=
its
.
second
;
++
it
)
{
auto
owner
=
it
->
second
;
possibleOwners
.
insert
(
std
::
make_pair
(
owner
.
first
,
owner
.
second
));
}
}
return
possibleOwners
;
}
void
AttributeHandler
::
addAttributeOwner
(
const
std
::
string
&
owner
,
const
AttributeHandler
::
OwnerType
&
type
,
const
std
::
string
&
name
)
{
attributeOwnerDictionary_s
.
insert
(
std
::
make_pair
(
name
,
std
::
make_pair
(
type
,
owner
)
)
);
}
\ No newline at end of file
src/AbstractObjects/AttributeHandler.h
View file @
482dc861
...
...
@@ -22,6 +22,7 @@
#include "AbstractObjects/AttributeBase.h"
#include "MemoryManagement/Pointer.h"
#include <string>
#include <map>
class
Attribute
;
class
AttributeBase
;
...
...
@@ -111,6 +112,15 @@ public:
// then [b]OpalException[/b] is thrown.
void
setReadOnly
(
bool
);
enum
OwnerType
{
ELEMENT
,
COMMAND
,
SUB_COMMAND
,
STATEMENT
,
NONE
};
static
std
::
multimap
<
OwnerType
,
std
::
string
>
getOwner
(
const
std
::
string
&
att
);
static
void
addAttributeOwner
(
const
std
::
string
&
owner
,
const
OwnerType
&
type
,
const
std
::
string
&
name
);
protected:
/// Attribute name.
...
...
@@ -134,6 +144,8 @@ private:
AttributeHandler
();
AttributeHandler
(
const
AttributeHandler
&
);
void
operator
=
(
const
AttributeHandler
&
);
static
std
::
multimap
<
std
::
string
,
std
::
pair
<
OwnerType
,
std
::
string
>
>
attributeOwnerDictionary_s
;
};
#endif // OPAL_AttributeHandler_HH
#endif // OPAL_AttributeHandler_HH
\ No newline at end of file
src/AbstractObjects/Object.cpp
View file @
482dc861
...
...
@@ -191,6 +191,15 @@ void Object::unregisterReference(Invalidator *ref) {
references
.
erase
(
ref
);
}
void
Object
::
registerOwnership
(
const
AttributeHandler
::
OwnerType
&
itsClass
)
const
{
if
(
getParent
()
!=
0
)
return
;
const
unsigned
int
end
=
itsAttr
.
size
();
const
std
::
string
name
=
getOpalName
();
for
(
unsigned
int
i
=
0
;
i
<
end
;
++
i
)
{
AttributeHandler
::
addAttributeOwner
(
name
,
itsClass
,
itsAttr
[
i
].
getName
());
}
}
void
Object
::
printHelp
(
std
::
ostream
&
os
)
const
{
*
gmsg
<<
endl
<<
itsHelp
<<
endl
;
...
...
@@ -335,4 +344,4 @@ Object::Object(const string &name, Object *parent):
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Object
&
object
)
{
object
.
print
(
os
);
return
os
;
}
}
\ No newline at end of file
src/AbstractObjects/Object.h
View file @
482dc861
...
...
@@ -208,6 +208,8 @@ public:
// will no longer be notified of any change to [b]this[/b].
void
unregisterReference
(
Invalidator
*
a
);
void
registerOwnership
(
const
AttributeHandler
::
OwnerType
&
itsClass
)
const
;
/// The object attributes (see Attribute.hh).
std
::
vector
<
Attribute
>
itsAttr
;
...
...
src/Aperture/Aperture.cpp
View file @
482dc861
...
...
@@ -178,6 +178,8 @@ Aperture::Aperture():
(
"DEFAULTAPERTURE"
,
"The default beam screen for markers and drift generated in sequences"
);
itsAttr
[
FILE
]
=
Attributes
::
makeString
(
"FILE"
,
"Name of file to receive APERTURE output"
,
"APERTURE.dat"
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
}
Aperture
::
Aperture
(
const
std
::
string
&
name
,
Aperture
*
parent
)
:
DefaultVisitor
(
itsTable
,
false
,
false
),
...
...
src/Aperture/Split.cpp
View file @
482dc861
...
...
@@ -167,6 +167,8 @@ MSplit::MSplit():
(
"STATIC"
,
"recalculation if static equal false"
,
true
);
itsAttr
[
FILE
]
=
Attributes
::
makeString
(
"FILE"
,
"Name of file to receive SPLIT output"
,
"SPLIT.dat"
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
}
MSplit
::
MSplit
(
const
std
::
string
&
name
,
MSplit
*
parent
)
:
DefaultVisitor
(
itsTable
,
false
,
false
),
...
...
@@ -787,4 +789,4 @@ MSplit::A_row &MSplit::findRow(const PlaceRep &place) {
throw
OpalException
(
"MSplit::findRow()"
,
"A_row
\"
"
+
os
.
str
()
+
"
\"
not found in twiss table
\"
"
+
getOpalName
()
+
"
\"
."
);
#endif
}
}
\ No newline at end of file
src/BasicActions/Call.cpp
View file @
482dc861
...
...
@@ -39,6 +39,8 @@ Call::Call():
"named file."
)
{
itsAttr
[
0
]
=
Attributes
::
makeString
(
"FILE"
,
"Name of file to be read"
,
"CALL"
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
}
...
...
src/BasicActions/DumpFields.cpp
View file @
482dc861
...
...
@@ -67,6 +67,8 @@ DumpFields::DumpFields() :
(
"Z_STEPS"
,
"Number of steps in z"
);
itsAttr
[
9
]
=
Attributes
::
makeString
(
"FILE_NAME"
,
"Name of the file to which field data is dumped"
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
}
DumpFields
::~
DumpFields
()
{
...
...
@@ -186,5 +188,4 @@ void DumpFields::writeFieldThis(Component* field) {
"Something went wrong during writing "
+
filename_m
);
}
fout
.
close
();
}
}
\ No newline at end of file
src/BasicActions/Echo.cpp
View file @
482dc861
...
...
@@ -29,6 +29,8 @@ Echo::Echo():
Action
(
1
,
"ECHO"
,
"The
\"
ECHO
\"
statement sends a message to the ECHO file."
)
{
itsAttr
[
0
]
=
Attributes
::
makeString
(
"MESSAGE"
,
"The message to be sent."
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
}
...
...
src/BasicActions/Help.cpp
View file @
482dc861
...
...
@@ -33,6 +33,8 @@ Help::Help():
"types of an object."
)
{
itsAttr
[
0
]
=
Attributes
::
makeString
(
"NAME"
,
"Name of object for which help is wanted"
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
}
...
...
@@ -68,4 +70,4 @@ void Help::execute() {
void
Help
::
parse
(
Statement
&
statement
)
{
parseShortcut
(
statement
);
}
}
\ No newline at end of file
src/BasicActions/Option.cpp
View file @
482dc861
...
...
@@ -193,6 +193,8 @@ Option::Option():
itsAttr
[
VERSION
]
=
Attributes
::
makeReal
(
"VERSION"
,
"Version of OPAL for which input file was written"
,
10000
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
FileStream
::
setEcho
(
echo
);
rangen
.
init55
(
seed
);
}
...
...
src/BasicActions/PSystem.cpp
View file @
482dc861
...
...
@@ -35,6 +35,8 @@ PSystem::PSystem():
"operating system from all nodes."
)
{
itsAttr
[
0
]
=
Attributes
::
makeString
(
"CMD"
,
"A system command to be executed"
);
registerOwnership
(
AttributeHandler
::
COMMAND
);
}
...
...
src/BasicActions/Save.cpp
View file @
482dc861
...
...
@@ -126,6 +126,8 @@ Save::Save():
"followed by elements, and finally all sequences."
)
{
itsAttr
[
0
]
=
Attributes
::
makeString
(
"FILE"
,
"Name of file to be written"
,
"SAVE"
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
}
...
...
src/BasicActions/Select.cpp
View file @
482dc861
...
...
@@ -74,6 +74,8 @@ Select::Select():
itsAttr
[
PATTERN
]
=
Attributes
::
makeString
(
"PATTERN"
,
"Regular expression for matching names (default: all names)"
);
registerOwnership
(
AttributeHandler
::
SUB_COMMAND
);
}
...
...
src/BasicActions/Show.cpp
View file @
482dc861
...
...
@@ -32,6 +32,8 @@ Show::Show():
" regular expression."
)
{
itsAttr
[
0
]
=
Attributes
::
makeString
(
"PATTERN"
,
"Regular expression for pattern match"
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
}
...
...
@@ -61,4 +63,4 @@ void Show::execute() {
void
Show
::
parse
(
Statement
&
statement
)
{
parseShortcut
(
statement
);
}
}
\ No newline at end of file
src/BasicActions/System.cpp
View file @
482dc861
...
...
@@ -35,6 +35,8 @@ System::System():
"operating system."
)
{
itsAttr
[
0
]
=
Attributes
::
makeString
(
"CMD"
,
"A system command to be executed"
);
registerOwnership
(
AttributeHandler
::
COMMAND
);
}
...
...
src/BasicActions/Title.cpp
View file @
482dc861
...
...
@@ -30,6 +30,8 @@ Title::Title():
"output."
)
{
itsAttr
[
0
]
=
Attributes
::
makeString
(
"STRING"
,
"The title string"
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
}
...
...
@@ -55,4 +57,4 @@ void Title::execute() {
void
Title
::
parse
(
Statement
&
statement
)
{
parseShortcut
(
statement
);
}
}
\ No newline at end of file
src/BasicActions/Value.cpp
View file @
482dc861
...
...
@@ -34,6 +34,8 @@ Value::Value():
"their values."
)
{
itsAttr
[
0
]
=
Attributes
::
makeRealArray
(
"VALUE"
,
"The values to be evaluated"
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
}
...
...
@@ -70,4 +72,4 @@ void Value::execute() {
void
Value
::
parse
(
Statement
&
statement
)
{
parseShortcut
(
statement
);
}
}
\ No newline at end of file
src/BasicActions/What.cpp
View file @
482dc861
...
...
@@ -31,6 +31,8 @@ What::What():
" values of an object."
)
{
itsAttr
[
0
]
=
Attributes
::
makeString
(
"NAME"
,
"Name of object to be displayed"
);
registerOwnership
(
AttributeHandler
::
STATEMENT
);
}
...
...
@@ -66,4 +68,4 @@ void What::execute() {
void
What
::
parse
(
Statement
&
statement
)
{
parseShortcut
(
statement
);
}
}
\ No newline at end of file
src/Classic/AbsBeamline/ElementBase.cpp
View file @
482dc861
...
...
@@ -49,7 +49,9 @@ ElementBase::ElementBase():
bgeometry_m
(
NULL
),
sphys_m
(
NULL
),
elType_m
(
isOther
),
positionIsFixed
(
false
)
positionIsFixed
(
false
),
elementPosition_m
(
0.0
),
elemedgeSet_m
(
false
)
{}
...
...
@@ -67,7 +69,9 @@ ElementBase::ElementBase(const ElementBase &right):
bgeometry_m
(
right
.
bgeometry_m
),
sphys_m
(
right
.
sphys_m
),
elType_m
(
right
.
elType_m
),
positionIsFixed
(
right
.
positionIsFixed
)
positionIsFixed
(
right
.
positionIsFixed
),
elementPosition_m
(
right
.
elementPosition_m
),
elemedgeSet_m
(
right
.
elemedgeSet_m
)
{
if
(
sphys_m
)
{
...
...
@@ -91,7 +95,9 @@ ElementBase::ElementBase(const std::string &name):
bgeometry_m
(
NULL
),
sphys_m
(
NULL
),
elType_m
(
isOther
),
positionIsFixed
(
false
)
positionIsFixed
(
false
),
elementPosition_m
(
0.0
),
elemedgeSet_m
(
false
)
{}
...
...
Prev
1
2
3
4
5
…
7
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment