Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mantidproject/mantid into feature…
Browse files Browse the repository at this point in the history
…/9907_update_idf_schema
  • Loading branch information
Anders-Markvardsen committed Sep 9, 2014
2 parents 0ab3ff5 + 2af01ab commit 22f4e5c
Show file tree
Hide file tree
Showing 36 changed files with 4,984 additions and 806 deletions.
31 changes: 17 additions & 14 deletions Code/Mantid/Framework/API/CMakeLists.txt
Expand Up @@ -10,7 +10,7 @@ set ( SRC_FILES
src/AnalysisDataService.cpp
src/ArchiveSearchFactory.cpp
src/Axis.cpp
src/BinEdgeAxis.cpp
src/BinEdgeAxis.cpp
src/BoxController.cpp
src/CatalogFactory.cpp
src/CatalogManager.cpp
Expand Down Expand Up @@ -42,9 +42,9 @@ set ( SRC_FILES
src/FunctionProperty.cpp
src/FunctionValues.cpp
src/GridDomain.cpp
src/GridDomain1D.cpp
src/HistoryItem.cpp
src/HistoryView.cpp
src/GridDomain1D.cpp
src/HistoryItem.cpp
src/HistoryView.cpp
src/IDomainCreator.cpp
src/IEventList.cpp
src/IEventWorkspace.cpp
Expand Down Expand Up @@ -85,6 +85,7 @@ set ( SRC_FILES
src/ModeratorModel.cpp
src/MultiDomainFunction.cpp
src/MultiPeriodGroupAlgorithm.cpp
src/MultiPeriodGroupWorker.cpp
src/MultipleExperimentInfos.cpp
src/MultipleFileProperty.cpp
src/NullCoordTransform.cpp
Expand All @@ -105,7 +106,7 @@ set ( SRC_FILES
src/Sample.cpp
src/SampleEnvironment.cpp
src/ScopedWorkspace.cpp
src/ScriptBuilder.cpp
src/ScriptBuilder.cpp
src/ScriptRepository.cpp
src/ScriptRepositoryFactory.cpp
src/SpectraAxis.cpp
Expand Down Expand Up @@ -143,7 +144,7 @@ set ( INC_FILES
inc/MantidAPI/AnalysisDataService.h
inc/MantidAPI/ArchiveSearchFactory.h
inc/MantidAPI/Axis.h
inc/MantidAPI/BinEdgeAxis.h
inc/MantidAPI/BinEdgeAxis.h
inc/MantidAPI/BoxController.h
inc/MantidAPI/CatalogFactory.h
inc/MantidAPI/CatalogManager.h
Expand Down Expand Up @@ -180,9 +181,9 @@ set ( INC_FILES
inc/MantidAPI/FunctionProperty.h
inc/MantidAPI/FunctionValues.h
inc/MantidAPI/GridDomain.h
inc/MantidAPI/GridDomain1D.h
inc/MantidAPI/GridDomain1D.h
inc/MantidAPI/HistoryItem.h
inc/MantidAPI/HistoryView.h
inc/MantidAPI/HistoryView.h
inc/MantidAPI/IAlgorithm.h
inc/MantidAPI/IArchiveSearch.h
inc/MantidAPI/IBackgroundFunction.h
Expand Down Expand Up @@ -242,6 +243,7 @@ set ( INC_FILES
inc/MantidAPI/ModeratorModel.h
inc/MantidAPI/MultiDomainFunction.h
inc/MantidAPI/MultiPeriodGroupAlgorithm.h
inc/MantidAPI/MultiPeriodGroupWorker.h
inc/MantidAPI/MultipleExperimentInfos.h
inc/MantidAPI/MultipleFileProperty.h
inc/MantidAPI/NullCoordTransform.h
Expand All @@ -263,7 +265,7 @@ set ( INC_FILES
inc/MantidAPI/Sample.h
inc/MantidAPI/SampleEnvironment.h
inc/MantidAPI/ScopedWorkspace.h
inc/MantidAPI/ScriptBuilder.h
inc/MantidAPI/ScriptBuilder.h
inc/MantidAPI/ScriptRepository.h
inc/MantidAPI/ScriptRepositoryFactory.h
inc/MantidAPI/SingleValueParameter.h
Expand Down Expand Up @@ -296,7 +298,7 @@ set ( TEST_FILES
AlgorithmTest.h
AnalysisDataServiceTest.h
AsynchronousTest.h
BinEdgeAxisTest.h
BinEdgeAxisTest.h
BoxControllerTest.h
CompositeFunctionTest.h
CoordTransformTest.h
Expand All @@ -316,8 +318,8 @@ set ( TEST_FILES
FunctionPropertyTest.h
FunctionTest.h
FunctionValuesTest.h
HistoryItemTest.h
HistoryViewTest.h
HistoryItemTest.h
HistoryViewTest.h
IEventListTest.h
IFunction1DSpectrumTest.h
IFunction1DTest.h
Expand All @@ -338,6 +340,7 @@ set ( TEST_FILES
ModeratorModelTest.h
MultiDomainFunctionTest.h
MultiPeriodGroupAlgorithmTest.h
MultiPeriodGroupWorkerTest.h
MultipleExperimentInfosTest.h
MultipleFilePropertyTest.h
NumericAxisTest.h
Expand All @@ -353,17 +356,17 @@ set ( TEST_FILES
RunTest.h
SampleEnvironmentTest.h
SampleTest.h
ScriptBuilderTest.h
ScopedWorkspaceTest.h
ScriptBuilderTest.h
SpectraAxisTest.h
SpectrumDetectorMappingTest.h
TextAxisTest.h
VectorParameterParserTest.h
VectorParameterTest.h
WorkspaceFactoryTest.h
WorkspaceGroupTest.h
WorkspaceHistoryTest.h
WorkspaceHistoryIOTest.h
WorkspaceHistoryTest.h
WorkspaceOpOverloadsTest.h
WorkspacePropertyTest.h
)
Expand Down
22 changes: 12 additions & 10 deletions Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h
Expand Up @@ -261,6 +261,18 @@ class MANTID_API_DLL Algorithm : public IAlgorithm, public Kernel::PropertyManag
/// set whether we wish to track the child algorithm's history and pass it the parent object to fill.
void trackAlgorithmHistory(boost::shared_ptr<AlgorithmHistory> parentHist);

typedef std::vector<boost::shared_ptr<Workspace> > WorkspaceVector;

void findWorkspaceProperties(WorkspaceVector& inputWorkspaces,
WorkspaceVector& outputWorkspaces) const;

// ------------------ For WorkspaceGroups ------------------------------------
virtual bool checkGroups();

virtual bool processGroups();

void copyNonWorkspaceProperties(IAlgorithm * alg, int periodNum);

protected:

/// Virtual method - must be overridden by concrete algorithm
Expand Down Expand Up @@ -312,17 +324,7 @@ class MANTID_API_DLL Algorithm : public IAlgorithm, public Kernel::PropertyManag
friend class WorkspaceHistory; // Allow workspace history loading to adjust g_execCount
static size_t g_execCount; ///< Counter to keep track of algorithm execution order

// ------------------ For WorkspaceGroups ------------------------------------
virtual bool checkGroups();

virtual bool processGroups();
virtual void setOtherProperties(IAlgorithm * alg, const std::string & propertyName, const std::string & propertyValue, int periodNum);
typedef std::vector<boost::shared_ptr<Workspace> > WorkspaceVector;

void findWorkspaceProperties(WorkspaceVector& inputWorkspaces,
WorkspaceVector& outputWorkspaces) const;

void copyNonWorkspaceProperties(IAlgorithm * alg, int periodNum);

/// All the WorkspaceProperties that are Input or InOut. Set in execute()
std::vector<IWorkspaceProperty *> m_inputWorkspaceProps;
Expand Down
Expand Up @@ -3,6 +3,9 @@

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/MultiPeriodGroupWorker.h"
#include <boost/scoped_ptr.hpp>


namespace Mantid
{
Expand Down Expand Up @@ -45,27 +48,20 @@ namespace API
virtual bool processGroups();
/// Method to provide the name for the input workspace property.
virtual std::string fetchInputPropertyName() const = 0;
/// Metod to indicate that a non-standard property is taken as the input, so will be specified via fetchInputPropertyName.
/// Method to indicate that a non-standard property is taken as the input, so will be specified via fetchInputPropertyName.
virtual bool useCustomInputPropertyName() const {return false;}
/// Try to add the input workspace to the input group list.
void tryAddInputWorkspaceToInputGroups(Workspace_sptr ws);
/// Copy input workspace properties to spawned algorithm.
void copyInputWorkspaceProperties(IAlgorithm* alg, const int& periodNumber);

std::string createFormattedInputWorkspaceNames(const size_t& periodIndex) const;
void validateMultiPeriodGroupInputs(const size_t& nInputWorkspaces) const;

/// Flag used to determine whether to use base or local virtual methods.
bool m_useDefaultGroupingBehaviour;
/// Convenience typdef for workspace names.
typedef std::vector<boost::shared_ptr<Mantid::API::WorkspaceGroup> > VecWSGroupType;
typedef MultiPeriodGroupWorker::VecWSGroupType VecWSGroupType;
/// multi period group workspaces.
VecWSGroupType m_multiPeriodGroups;
/// Multiperiod group worker.
boost::scoped_ptr<MultiPeriodGroupWorker> m_worker;

};


} // namespace API
} // namespace Mantid

#endif /* MANTID_API_MUTLIPERIODGROUPALGORITHM_H_ */
#endif /* MANTID_API_MUTLIPERIODGROUPALGORITHM_H_ */
91 changes: 91 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/MultiPeriodGroupWorker.h
@@ -0,0 +1,91 @@
#ifndef MANTID_API_MULTIPERIODGROUPWORKER_H_
#define MANTID_API_MULTIPERIODGROUPWORKER_H_

#include "MantidKernel/System.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidAPI/Algorithm.h"
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>

namespace Mantid
{
namespace API
{

/** MultiPeriodGroupWorker : Multiperiod group logic relating to determining a valid multiperiod group, and processing a
* multiperiod group, as well as combining and returning the output.
*
*
* Determines if the input workspaces are multiperiod group workspaces
* Processes the multiperiod group workspaces period by period running a new instance of the target algorithm for each one, then regrouping the results
*
*
Copyright &copy; 2014 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
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 DLLExport MultiPeriodGroupWorker
{
public:
/// Convenience typdef for workspace names.
typedef std::vector<boost::shared_ptr<Mantid::API::WorkspaceGroup> > VecWSGroupType;
/// Constructor
MultiPeriodGroupWorker();
/// Copy constructor
MultiPeriodGroupWorker(const std::string& workspacePropertyName);
virtual ~MultiPeriodGroupWorker();
/// Flag to indicate use of a custom workspace property
bool useCustomWorkspaceProperty() const;
/// Check groups
VecWSGroupType findMultiPeriodGroups(Algorithm const * const sourceAlg) const;
/// Process groups
bool processGroups(Algorithm * const sourceAlg, const VecWSGroupType& vecMultiPeriodGroups) const;

private:
// Disable copy
MultiPeriodGroupWorker(const MultiPeriodGroupWorker&);
// Disable assignment
MultiPeriodGroupWorker& operator=(const MultiPeriodGroupWorker&);

/// Try ot add a workspace to the group of input workspaces.
void tryAddInputWorkspaceToInputGroups(Workspace_sptr ws,
VecWSGroupType& vecWorkspaceGroups) const;

/// Copy input workspace properties to spawned algorithm.
void copyInputWorkspaceProperties(IAlgorithm* targetAlg, IAlgorithm* sourceAlg,
const int& periodNumber) const;

/// Create an input workspace string from the workspace groups.
std::string createFormattedInputWorkspaceNames(const size_t& periodIndex,
const VecWSGroupType& vecWorkspaceGroups) const;

/// Validate the input group workspace
void validateMultiPeriodGroupInputs(const VecWSGroupType& vecMultiPeriodGroups) const;

/// Workspace property name
std::string m_workspacePropertyName;

};

} // namespace API
} // namespace Mantid

#endif /* MANTID_API_MULTIPERIODGROUPWORKER_H_ */

0 comments on commit 22f4e5c

Please sign in to comment.