Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/7636_icat_p…
Browse files Browse the repository at this point in the history
…ublish. Refs #7636.

Conflicts:
	Code/Mantid/Framework/ICat/inc/MantidICat/ICat4/ICat4Catalog.h
  • Loading branch information
jawrainey committed Dec 11, 2013
2 parents db15e7e + 6ca4ece commit e28c983
Show file tree
Hide file tree
Showing 52 changed files with 4,166 additions and 1,161 deletions.
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/ScopedWorkspace.h
Expand Up @@ -60,6 +60,9 @@ namespace API
/// Retrieve workspace from the ADS
Workspace_sptr retrieve() const;

/// Removes the workspace entry from the ADS
void remove();

/// Operator for conversion to boolean
operator bool() const;

Expand Down
17 changes: 10 additions & 7 deletions Code/Mantid/Framework/API/src/FileProperty.cpp
Expand Up @@ -42,7 +42,7 @@ FileProperty::FileProperty(const std::string & name, const std::string& default_
/* Create either a FileValidator or a DirectoryValidator, depending on Action */
(action == FileProperty::Directory || action == FileProperty::OptionalDirectory) ?
boost::make_shared<DirectoryValidator>(action == FileProperty::Directory) :
boost::make_shared<FileValidator>(exts, (action == FileProperty::Load) )
boost::make_shared<FileValidator>(exts, (action == FileProperty::Load), (action == FileProperty::Save) )
, direction),
m_action(action),
m_defaultExt(""),
Expand All @@ -69,7 +69,7 @@ FileProperty::FileProperty(const std::string & name, const std::string& default_
/* Create either a FileValidator or a DirectoryValidator, depending on Action */
(action == FileProperty::Directory || action == FileProperty::OptionalDirectory) ?
boost::make_shared<DirectoryValidator>(action == FileProperty::Directory) :
boost::make_shared<FileValidator>(std::vector<std::string>(1,ext), (action == FileProperty::Load) )
boost::make_shared<FileValidator>(std::vector<std::string>(1,ext), (action == FileProperty::Load), (action == FileProperty::Save) )
, direction),
m_action(action),
m_defaultExt(ext),
Expand Down Expand Up @@ -370,27 +370,30 @@ std::string FileProperty::createDirectory(const std::string & path) const
{
stempath.makeParent();
}
std::string error("");

if( !stempath.toString().empty() )
{
Poco::File stem(stempath);
if( !stem.exists() )
{
try
{
stem.createDirectories();
stem.createDirectories();
}
catch(Poco::Exception &e)
{
error = e.what();
std::stringstream msg;
msg << "Failed to create directory \"" << stempath.toString()
<< "\": " << e.what() ;
return msg.str();
}
}
}
else
{
error = "Invalid directory.";
return "Invalid directory.";
}
return error;
return ""; // everything went fine
}

/**
Expand Down
41 changes: 26 additions & 15 deletions Code/Mantid/Framework/API/src/ScopedWorkspace.cpp
Expand Up @@ -32,21 +32,7 @@ namespace API
*/
ScopedWorkspace::~ScopedWorkspace()
{
AnalysisDataServiceImpl& ads = AnalysisDataService::Instance();

// When destructed, remove workspace from the ADS if was added and still exists
if ( ads.doesExist(m_name) )
{
if ( ads.retrieveWS<WorkspaceGroup>(m_name) )
{
// If is a group, need to remove all the members as well
ads.deepRemoveGroup(m_name);
}
else
{
ads.remove(m_name);
}
}
remove();
}

/**
Expand All @@ -73,6 +59,28 @@ namespace API

return Workspace_sptr();
}

/**
* Removes the workspace entry from the ADS.
*/
void ScopedWorkspace::remove()
{
AnalysisDataServiceImpl& ads = AnalysisDataService::Instance();

// When destructed, remove workspace from the ADS if was added and still exists
if ( ads.doesExist(m_name) )
{
if ( ads.retrieveWS<WorkspaceGroup>(m_name) )
{
// If is a group, need to remove all the members as well
ads.deepRemoveGroup(m_name);
}
else
{
ads.remove(m_name);
}
}
}

