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
9f0f37b4
Commit
9f0f37b4
authored
9 years ago
by
Michael Hart
Browse files
Options
Downloads
Patches
Plain Diff
Re #13632 Added local cache of bank shared_pointers
parent
5ae90610
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/Crystal/inc/MantidCrystal/LoadIsawPeaks.h
+7
-0
7 additions, 0 deletions
Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h
Framework/Crystal/src/LoadIsawPeaks.cpp
+26
-2
26 additions, 2 deletions
Framework/Crystal/src/LoadIsawPeaks.cpp
with
33 additions
and
2 deletions
Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h
+
7
−
0
View file @
9f0f37b4
...
...
@@ -65,6 +65,13 @@ private:
std
::
string
filename
);
void
checkNumberPeaks
(
Mantid
::
DataObjects
::
PeaksWorkspace_sptr
outWS
,
std
::
string
filename
);
/// Local cache of bank IComponents used in file
std
::
map
<
std
::
string
,
boost
::
shared_ptr
<
const
Geometry
::
IComponent
>>
m_banks
;
/// Retrieve cached bank (or load and cache for next time)
boost
::
shared_ptr
<
const
Geometry
::
IComponent
>
getCachedBankByName
(
std
::
string
bankname
,
const
boost
::
shared_ptr
<
const
Geometry
::
Instrument
>&
inst
);
};
}
// namespace Mantid
...
...
This diff is collapsed.
Click to expand it.
Framework/Crystal/src/LoadIsawPeaks.cpp
+
26
−
2
View file @
9f0f37b4
...
...
@@ -190,7 +190,7 @@ LoadIsawPeaks::ApplyCalibInfo(std::ifstream &in, std::string startChar,
}
bankName
+=
SbankNum
;
boost
::
shared_ptr
<
const
Geometry
::
IComponent
>
bank
=
instr_old
->
getComponent
ByName
(
bankName
);
getCachedBank
ByName
(
bankName
,
instr_old
);
if
(
!
bank
)
{
g_log
.
error
()
<<
"There is no bank "
<<
bankName
<<
" in the instrument"
...
...
@@ -405,7 +405,8 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS,
int
LoadIsawPeaks
::
findPixelID
(
Instrument_const_sptr
inst
,
std
::
string
bankName
,
int
col
,
int
row
)
{
boost
::
shared_ptr
<
const
IComponent
>
parent
=
inst
->
getComponentByName
(
bankName
);
getCachedBankByName
(
bankName
,
inst
);
if
(
parent
->
type
().
compare
(
"RectangularDetector"
)
==
0
)
{
boost
::
shared_ptr
<
const
RectangularDetector
>
RDet
=
boost
::
dynamic_pointer_cast
<
const
RectangularDetector
>
(
parent
);
...
...
@@ -607,5 +608,28 @@ void LoadIsawPeaks::exec() {
this
->
checkNumberPeaks
(
ws
,
getPropertyValue
(
"Filename"
));
}
//----------------------------------------------------------------------------------------------
/** Retrieves pointer to given bank from local cache.
*
* When the bank isn't in the local cache, it is loaded and
* added to the cache for later use. Lifetime of the cache
* is bound to the lifetime of this instance of the algorithm
* (typically, the instance should be destroyed once exec()
* finishes).
*
* Note that while this is used only for banks here, it would
* work for caching any component without modification.
*
* @param bankname :: the name of the requested bank
* @param inst :: the instrument from which to load the bank if it is not yet cached
* @return A shared pointer to the request bank (empty shared pointer if not found)
*/
boost
::
shared_ptr
<
const
IComponent
>
LoadIsawPeaks
::
getCachedBankByName
(
std
::
string
bankname
,
const
boost
::
shared_ptr
<
const
Geometry
::
Instrument
>&
inst
)
{
if
(
m_banks
.
count
(
bankname
)
==
0
)
m_banks
[
bankname
]
=
inst
->
getComponentByName
(
bankname
);
return
m_banks
[
bankname
];
}
}
// namespace Mantid
}
// namespace Crystal
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