Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
874f65c8
Commit
874f65c8
authored
Sep 04, 2017
by
Karl Palmen
Browse files
Mergin in master to remove need for cast re #19010
parent
5d4e6081
Changes
1000
Expand all
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 1000+
files are displayed.
Plain diff
Email patch
.flake8
View file @
874f65c8
...
...
@@ -14,15 +14,12 @@ exclude =
installers,
instrument,
MantidPlot,
MantidQt,
QtPropertyBrowser,
qt,
scripts/test,
Testing/PerformanceTests,
Testing/SystemTests/lib,
Testing/SystemTests/scripts,
Testing/SystemTests/tests/analysis/reference,
Testing/Tools,
Vates/ParaviewPlugins,
Vates/VatesSimpleGui
max-complexity = 20
max-line-length = 140
CMakeLists.txt
View file @
874f65c8
...
...
@@ -124,13 +124,6 @@ endif()
###########################################################################
find_package
(
GSL REQUIRED
)
###########################################################################
# Add QtPropertyBrowser to build
###########################################################################
if
(
ENABLE_MANTIDPLOT
)
add_subdirectory
(
QtPropertyBrowser
)
endif
(
ENABLE_MANTIDPLOT
)
###########################################################################
# Now add in all the components
###########################################################################
...
...
@@ -159,20 +152,15 @@ set ( CORE_MANTIDLIBS Kernel HistogramData Indexing Geometry API Types )
if
(
ENABLE_MANTIDPLOT
)
# Add a target for all GUI tests
add_custom_target
(
GUITests
)
add_dependencies
(
GUITests Mantid
Widgets
Test
)
add_dependencies
(
GUITests Mantid
QtCommon
Test
)
add_dependencies
(
check GUITests
)
# Collect all tests together
add_custom_target
(
AllTests
)
add_dependencies
(
AllTests FrameworkTests GUITests
)
endif
()
if
(
UNIX
)
#Experimental feature. Unix only at this point.
set
(
UNITY_BUILD OFF CACHE BOOL
"Switch for utilising unity builds. Faster builds for selected components."
)
endif
(
UNIX
)
if
(
ENABLE_MANTIDPLOT AND MAKE_VATES
)
if
(
ENABLE_MANTIDPLOT AND MAKE_VATES
)
add_subdirectory
(
Vates
)
if
(
NOT APPLE
)
LIST
(
APPEND CPACK_INSTALL_CMAKE_PROJECTS
"
${
ParaView_DIR
}
"
"ParaView Runtime Libs"
"Runtime"
"
${
INBUNDLE
}
/"
...
...
@@ -190,12 +178,17 @@ if (ENABLE_MANTIDPLOT AND MAKE_VATES )
endif
(
ENABLE_MANTIDPLOT AND MAKE_VATES
)
if
(
UNIX
)
#Experimental feature. Unix only at this point.
set
(
UNITY_BUILD OFF CACHE BOOL
"Switch for utilising unity builds. Faster builds for selected components."
)
endif
(
UNIX
)
if
(
MSVC
)
add_definitions
(
-DQWT_DLL
)
endif
()
if
(
ENABLE_MANTIDPLOT
)
add_subdirectory
(
MantidQ
t
)
add_subdirectory
(
q
t
)
add_subdirectory
(
MantidPlot
)
endif
()
...
...
@@ -303,6 +296,7 @@ if ( ENABLE_CPACK )
"libboost-regex
${
Boost_MAJOR_VERSION
}
.
${
Boost_MINOR_VERSION
}
.
${
Boost_SUBMINOR_VERSION
}
,"
"libboost-python
${
Boost_MAJOR_VERSION
}
.
${
Boost_MINOR_VERSION
}
.
${
Boost_SUBMINOR_VERSION
}
,"
"libboost-serialization
${
Boost_MAJOR_VERSION
}
.
${
Boost_MINOR_VERSION
}
.
${
Boost_SUBMINOR_VERSION
}
,"
"libboost-filesystem
${
Boost_MAJOR_VERSION
}
.
${
Boost_MINOR_VERSION
}
.
${
Boost_SUBMINOR_VERSION
}
,"
"libnexus0 (>= 4.3),"
"libgsl0ldbl,"
"libqtcore4 (>= 4.2),"
...
...
Framework/API/CMakeLists.txt
View file @
874f65c8
...
...
@@ -19,7 +19,6 @@ set ( SRC_FILES
src/Column.cpp
src/ColumnFactory.cpp
src/CommonBinsValidator.cpp
src/ComponentInfo.cpp
src/CompositeCatalog.cpp
src/CompositeDomainMD.cpp
src/CompositeFunction.cpp
...
...
@@ -28,8 +27,7 @@ set ( SRC_FILES
src/CostFunctionFactory.cpp
src/DataProcessorAlgorithm.cpp
src/DeprecatedAlgorithm.cpp
src/DetectorInfo.cpp
src/DetectorSearcher.cpp
src/DetectorSearcher.cpp
src/DomainCreatorFactory.cpp
src/EnabledWhenWorkspaceIsType.cpp
src/EqualBinSizesValidator.cpp
...
...
@@ -84,6 +82,8 @@ set ( SRC_FILES
src/ImplicitFunctionParameterParserFactory.cpp
src/ImplicitFunctionParserFactory.cpp
src/IncreasingAxisValidator.cpp
src/IndexProperty.cpp
src/IndexTypeProperty.cpp
src/InstrumentDataService.cpp
src/InstrumentValidator.cpp
src/JointDomain.cpp
...
...
@@ -104,8 +104,6 @@ set ( SRC_FILES
src/MultiPeriodGroupWorker.cpp
src/MultipleExperimentInfos.cpp
src/MultipleFileProperty.cpp
src/WorkspaceNearestNeighbourInfo.cpp
src/WorkspaceNearestNeighbours.cpp
src/NotebookBuilder.cpp
src/NotebookWriter.cpp
src/NullCoordTransform.cpp
...
...
@@ -141,6 +139,8 @@ set ( SRC_FILES
src/WorkspaceFactory.cpp
src/WorkspaceGroup.cpp
src/WorkspaceHistory.cpp
src/WorkspaceNearestNeighbourInfo.cpp
src/WorkspaceNearestNeighbours.cpp
src/WorkspaceOpOverloads.cpp
src/WorkspaceProperty.cpp
src/WorkspaceUnitValidator.cpp
...
...
@@ -159,6 +159,7 @@ set ( INC_FILES
# inc/MantidAPI/BoxCtrlChangesInterface.h
inc/MantidAPI/ADSValidator.h
inc/MantidAPI/Algorithm.h
inc/MantidAPI/Algorithm.tcc
inc/MantidAPI/AlgorithmFactory.h
inc/MantidAPI/AlgorithmHasProperty.h
inc/MantidAPI/AlgorithmHistory.h
...
...
@@ -178,7 +179,6 @@ set ( INC_FILES
inc/MantidAPI/Column.h
inc/MantidAPI/ColumnFactory.h
inc/MantidAPI/CommonBinsValidator.h
inc/MantidAPI/ComponentInfo.h
inc/MantidAPI/CompositeCatalog.h
inc/MantidAPI/CompositeDomain.h
inc/MantidAPI/CompositeDomainMD.h
...
...
@@ -189,8 +189,7 @@ set ( INC_FILES
inc/MantidAPI/DataProcessorAlgorithm.h
inc/MantidAPI/DeclareUserAlg.h
inc/MantidAPI/DeprecatedAlgorithm.h
inc/MantidAPI/DetectorInfo.h
inc/MantidAPI/DetectorSearcher.h
inc/MantidAPI/DetectorSearcher.h
inc/MantidAPI/DllConfig.h
inc/MantidAPI/DomainCreatorFactory.h
inc/MantidAPI/EnabledWhenWorkspaceIsType.h
...
...
@@ -274,6 +273,8 @@ set ( INC_FILES
inc/MantidAPI/ImplicitFunctionParser.h
inc/MantidAPI/ImplicitFunctionParserFactory.h
inc/MantidAPI/IncreasingAxisValidator.h
inc/MantidAPI/IndexProperty.h
inc/MantidAPI/IndexTypeProperty.h
inc/MantidAPI/InstrumentDataService.h
inc/MantidAPI/InstrumentValidator.h
inc/MantidAPI/Jacobian.h
...
...
@@ -297,8 +298,6 @@ set ( INC_FILES
inc/MantidAPI/MultiPeriodGroupWorker.h
inc/MantidAPI/MultipleExperimentInfos.h
inc/MantidAPI/MultipleFileProperty.h
inc/MantidAPI/WorkspaceNearestNeighbourInfo.h
inc/MantidAPI/WorkspaceNearestNeighbours.h
inc/MantidAPI/NotebookBuilder.h
inc/MantidAPI/NotebookWriter.h
inc/MantidAPI/NullCoordTransform.h
...
...
@@ -338,6 +337,8 @@ set ( INC_FILES
inc/MantidAPI/WorkspaceGroup.h
inc/MantidAPI/WorkspaceGroup_fwd.h
inc/MantidAPI/WorkspaceHistory.h
inc/MantidAPI/WorkspaceNearestNeighbourInfo.h
inc/MantidAPI/WorkspaceNearestNeighbours.h
inc/MantidAPI/WorkspaceOpOverloads.h
inc/MantidAPI/WorkspaceProperty.h
inc/MantidAPI/WorkspaceProperty.tcc
...
...
@@ -361,13 +362,12 @@ set ( TEST_FILES
BinEdgeAxisTest.h
BoxControllerTest.h
CommonBinsValidatorTest.h
ComponentInfoTest.h
CompositeFunctionTest.h
CoordTransformTest.h
CostFunctionFactoryTest.h
DataProcessorAlgorithmTest.h
DetectorInfoTest.h
DetectorSearcherTest.h
DetectorSearcherTest.h
EnabledWhenWorkspaceIsTypeTest.h
EqualBinSizesValidatorTest.h
ExperimentInfoTest.h
...
...
@@ -401,6 +401,8 @@ set ( TEST_FILES
ImmutableCompositeFunctionTest.h
ImplicitFunctionParserFactoryTest.h
IncreasingAxisValidatorTest.h
IndexPropertyTest.h
IndexTypePropertyTest.h
InstrumentDataServiceTest.h
InstrumentValidatorTest.h
LatticeDomainTest.h
...
...
@@ -417,8 +419,6 @@ set ( TEST_FILES
MultiPeriodGroupWorkerTest.h
MultipleExperimentInfosTest.h
MultipleFilePropertyTest.h
WorkspaceNearestNeighbourInfoTest.h
WorkspaceNearestNeighboursTest.h
NotebookBuilderTest.h
NotebookWriterTest.h
NumericAxisTest.h
...
...
@@ -427,7 +427,7 @@ set ( TEST_FILES
ParameterReferenceTest.h
ParameterTieTest.h
PeakFunctionIntegratorTest.h
ProgressTest.h
ProgressTest.h
ProjectionTest.h
RawCountValidatorTest.h
RemoteJobManagerFactoryTest.h
...
...
@@ -449,6 +449,8 @@ set ( TEST_FILES
WorkspaceGroupTest.h
WorkspaceHistoryIOTest.h
WorkspaceHistoryTest.h
WorkspaceNearestNeighbourInfoTest.h
WorkspaceNearestNeighboursTest.h
WorkspaceOpOverloadsTest.h
WorkspacePropertyTest.h
WorkspaceUnitValidatorTest.h
...
...
Framework/API/inc/MantidAPI/Algorithm.h
View file @
874f65c8
...
...
@@ -5,19 +5,21 @@
#include
"MantidAPI/DllConfig.h"
#include
"MantidAPI/IAlgorithm.h"
#include
"MantidAPI/IndexTypeProperty.h"
#include
"MantidKernel/PropertyManagerOwner.h"
// -- These headers will (most-likely) be used by every inheriting algorithm
#include
"MantidAPI/AlgorithmFactory.h"
//for the factory macro
#include
"MantidAPI/IndexTypeProperty.h"
#include
"MantidAPI/Progress.h"
#include
"MantidAPI/WorkspaceProperty.h"
#include
"MantidAPI/WorkspaceOpOverloads.h"
#include
"Mantid
Kernel/MultiThreaded
.h"
#include
"Mantid
API/WorkspaceProperty
.h"
#include
"MantidKernel/EmptyValues.h"
#include
"MantidKernel/MultiThreaded.h"
#include
<MantidIndexing/SpectrumIndexSet.h>
#include
"MantidParallel/ExecutionMode.h"
#include
"MantidParallel/StorageMode.h"
namespace
boost
{
template
<
class
T
>
class
weak_ptr
;
}
...
...
@@ -28,7 +30,7 @@ template <class O> class ActiveStarter;
class
NotificationCenter
;
template
<
class
C
,
class
N
>
class
NObserver
;
class
Void
;
}
}
// namespace Poco
namespace
Json
{
class
Value
;
...
...
@@ -46,48 +48,48 @@ class AlgorithmProxy;
class
AlgorithmHistory
;
/**
Base class from which all concrete algorithm classes should be derived.
In order for a concrete algorithm class to do anything
useful the methods init() & exec() should be overridden.
Further text from Gaudi file.......
The base class provides utility methods for accessing
standard services (event data service etc.); for declaring
properties which may be configured by the job options
service; and for creating Child Algorithms.
The only base class functionality which may be used in the
constructor of a concrete algorithm is the declaration of
member variables as properties. All other functionality,
i.e. the use of services and the creation of Child Algorithms,
may be used only in initialise() and afterwards (see the
Gaudi user guide).
@author Russell Taylor, Tessella Support Services plc
@author Based on the Gaudi class of the same name (see
http://proj-gaudi.web.cern.ch/proj-gaudi/)
@date 12/09/2007
Copyright © 2007-10 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid 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.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
Base class from which all concrete algorithm classes should be derived.
In order for a concrete algorithm class to do anything
useful the methods init() & exec() should be overridden.
Further text from Gaudi file.......
The base class provides utility methods for accessing
standard services (event data service etc.); for declaring
properties which may be configured by the job options
service; and for creating Child Algorithms.
The only base class functionality which may be used in the
constructor of a concrete algorithm is the declaration of
member variables as properties. All other functionality,
i.e. the use of services and the creation of Child Algorithms,
may be used only in initialise() and afterwards (see the
Gaudi user guide).
@author Russell Taylor, Tessella Support Services plc
@author Based on the Gaudi class of the same name (see
http://proj-gaudi.web.cern.ch/proj-gaudi/)
@date 12/09/2007
Copyright © 2007-10 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid 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.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class
MANTID_API_DLL
Algorithm
:
public
IAlgorithm
,
public
Kernel
::
PropertyManagerOwner
{
public:
...
...
@@ -189,6 +191,31 @@ public:
/// Override if the algorithm is not part of the Mantid distribution.
const
std
::
string
helpURL
()
const
override
{
return
""
;
}
template
<
typename
T
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T
*
,
MatrixWorkspace
*
>
::
value
>::
type
>
std
::
tuple
<
boost
::
shared_ptr
<
T
>
,
Indexing
::
SpectrumIndexSet
>
getWorkspaceAndIndices
(
const
std
::
string
&
name
)
const
;
template
<
typename
T1
,
typename
T2
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T1
*
,
MatrixWorkspace
*
>
::
value
>::
type
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T2
*
,
std
::
string
*>::
value
||
std
::
is_convertible
<
T2
*
,
std
::
vector
<
int
>
*>::
value
>::
type
>
void
setWorkspaceInputProperties
(
const
std
::
string
&
name
,
const
boost
::
shared_ptr
<
T1
>
&
wksp
,
IndexType
type
,
const
T2
&
list
);
template
<
typename
T1
,
typename
T2
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T1
*
,
MatrixWorkspace
*
>
::
value
>::
type
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T2
*
,
std
::
string
*>::
value
||
std
::
is_convertible
<
T2
*
,
std
::
vector
<
int
>
*>::
value
>::
type
>
void
setWorkspaceInputProperties
(
const
std
::
string
&
name
,
const
std
::
string
&
wsName
,
IndexType
type
,
const
T2
&
list
);
const
std
::
string
workspaceMethodName
()
const
override
;
const
std
::
vector
<
std
::
string
>
workspaceMethodOn
()
const
override
;
const
std
::
string
workspaceMethodInputProperty
()
const
override
;
...
...
@@ -375,7 +402,18 @@ protected:
/// versions
bool
m_usingBaseProcessGroups
=
false
;
template
<
typename
T
,
typename
=
typename
std
::
enable_if
<
std
::
is_convertible
<
T
*
,
MatrixWorkspace
*
>
::
value
>::
type
>
void
declareWorkspaceInputProperties
(
const
std
::
string
&
propertyName
,
const
int
allowedIndexTypes
=
IndexType
::
WorkspaceIndex
,
PropertyMode
::
Type
optional
=
PropertyMode
::
Type
::
Mandatory
,
LockMode
::
Type
lock
=
LockMode
::
Type
::
Lock
,
const
std
::
string
&
doc
=
""
);
private:
template
<
typename
T1
,
typename
T2
,
typename
WsType
>
void
doSetInputProperties
(
const
std
::
string
&
name
,
const
T1
&
wksp
,
IndexType
type
,
const
T2
&
list
);
void
lockWorkspaces
();
void
unlockWorkspaces
();
...
...
@@ -398,6 +436,8 @@ private:
getInputWorkspaceStorageModes
()
const
;
void
setupSkipValidationMasterOnly
();
bool
isCompoundProperty
(
const
std
::
string
&
name
)
const
;
// --------------------- Private Members -----------------------------------
/// Poco::ActiveMethod used to implement asynchronous execution.
Poco
::
ActiveMethod
<
bool
,
Poco
::
Void
,
Algorithm
,
...
...
@@ -414,7 +454,7 @@ private:
bool
m_isExecuted
;
///< Algorithm is executed flag
bool
m_isChildAlgorithm
;
///< Algorithm is a child algorithm
bool
m_recordHistoryForChild
;
///< Flag to indicate whether history should be
/// recorded. Applicable to child algs only
/// recorded. Applicable to child algs only
bool
m_alwaysStoreInADS
;
///< Always store in the ADS, even for child algos
bool
m_runningAsync
;
///< Algorithm is running asynchronously
std
::
atomic
<
bool
>
m_running
;
///< Algorithm is running
...
...
@@ -423,15 +463,15 @@ private:
/// closedown messages from the base class
/// (default = true)
mutable
double
m_startChildProgress
;
///< Keeps value for algorithm's progress
/// at start of an Child Algorithm
mutable
double
m_endChildProgress
;
///< Keeps value for algorithm's progress
/// at Child Algorithm's finish
AlgorithmID
m_algorithmID
;
///< Algorithm ID for managed algorithms
/// at start of an Child Algorithm
mutable
double
m_endChildProgress
;
///< Keeps value for algorithm's progress
/// at Child Algorithm's finish
AlgorithmID
m_algorithmID
;
///< Algorithm ID for managed algorithms
std
::
vector
<
boost
::
weak_ptr
<
IAlgorithm
>>
m_ChildAlgorithms
;
///< A list of
/// weak pointers
/// to any child
/// algorithms
/// created
/// weak pointers
/// to any child
/// algorithms
/// created
/// Vector of all the workspaces that have been read-locked
WorkspaceVector
m_readLockedWorkspaces
;
...
...
@@ -450,6 +490,8 @@ private:
/// All the groups have similar names (group_1, group_2 etc.)
bool
m_groupsHaveSimilarNames
;
std
::
vector
<
std
::
string
>
m_reservedList
;
/// (MPI) communicator used when executing the algorithm.
std
::
unique_ptr
<
Parallel
::
Communicator
>
m_communicator
;
};
...
...
Framework/API/inc/MantidAPI/Algorithm.tcc
0 → 100644
View file @
874f65c8
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/IndexProperty.h"
#include "MantidAPI/WorkspaceProperty.h"
#include "MantidIndexing/SpectrumIndexSet.h"
namespace {
template <typename T1, typename T2>
void setWorkspaceProperty(Mantid::API::WorkspaceProperty<T1> *wsProp,
const T2 &wksp, const boost::true_type &) {
*wsProp = wksp;
}
template <typename T1, typename T2>
void setWorkspaceProperty(Mantid::API::WorkspaceProperty<T1> *wsProp,
const T2 &wksp, const boost::false_type &) {
wsProp->setValue(wksp);
}
} // namespace
namespace Mantid {
namespace API {
/** Declare a property which defines the workspace and allowed index types, as
* well as a property for capturing the indices all at once. This method is
* only enabled if T is convertible to MatrixWorkspace.
@param propertyName Name of property which will be reserved
@param allowedIndexTypes combination of allowed index types. Default
IndexType::WorkspaceIndex
@param optional Determines if workspace property is optional. Default
PropertyMode::Type::Mandatory
@param lock Determines whether or not the workspace is locked. Default
LockMode::Type::Lock
@param doc Property documentation string.
*/
template <typename T, typename>
void Algorithm::declareWorkspaceInputProperties(const std::string &propertyName,
const int allowedIndexTypes,
PropertyMode::Type optional,
LockMode::Type lock,
const std::string &doc) {
auto wsProp = Kernel::make_unique<WorkspaceProperty<T>>(
propertyName, "", Kernel::Direction::Input, optional, lock);
const auto &wsPropRef = *wsProp;
declareProperty(std::move(wsProp), doc);
auto indexTypePropName =
IndexTypeProperty::generatePropertyName(propertyName);
auto indexTypeProp = Kernel::make_unique<IndexTypeProperty>(
indexTypePropName, allowedIndexTypes);
const auto &indexTypePropRef = *indexTypeProp;
declareProperty(std::move(indexTypeProp));
auto indexPropName = IndexProperty::generatePropertyName(propertyName);
declareProperty(Kernel::make_unique<IndexProperty>(indexPropName, wsPropRef,
indexTypePropRef));
m_reservedList.push_back(propertyName);
m_reservedList.push_back(indexTypePropName);
m_reservedList.push_back(indexPropName);
}
template <typename T1, typename T2, typename WsType>
void Algorithm::doSetInputProperties(const std::string &name, const T1 &wksp,
IndexType type, const T2 &list) {
if (!isCompoundProperty(name))
throw std::runtime_error(
"Algorithm::setWorkspaceInputProperties can only be used "
"with properties declared using "
"declareWorkspaceInputProperties.");
auto *wsProp =
dynamic_cast<WorkspaceProperty<WsType> *>(getPointerToProperty(name));
auto *indexTypeProp = dynamic_cast<IndexTypeProperty *>(
getPointerToProperty(IndexTypeProperty::generatePropertyName(name)));
auto *indexProp = dynamic_cast<IndexProperty *>(
getPointerToProperty(IndexProperty::generatePropertyName(name)));
setWorkspaceProperty<WsType, T1>(
wsProp, wksp, boost::is_convertible<T1, boost::shared_ptr<WsType>>());
*indexTypeProp = type;
*indexProp = list;
}
/** Mechanism for setting the index property with a workspace shared pointer.
* This method can only be used if T1 is convertible to a MatrixWorkspace and
* T2 is either std::string or std::vector<int>
@param name Property name
@param wksp Workspace as a pointer
@param type Index type IndexType::WorkspaceIndex or IndexType::SpectrumNum
@param list List of indices to be used.
*/
template <typename T1, typename T2, typename, typename>
void Algorithm::setWorkspaceInputProperties(const std::string &name,
const boost::shared_ptr<T1> &wksp,
IndexType type, const T2 &list) {
doSetInputProperties<boost::shared_ptr<T1>, T2, T1>(name, wksp, type, list);
}
/** Mechanism for setting the index property with a workspace shared pointer.
* This method can only be used if T1 is convertible to a MatrixWorkspace and
* T2 is either std::string or std::vector<int>
@param name Property name
@param wsName Workspace name as string
@param type Index type IndexType::WorkspaceIndex or IndexType::SpectrumNum
@param list List of indices to be used.
*/
template <typename T1, typename T2, typename, typename>
void Algorithm::setWorkspaceInputProperties(const std::string &name,
const std::string &wsName,
IndexType type, const T2 &list) {
doSetInputProperties<std::string, T2, T1>(name, wsName, type, list);
}
/** Mechanism for retriving the index property. This method can only be used
if T is convertible to a MatrixWorkspace.
@param name Property name
@returns Tuple containing Workspace shared pointer and SpectrumIndexSet
*/
template <typename T, typename>
std::tuple<boost::shared_ptr<T>, Indexing::SpectrumIndexSet>
Algorithm::getWorkspaceAndIndices(const std::string &name) const {
if (!isCompoundProperty(name))
throw std::runtime_error(
"Algorithm::getWorkspacesAndIndices can only be used "
"with properties declared using "
"declareWorkspaceInputProperties.");
boost::shared_ptr<T> ws = getProperty(name);
// Not able to use the regular getProperty mechanism because types, in this
// case SpectrumIndexSet, need to be known upfront. Since SpectrumIndexSet is
// not declared at a level where it can be used in Kernel, this will not work.
// There is an issue which has been created which may solve this and other
// problems related to the property mechanism in the future:
// https://github.com/mantidproject/mantid/issues/20092
auto indexProp = dynamic_cast<IndexProperty *>(
getPointerToProperty(IndexProperty::generatePropertyName(name)));
Indexing::SpectrumIndexSet indexSet = *indexProp;
return std::make_tuple(ws, indexSet);
}
} // namespace API
} // namespace Mantid
\ No newline at end of file
Framework/API/inc/MantidAPI/DetectorSearcher.h
View file @
874f65c8
#ifndef MANTID_DETECTOR_SEARCHER_H_
#define MANTID_DETECTOR_SEARCHER_H_
#include
"MantidAPI/DetectorInfo.h"
#include
"MantidAPI/DllConfig.h"
#include
"MantidGeometry/Instrument.h"
#include
"MantidGeometry/Instrument/DetectorInfo.h"
#include
"MantidGeometry/Objects/InstrumentRayTracer.h"
#include
"MantidKernel/NearestNeighbours.h"
#include
"MantidKernel/V3D.h"
...
...
@@ -60,7 +60,7 @@ public:
/// Create a new DetectorSearcher with the given instrument & detectors
DetectorSearcher
(
Geometry
::
Instrument_const_sptr
instrument
,
const
DetectorInfo
&
detInfo
);
const
Geometry
::
DetectorInfo
&
detInfo
);
/// Find a detector that intsects with the given Qlab vector
DetectorSearchResult
findDetectorIndex
(
const
Kernel
::
V3D
&
q
);
...
...
@@ -91,7 +91,7 @@ private:
/// flag for whether the crystallography convention is to be used
const
double
m_crystallography_convention
;
/// detector info for the instrument
const
DetectorInfo
&
m_detInfo
;
const
Geometry
::
DetectorInfo
&
m_detInfo
;
/// handle to the instrument to search for detectors in
Geometry
::
Instrument_const_sptr
m_instrument
;
/// vector of detector indicies used in the search
...
...
Framework/API/inc/MantidAPI/ExperimentInfo.h
View file @
874f65c8
...
...
@@ -24,16 +24,15 @@ class DetectorInfo;
class
SpectrumInfo
;
}
namespace
Geometry
{
class
ComponentInfo
;
class
DetectorInfo
;
class
IDetector
;
class
InfoComponentVisitor
;
class
ParameterMap
;
class
XMLInstrumentParameter
;
}