/**
* Make ADS entry to point to the given workspace.
Expand All @@ -84,6 +92,9 @@ namespace API
if ( ! newWS->name().empty() && ads.doesExist( newWS->name() ) )
throw std::invalid_argument( "Workspace is already in the ADS under the name " + newWS->name() );

// Remove previous workspace entry
remove();

ads.add(m_name, newWS);
}

Expand Down
17 changes: 17 additions & 0 deletions Code/Mantid/Framework/API/test/ScopedWorkspaceTest.h
Expand Up @@ -161,6 +161,23 @@ class ScopedWorkspaceTest : public CxxTest::TestSuite
TS_ASSERT( test );
}

void test_settingTwice()
{
ScopedWorkspace test;

MockWorkspace_sptr ws1 = MockWorkspace_sptr(new MockWorkspace);
test.set(ws1);

TS_ASSERT_EQUALS( ws1->name(), test.name() );

MockWorkspace_sptr ws2 = MockWorkspace_sptr(new MockWorkspace);
test.set(ws2);

TS_ASSERT_EQUALS( ws2->name(), test.name() );
TS_ASSERT( ws1->name().empty() );
TS_ASSERT_EQUALS( m_ads.getObjectNamesInclHidden().size(), 1 );
}

private:
AnalysisDataServiceImpl& m_ads;
};
Expand Down
18 changes: 12 additions & 6 deletions Code/Mantid/Framework/Algorithms/CMakeLists.txt
Expand Up @@ -46,8 +46,8 @@ set ( SRC_FILES
src/ConvertToPointData.cpp
src/ConvertUnits.cpp
src/CopyInstrumentParameters.cpp
src/CopySample.cpp
src/CopyLogs.cpp
src/CopySample.cpp
src/CorrectFlightPaths.cpp
src/CorrectKiKf.cpp
src/CorrectToFile.cpp
Expand Down Expand Up @@ -100,8 +100,8 @@ set ( SRC_FILES
src/FindDeadDetectors.cpp
src/FindDetectorsOutsideLimits.cpp
src/FindPeakBackground.cpp
src/FitPeak.cpp
src/FindPeaks.cpp
src/FitPeak.cpp
src/FixGSASInstrumentFile.cpp
src/FlatPlateAbsorption.cpp
src/GeneralisedSecondDifference.cpp
Expand Down Expand Up @@ -139,6 +139,7 @@ set ( SRC_FILES
src/MultipleScatteringCylinderAbsorption.cpp
src/Multiply.cpp
src/MultiplyRange.cpp
src/MuonGroupDetectors.cpp
src/NormaliseByCurrent.cpp
src/NormaliseByDetector.cpp
src/NormaliseToMonitor.cpp
Expand Down Expand Up @@ -167,6 +168,7 @@ set ( SRC_FILES
src/RebinToWorkspace.cpp
src/Rebunch.cpp
src/RecordPythonScript.cpp
src/ReflectometryReductionOne.cpp
src/Regroup.cpp
src/RemoveBins.cpp
src/RemoveExpDecay.cpp
Expand Down Expand Up @@ -266,8 +268,8 @@ set ( INC_FILES
inc/MantidAlgorithms/ConvertToPointData.h
inc/MantidAlgorithms/ConvertUnits.h
inc/MantidAlgorithms/CopyInstrumentParameters.h
inc/MantidAlgorithms/CopySample.h
inc/MantidAlgorithms/CopyLogs.h
inc/MantidAlgorithms/CopySample.h
inc/MantidAlgorithms/CorrectFlightPaths.h
inc/MantidAlgorithms/CorrectKiKf.h
inc/MantidAlgorithms/CorrectToFile.h
Expand Down Expand Up @@ -320,8 +322,8 @@ set ( INC_FILES
inc/MantidAlgorithms/FindDeadDetectors.h
inc/MantidAlgorithms/FindDetectorsOutsideLimits.h
inc/MantidAlgorithms/FindPeakBackground.h
inc/MantidAlgorithms/FitPeak.h
inc/MantidAlgorithms/FindPeaks.h
inc/MantidAlgorithms/FitPeak.h
inc/MantidAlgorithms/FixGSASInstrumentFile.h
inc/MantidAlgorithms/FlatPlateAbsorption.h
inc/MantidAlgorithms/GSLFunctions.h
Expand Down Expand Up @@ -360,6 +362,7 @@ set ( INC_FILES
inc/MantidAlgorithms/MultipleScatteringCylinderAbsorption.h
inc/MantidAlgorithms/Multiply.h
inc/MantidAlgorithms/MultiplyRange.h
inc/MantidAlgorithms/MuonGroupDetectors.h
inc/MantidAlgorithms/NormaliseByCurrent.h
inc/MantidAlgorithms/NormaliseByDetector.h
inc/MantidAlgorithms/NormaliseToMonitor.h
Expand Down Expand Up @@ -388,6 +391,7 @@ set ( INC_FILES
inc/MantidAlgorithms/RebinToWorkspace.h
inc/MantidAlgorithms/Rebunch.h
inc/MantidAlgorithms/RecordPythonScript.h
inc/MantidAlgorithms/ReflectometryReductionOne.h
inc/MantidAlgorithms/Regroup.h
inc/MantidAlgorithms/RemoveBins.h
inc/MantidAlgorithms/RemoveExpDecay.h
Expand Down Expand Up @@ -498,8 +502,8 @@ set ( TEST_FILES
ConvertToPointDataTest.h
ConvertUnitsTest.h
CopyInstrumentParametersTest.h
CopySampleTest.h
CopyLogsTest.h
CopySampleTest.h
CorrectFlightPathsTest.h
CorrectKiKfTest.h
CorrectToFileTest.h
Expand Down Expand Up @@ -546,8 +550,8 @@ set ( TEST_FILES
FindDeadDetectorsTest.h
FindDetectorsOutsideLimitsTest.h
FindPeakBackgroundTest.h
FitPeakTest.h
FindPeaksTest.h
FitPeakTest.h
FixGSASInstrumentFileTest.h
FlatPlateAbsorptionTest.h
GenerateEventsFilterTest.h
Expand Down Expand Up @@ -579,6 +583,7 @@ set ( TEST_FILES
MultipleScatteringCylinderAbsorptionTest.h
MultiplyRangeTest.h
MultiplyTest.h
MuonGroupDetectorsTest.h
NormaliseByCurrentTest.h
NormaliseByDetectorTest.h
NormaliseToMonitorTest.h
Expand All @@ -604,6 +609,7 @@ set ( TEST_FILES
RebinTest.h
RebinToWorkspaceTest.h
RebunchTest.h
ReflectometryReductionOneTest.h
RegroupTest.h
RemoveBinsTest.h
RemoveExpDecayTest.h
Expand Down
@@ -1,20 +1,15 @@
#ifndef MANTID_DATAHANDLING_APPLYGROUPINGFROMMUONNEXUS_H_
#define MANTID_DATAHANDLING_APPLYGROUPINGFROMMUONNEXUS_H_
#ifndef MANTID_ALGORITHMS_MUONGROUPDETECTORS_H_
#define MANTID_ALGORITHMS_MUONGROUPDETECTORS_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/Workspace2D.h"

namespace Mantid
{
namespace DataHandling
namespace Algorithms
{
using namespace DataObjects;
/**
Applies grouping information from Muon Nexus file to the workspace.

@author Arturs Bekasovs
@date 10/10/2013
/** MuonGroupDetectors : applies detector grouping to a workspace. (Muon version)
Copyright &copy; 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Expand All @@ -36,9 +31,12 @@ namespace DataHandling
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport ApplyGroupingFromMuonNexus : public API::Algorithm
class DLLExport MuonGroupDetectors : public API::Algorithm
{
public:
MuonGroupDetectors();
virtual ~MuonGroupDetectors();

virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
Expand All @@ -48,15 +46,11 @@ namespace DataHandling
void init();
void exec();

bool checkGroups();
bool processGroups();

/// Applies grouping to a given workspace
Workspace2D_sptr applyGrouping(const std::vector<int>& detectorGrouping, Workspace2D_const_sptr inputWs);
};


} // namespace DataHandling
} // namespace Algorithms
} // namespace Mantid

#endif /* MANTID_DATAHANDLING_APPLYGROUPINGFROMMUONNEXUS_H_ */
#endif /* MANTID_ALGORITHMS_MUONGROUPDETECTORS_H_ */

0 comments on commit e28c983

Please sign in to comment.