Commit f7f9f03c authored by Nick Draper's avatar Nick Draper
Browse files

Merge branch 'master' of github.com:mantidproject/mantid into 15450_spectrum_index_corrections

# Conflicts:
#	Framework/API/inc/MantidAPI/Axis.h

re #15450
parents 3feaa83c 2d597642
......@@ -262,11 +262,11 @@ if ( ENABLE_CPACK )
if( "${UNIX_CODENAME}" MATCHES "Santiago" )
# On RHEL6 we have to use an updated qscintilla to fix an auto complete bug
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES} qscintilla >= 2.4.6, boost148" )
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES} qscintilla >= 2.4.6, boost157" )
# On RHEL6 we are using SCL packages for Qt
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},scl-utils,mantidlibs34,mantidlibs34-runtime,mantidlibs34-qt,mantidlibs34-qt-x11,mantidlibs34-qt-webkit,mantidlibs34-qwt5-qt4" )
else()
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES} qscintilla,qwt5-qt4,python-matplotlib-qt4,boost >= 1.48.0" )
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES} qscintilla,qwt5-qt4,python-matplotlib-qt4,boost >= 1.53.0" )
endif()
# Add software collections for RHEL
......
......@@ -4,13 +4,15 @@
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include <deque>
#include <string>
#include <Poco/NotificationCenter.h>
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/SingletonHolder.h"
#include "MantidAPI/Algorithm.h"
#include <deque>
#include <mutex>
#include <string>
namespace Mantid {
namespace API {
......@@ -97,7 +99,7 @@ private:
std::deque<IAlgorithm_sptr>
m_managed_algs; ///< pointers to managed algorithms [policy???]
/// Mutex for modifying/accessing the m_managed_algs member.
mutable Kernel::Mutex m_managedMutex;
mutable std::mutex m_managedMutex;
};
/// Forward declaration of a specialisation of SingletonHolder for
......
......@@ -88,7 +88,7 @@ public:
virtual size_t indexOfValue(const double value) const = 0;
/// Get the spectrum number
virtual specid_t spectraNo(const std::size_t &index) const;
virtual specnum_t spectraNo(const std::size_t &index) const;
/// Get the length of the axis
virtual std::size_t length() const = 0;
......
......@@ -2,7 +2,6 @@
#define BOXCONTROLLER_H_
#include "MantidKernel/DiskBuffer.h"
#include "MantidKernel/MultiThreaded.h"
#include "MantidKernel/System.h"
#include "MantidKernel/ThreadPool.h"
#include "MantidKernel/Exception.h"
......@@ -84,7 +83,7 @@ public:
//-----------------------------------------------------------------------------------
/** @return the mutex for avoiding simultaneous assignments of box Ids. */
inline Kernel::Mutex &getIdMutex() { return m_idMutex; }
inline std::mutex &getIdMutex() { return m_idMutex; }
//-----------------------------------------------------------------------------------
/** Return true if the MDBox should split, given :
......@@ -286,7 +285,7 @@ public:
*boxes.
*/
void trackNumBoxes(size_t depth) {
m_mutexNumMDBoxes.lock();
std::lock_guard<std::mutex> lock(m_mutexNumMDBoxes);
if (m_numMDBoxes[depth] > 0) {
m_numMDBoxes[depth]--;
}
......@@ -303,7 +302,6 @@ public:
} else {
m_numMDBoxes[depth + 1] += m_numSplit;
}
m_mutexNumMDBoxes.unlock();
}
/** Return the vector giving the number of MD Boxes as a function of depth */
......@@ -357,13 +355,12 @@ public:
/** Reset the number of boxes tracked in m_numMDBoxes */
void resetNumBoxes() {
m_mutexNumMDBoxes.lock();
std::lock_guard<std::mutex> lock(m_mutexNumMDBoxes);
m_numMDBoxes.clear();
m_numMDBoxes.resize(m_maxDepth + 1, 0); // Reset to 0
m_numMDGridBoxes.resize(m_maxDepth + 1, 0); // Reset to 0
m_numMDBoxes[0] = 1; // Start at 1 at depth 0.
resetMaxNumBoxes(); // Also the maximums
m_mutexNumMDBoxes.unlock();
}
// { return m_useWriteBuffer; }
......@@ -495,14 +492,14 @@ private:
std::vector<size_t> m_numMDGridBoxes;
/// Mutex for changing the number of MD Boxes.
Mantid::Kernel::Mutex m_mutexNumMDBoxes;
std::mutex m_mutexNumMDBoxes;
/// This is the maximum number of MD boxes there could be at each recursion
/// level (e.g. (splitInto ^ ndims) ^ depth )
std::vector<double> m_maxNumMDBoxes;
/// Mutex for getting IDs
Mantid::Kernel::Mutex m_idMutex;
std::mutex m_idMutex;
// the class which does actual IO operations, including MRU support list
boost::shared_ptr<IBoxControllerIO> m_fileIO;
......
......@@ -12,6 +12,7 @@
#include "MantidKernel/DeltaEMode.h"
#include <list>
#include <mutex>
namespace Mantid {
//---------------------------------------------------------------------------
......@@ -198,7 +199,7 @@ private:
/// Detector grouping information
det2group_map m_detgroups;
/// Mutex to protect against cow_ptr copying
mutable Poco::Mutex m_mutex;
mutable std::recursive_mutex m_mutex;
};
/// Shared pointer to ExperimentInfo
......
......@@ -8,7 +8,8 @@
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/DynamicFactory.h"
#include "MantidKernel/SingletonHolder.h"
#include "MantidKernel/MultiThreaded.h"
#include <mutex>
namespace Mantid {
......@@ -116,7 +117,7 @@ private:
void addTie(boost::shared_ptr<IFunction> fun, const Expression &expr) const;
mutable std::map<std::string, std::vector<std::string>> m_cachedFunctionNames;
mutable Kernel::Mutex m_mutex;
mutable std::mutex m_mutex;
};
/**
......@@ -126,7 +127,7 @@ private:
*/
template <typename FunctionType>
const std::vector<std::string> &FunctionFactoryImpl::getFunctionNames() const {
Kernel::Mutex::ScopedLock _lock(m_mutex);
std::lock_guard<std::mutex> _lock(m_mutex);
const std::string soughtType(typeid(FunctionType).name());
if (m_cachedFunctionNames.find(soughtType) != m_cachedFunctionNames.end()) {
......
......@@ -24,7 +24,7 @@ public:
IEventList() {}
/// Constructor
IEventList(specid_t specNo) : ISpectrum(specNo) {}
IEventList(specnum_t specNo) : ISpectrum(specNo) {}
/// Return the current event type for the list
virtual Mantid::API::EventType getEventType() const = 0;
......
......@@ -135,7 +135,7 @@ public:
* spectra.
* @param specList :: A vector with spectra indices.
*/
virtual void setSpectra(const std::vector<specid_t> &specList) {
virtual void setSpectra(const std::vector<specnum_t> &specList) {
(void)specList;
}
......
......@@ -47,7 +47,7 @@ namespace API {
class DLLExport ISpectrum {
public:
ISpectrum();
ISpectrum(const specid_t specNo);
ISpectrum(const specnum_t specNo);
ISpectrum(const ISpectrum &other);
virtual ~ISpectrum();
......@@ -112,9 +112,9 @@ public:
void clearDetectorIDs();
// ---------------------------------------------------------
specid_t getSpectrumNo() const;
specnum_t getSpectrumNo() const;
void setSpectrumNo(specid_t num);
void setSpectrumNo(specnum_t num);
// ---------------------------------------------------------
virtual void lockData() const;
......@@ -126,7 +126,7 @@ public:
protected:
/// The spectrum number of this spectrum
specid_t m_specNo;
specnum_t m_specNo;
/// Set of the detector IDs associated with this spectrum
std::set<detid_t> detectorIDs;
......
......@@ -103,18 +103,18 @@ public:
/// Causes the nearest neighbours map to be rebuilt
void rebuildNearestNeighbours();
/// Query the NearestNeighbours object for a detector
std::map<specid_t, Mantid::Kernel::V3D>
std::map<specnum_t, Mantid::Kernel::V3D>
getNeighbours(const Geometry::IDetector *comp, const double radius = 0.0,
const bool ignoreMaskedDetectors = false) const;
/// Query the NearestNeighbours object for a given spectrum number using a
/// search radius
std::map<specid_t, Mantid::Kernel::V3D>
getNeighbours(specid_t spec, const double radius,
std::map<specnum_t, Mantid::Kernel::V3D>
getNeighbours(specnum_t spec, const double radius,
const bool ignoreMaskedDetectors = false) const;
/// Query the NearestNeighbours object for a given spectrum number using the
/// direct number of nearest neighbours
std::map<specid_t, Mantid::Kernel::V3D>
getNeighboursExact(specid_t spec, const int nNeighbours,
std::map<specnum_t, Mantid::Kernel::V3D>
getNeighboursExact(specnum_t spec, const int nNeighbours,
const bool ignoreMaskedDetectors = false) const;
//@}
......@@ -130,14 +130,15 @@ public:
virtual std::vector<size_t>
getDetectorIDToWorkspaceIndexVector(detid_t &offset,
bool throwIfMultipleDets = false) const;
virtual std::vector<size_t>
getSpectrumToWorkspaceIndexVector(specid_t &offset) const;
getSpectrumToWorkspaceIndexVector(specnum_t &offset) const;
std::vector<size_t>
getIndicesFromSpectra(const std::vector<specid_t> &spectraList) const;
size_t getIndexFromSpectrumNumber(const specid_t specNo) const;
getIndicesFromSpectra(const std::vector<specnum_t> &spectraList) const;
size_t getIndexFromSpectrumNumber(const specnum_t specNo) const;
std::vector<size_t>
getIndicesFromDetectorIDs(const std::vector<detid_t> &detIdList) const;
std::vector<specid_t>
std::vector<specnum_t>
getSpectraFromDetectorIDs(const std::vector<detid_t> &detIdList) const;
bool hasGroupedDetectors() const;
......
......@@ -5,8 +5,8 @@
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/MultiThreaded.h"
#include "MantidKernel/SingletonHolder.h"
#include <mutex>
namespace Mantid {
namespace API {
......@@ -76,7 +76,7 @@ private:
*/
size_t memoryCleared;
/// Mutex for adding to memoryCleared
Kernel::Mutex accumulatorMutex;
std::mutex accumulatorMutex;
};
/// Forward declaration of a specialisation of SingletonHolder for
......
......@@ -8,8 +8,6 @@
#include <boost/shared_ptr.hpp>
using namespace Mantid::Kernel;
namespace Mantid {
namespace API {
......@@ -51,9 +49,9 @@ public:
/// Default constructor builds identity projection
Projection();
/// Three dimensional value constructor, w is the cross product of u and v.
Projection(const V3D &u, const V3D &v);
Projection(const Kernel::V3D &u, const Kernel::V3D &v);
/// Three dimensional value constructor
Projection(const V3D &u, const V3D &v, const V3D &w);
Projection(const Kernel::V3D &u, const Kernel::V3D &v, const Kernel::V3D &w);
/// Construct from an ITableWorkspace
Projection(const ITableWorkspace &ws);
/// Copy constructor
......@@ -65,23 +63,23 @@ public:
/// Retrieves the offset for the given dimension
double getOffset(size_t nd);
/// Retrieves the axis vector for the given dimension
V3D getAxis(size_t nd);
Kernel::V3D getAxis(size_t nd);
/// Retrives the unit of the given dimension
ProjectionUnit getUnit(size_t nd);
/// Set the offset for a given dimension
void setOffset(size_t nd, double offset);
/// Set the axis vector for a given dimension
void setAxis(size_t nd, V3D axis);
void setAxis(size_t nd, Kernel::V3D axis);
/// Set the unit for a given dimension
void setUnit(size_t nd, ProjectionUnit unit);
V3D &U() { return m_dimensions[0]; }
V3D &V() { return m_dimensions[1]; }
V3D &W() { return m_dimensions[2]; }
Kernel::V3D &U() { return m_dimensions[0]; }
Kernel::V3D &V() { return m_dimensions[1]; }
Kernel::V3D &W() { return m_dimensions[2]; }
protected:
/// The dimensions
V3D m_dimensions[3];
Kernel::V3D m_dimensions[3];
/// The offsets for each dimension
double m_offsets[3];
/// The units for each dimension
......
......@@ -61,7 +61,7 @@ public:
bool operator==(const Axis &) const override;
std::string label(const std::size_t &index) const override;
specid_t spectraNo(const std::size_t &index) const override;
specnum_t spectraNo(const std::size_t &index) const override;
// Get a map that contains the spectra index as the key and the index in the
// array as the value
spec2index_map getSpectraIndexMap() const;
......
......@@ -15,12 +15,12 @@ namespace Mantid {
#ifndef HAS_UNORDERED_MAP_H
/// Map with key = spectrum number, value = workspace index
typedef std::map<specid_t, size_t> spec2index_map;
typedef std::map<specnum_t, size_t> spec2index_map;
/// Map with key = detector ID, value = workspace index
typedef std::map<detid_t, size_t> detid2index_map;
#else
/// Map with key = spectrum number, value = workspace index
typedef std::tr1::unordered_map<specid_t, size_t> spec2index_map;
typedef std::tr1::unordered_map<specnum_t, size_t> spec2index_map;
/// Map with key = detector ID, value = workspace index
typedef std::tr1::unordered_map<detid_t, size_t> detid2index_map;
#endif
......
......@@ -50,34 +50,34 @@ class MatrixWorkspace;
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class MANTID_API_DLL SpectrumDetectorMapping {
typedef std::unordered_map<specid_t, std::set<detid_t>> sdmap;
typedef std::unordered_map<specnum_t, std::set<detid_t>> sdmap;
public:
explicit SpectrumDetectorMapping(const MatrixWorkspace *const workspace,
bool useSpecNoIndex = true);
SpectrumDetectorMapping(
const std::vector<specid_t> &spectrumNumbers,
const std::vector<specnum_t> &spectrumNumbers,
const std::vector<detid_t> &detectorIDs,
const std::vector<detid_t> &ignoreDetIDs = std::vector<detid_t>());
SpectrumDetectorMapping(const specid_t *const spectrumNumbers,
SpectrumDetectorMapping(const specnum_t *const spectrumNumbers,
const detid_t *const detectorIDs,
size_t arrayLengths);
SpectrumDetectorMapping();
virtual ~SpectrumDetectorMapping();
std::set<specid_t> getSpectrumNumbers() const;
std::set<specnum_t> getSpectrumNumbers() const;
const std::set<detid_t> &
getDetectorIDsForSpectrumNo(const specid_t spectrumNo) const;
getDetectorIDsForSpectrumNo(const specnum_t spectrumNo) const;
const std::set<detid_t> &
getDetectorIDsForSpectrumIndex(const size_t index) const;
const sdmap &getMapping() const;
bool indexIsSpecNumber() const;
private:
void fillMapFromArray(const specid_t *const spectrumNumbers,
void fillMapFromArray(const specnum_t *const spectrumNumbers,
const detid_t *const detectorIDs,
const size_t arrayLengths);
void fillMapFromVector(const std::vector<specid_t> &spectrumNumbers,
void fillMapFromVector(const std::vector<specnum_t> &spectrumNumbers,
const std::vector<detid_t> &detectorIDs,
const std::vector<detid_t> &ignoreDetIDs);
......
......@@ -9,7 +9,7 @@
#include "MantidAPI/AnalysisDataService.h"
#include <Poco/NObserver.h>
#include <Poco/Mutex.h>
#include <mutex>
namespace Mantid {
......@@ -145,7 +145,7 @@ private:
/// Flag as to whether the observers have been added to the ADS
bool m_observingADS;
/// Recursive mutex to avoid simultaneous access
mutable Poco::Mutex m_mutex;
mutable std::recursive_mutex m_mutex;
friend class AnalysisDataServiceImpl;
friend class Algorithm;
......
......@@ -6,9 +6,6 @@
#include "MantidAPI/AlgorithmFactory.h"
#include "MantidAPI/Algorithm.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/MultiThreaded.h"
using Mantid::Kernel::Mutex;
namespace Mantid {
namespace API {
......@@ -66,7 +63,7 @@ Algorithm_sptr AlgorithmManagerImpl::createUnmanaged(const std::string &algName,
IAlgorithm_sptr AlgorithmManagerImpl::create(const std::string &algName,
const int &version,
bool makeProxy) {
Mutex::ScopedLock _lock(this->m_managedMutex);
std::lock_guard<std::mutex> _lock(this->m_managedMutex);
IAlgorithm_sptr alg;
try {
Algorithm_sptr unmanagedAlg = AlgorithmFactory::Instance().create(
......@@ -122,7 +119,7 @@ IAlgorithm_sptr AlgorithmManagerImpl::create(const std::string &algName,
* Clears all managed algorithm objects.
*/
void AlgorithmManagerImpl::clear() {
Mutex::ScopedLock _lock(this->m_managedMutex);
std::lock_guard<std::mutex> _lock(this->m_managedMutex);
m_managed_algs.clear();
return;
}
......@@ -148,7 +145,7 @@ void AlgorithmManagerImpl::setMaxAlgorithms(int n) {
* @returns A shared pointer to the algorithm
*/
IAlgorithm_sptr AlgorithmManagerImpl::getAlgorithm(AlgorithmID id) const {
Mutex::ScopedLock _lock(this->m_managedMutex);
std::lock_guard<std::mutex> _lock(this->m_managedMutex);
for (const auto &managed_alg : m_managed_algs) {
if ((*managed_alg).getAlgorithmID() == id)
return managed_alg;
......@@ -161,7 +158,7 @@ IAlgorithm_sptr AlgorithmManagerImpl::getAlgorithm(AlgorithmID id) const {
* @param id :: The ID of the algorithm
*/
void AlgorithmManagerImpl::removeById(AlgorithmID id) {
Mutex::ScopedLock _lock(this->m_managedMutex);
std::lock_guard<std::mutex> _lock(this->m_managedMutex);
auto itend = m_managed_algs.end();
for (auto it = m_managed_algs.begin(); it != itend; ++it) {
if ((**it).getAlgorithmID() == id) {
......@@ -206,7 +203,7 @@ AlgorithmManagerImpl::newestInstanceOf(const std::string &algorithmName) const {
std::vector<IAlgorithm_const_sptr> AlgorithmManagerImpl::runningInstancesOf(
const std::string &algorithmName) const {
std::vector<IAlgorithm_const_sptr> theRunningInstances;
Mutex::ScopedLock _lock(this->m_managedMutex);
std::lock_guard<std::mutex> _lock(this->m_managedMutex);
for (auto currentAlgorithm : m_managed_algs) {
if (currentAlgorithm->name() == algorithmName &&
currentAlgorithm->isRunning()) {
......@@ -219,7 +216,7 @@ std::vector<IAlgorithm_const_sptr> AlgorithmManagerImpl::runningInstancesOf(
/// Requests cancellation of all running algorithms
void AlgorithmManagerImpl::cancelAll() {
Mutex::ScopedLock _lock(this->m_managedMutex);
std::lock_guard<std::mutex> _lock(this->m_managedMutex);
for (auto &managed_alg : m_managed_algs) {
if (managed_alg->isRunning())
managed_alg->cancel();
......
......@@ -63,7 +63,7 @@ double Axis::getValue(const std::size_t &index,
* @return The spectrum number as an int
* @throw domain_error If this method is called on a numeric axis
*/
specid_t Axis::spectraNo(const std::size_t &index) const {
specnum_t Axis::spectraNo(const std::size_t &index) const {
UNUSED_ARG(index)
throw std::domain_error("Cannot call spectraNo() on a non-spectra axis.");
}
......
......@@ -116,10 +116,9 @@ BoxController::~BoxController() {
* @returns initial ID to use in the range
*/
size_t BoxController::claimIDRange(size_t range) {
m_idMutex.lock();
std::lock_guard<std::mutex> lock(m_idMutex);
size_t tmp = m_maxId;
m_maxId += range;
m_idMutex.unlock();
return tmp;
}
/** Serialize to an XML string
......
......@@ -59,7 +59,7 @@ std::string CompositeFunction::asString() const {
}
if (name() != "CompositeFunction" || nAttributes() > 1 ||
getAttribute("NumDeriv").asBool() == true) {
getAttribute("NumDeriv").asBool()) {
ostr << "composite=" << name();
std::vector<std::string> attr = this->getAttributeNames();
for (const auto &attName : attr) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment