Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
52b99020
Commit
52b99020
authored
4 years ago
by
Peterson, Peter
Browse files
Options
Downloads
Patches
Plain Diff
Take advantage of new method in NexusFileLoader
parent
ab22cd70
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/DataHandling/inc/MantidDataHandling/Load.h
+0
-3
0 additions, 3 deletions
Framework/DataHandling/inc/MantidDataHandling/Load.h
Framework/DataHandling/src/Load.cpp
+25
-29
25 additions, 29 deletions
Framework/DataHandling/src/Load.cpp
with
25 additions
and
32 deletions
Framework/DataHandling/inc/MantidDataHandling/Load.h
+
0
−
3
View file @
52b99020
...
...
@@ -43,9 +43,6 @@ public:
void
setPropertyValue
(
const
std
::
string
&
name
,
const
std
::
string
&
value
)
override
;
/// Free function to find first file property
static
std
::
string
findFilenamePropertyName
(
const
IAlgorithm
*
loader
);
protected
:
Parallel
::
ExecutionMode
getParallelExecutionMode
(
const
std
::
map
<
std
::
string
,
Parallel
::
StorageMode
>
&
storageModes
)
...
...
This diff is collapsed.
Click to expand it.
Framework/DataHandling/src/Load.cpp
+
25
−
29
View file @
52b99020
...
...
@@ -13,6 +13,7 @@
#include
"MantidAPI/ITableWorkspace.h"
#include
"MantidAPI/IWorkspaceProperty.h"
#include
"MantidAPI/MultipleFileProperty.h"
#include
"MantidAPI/NexusFileLoader.h"
#include
"MantidAPI/WorkspaceGroup.h"
#include
"MantidKernel/ArrayProperty.h"
#include
"MantidKernel/FacilityInfo.h"
...
...
@@ -214,44 +215,39 @@ API::IAlgorithm_sptr Load::getFileLoader(const std::string &filePath) {
return
winningLoader
;
}
std
::
string
Load
::
findFilenamePropertyName
(
const
IAlgorithm
*
loader
)
{
std
::
string
propertyName
;
// default is empty string
// Use the first file property as the main Filename
const
auto
&
props
=
loader
->
getProperties
();
for
(
auto
prop
:
props
)
{
auto
*
multiprop
=
dynamic_cast
<
API
::
MultipleFileProperty
*>
(
prop
);
auto
*
singleprop
=
dynamic_cast
<
API
::
FileProperty
*>
(
prop
);
if
(
multiprop
)
{
propertyName
=
multiprop
->
name
();
break
;
}
if
(
singleprop
)
{
propertyName
=
singleprop
->
name
();
break
;
void
Load
::
findFilenameProperty
(
const
API
::
IAlgorithm_sptr
&
loader
)
{
const
auto
nxsLoader
=
boost
::
dynamic_pointer_cast
<
NexusFileLoader
>
(
loader
);
if
(
nxsLoader
)
{
// NexusFileLoader has a method for giving back the name directly
m_filenamePropName
=
nxsLoader
->
getFilenamePropertyName
();
}
else
{
// Use the first file property as the main Filename
const
auto
&
props
=
loader
->
getProperties
();
for
(
auto
prop
:
props
)
{
auto
*
multiprop
=
dynamic_cast
<
API
::
MultipleFileProperty
*>
(
prop
);
auto
*
singleprop
=
dynamic_cast
<
API
::
FileProperty
*>
(
prop
);
if
(
multiprop
)
{
m_filenamePropName
=
multiprop
->
name
();
break
;
}
if
(
singleprop
)
{
m_filenamePropName
=
singleprop
->
name
();
break
;
}
}
}
// throw an exception if somehting nothing was found
if
(
propertyName
.
empty
())
{
if
(
m_filenamePropName
.
empty
())
{
// unset member variables
setPropertyValue
(
"LoaderName"
,
""
);
setProperty
(
"LoaderVersion"
,
-
1
);
std
::
stringstream
msg
;
msg
<<
"Cannot find FileProperty on
\"
"
<<
loader
->
name
()
<<
"
\"
v"
<<
loader
->
version
()
<<
" algorithm."
;
throw
std
::
runtime_error
(
msg
.
str
());
}
return
propertyName
;
}
void
Load
::
findFilenameProperty
(
const
API
::
IAlgorithm_sptr
&
loader
)
{
try
{
m_filenamePropName
=
findFilenamePropertyName
(
loader
.
get
());
}
catch
(
std
::
runtime_error
&
)
{
// unset member variables
setPropertyValue
(
"LoaderName"
,
""
);
setProperty
(
"LoaderVersion"
,
-
1
);
throw
;
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment