Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #10131. Worker class put in place.
- Loading branch information
1 parent
1ef3adb
commit 2433568
Showing
6 changed files
with
226 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Code/Mantid/Framework/API/inc/MantidAPI/MultiPeriodGroupWorker.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#ifndef MANTID_API_MULTIPERIODGROUPWORKER_H_ | ||
#define MANTID_API_MULTIPERIODGROUPWORKER_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/IAlgorithm.h" | ||
#include <string> | ||
|
||
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. | ||
Copyright © 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: | ||
MultiPeriodGroupWorker(); | ||
MultiPeriodGroupWorker(const std::string& workspacePropertyName); | ||
virtual ~MultiPeriodGroupWorker(); | ||
/// Getter for the input workspace property name | ||
std::string getInputWorkspacePropertyName() const; | ||
/// Flag to indicate use of a custom workspace property | ||
bool useCustomWorkspaceProperty() const; | ||
/// Check groups | ||
bool checkGroups(IAlgorithm_sptr alg) const; | ||
|
||
private: | ||
MultiPeriodGroupWorker(const MultiPeriodGroupWorker&); | ||
MultiPeriodGroupWorker& operator=(const MultiPeriodGroupWorker&); | ||
|
||
/// Workspace property name | ||
std::string m_workspacePropertyName; | ||
|
||
}; | ||
|
||
} // namespace API | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_API_MULTIPERIODGROUPWORKER_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "MantidAPI/MultiPeriodGroupWorker.h" | ||
|
||
namespace Mantid | ||
{ | ||
namespace API | ||
{ | ||
|
||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Constructor | ||
*/ | ||
MultiPeriodGroupWorker::MultiPeriodGroupWorker() | ||
{ | ||
} | ||
|
||
/** | ||
* Constructor | ||
* @param workspacePropertyName : Property name to treat as source of multiperiod workspaces. | ||
*/ | ||
MultiPeriodGroupWorker::MultiPeriodGroupWorker(const std::string& workspacePropertyName) : m_workspacePropertyName(workspacePropertyName) | ||
{ | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Destructor | ||
*/ | ||
MultiPeriodGroupWorker::~MultiPeriodGroupWorker() | ||
{ | ||
} | ||
|
||
|
||
bool MultiPeriodGroupWorker::checkGroups(IAlgorithm_sptr alg) const | ||
{ | ||
return false; | ||
} | ||
|
||
bool MultiPeriodGroupWorker::useCustomWorkspaceProperty() const | ||
{ | ||
return !this->m_workspacePropertyName.empty(); | ||
} | ||
|
||
|
||
} // namespace API | ||
} // namespace Mantid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* MultiPeriodGroupTestBase.h | ||
* | ||
* Created on: 18 Aug 2014 | ||
* Author: spu92482 | ||
*/ | ||
|
||
#ifndef MANTID_API_MULTIPERIODGROUPTESTBASE_H_ | ||
#define MANTID_API_MULTIPERIODGROUPTESTBASE_H_ | ||
|
||
#include "MantidAPI/AnalysisDataService.h" | ||
#include "MantidAPI/WorkspaceGroup.h" | ||
#include "MantidAPI/MatrixWorkspace.h" | ||
#include "MantidKernel/PropertyWithValue.h" | ||
#include "MantidTestHelpers/FakeObjects.h" | ||
|
||
|
||
using namespace Mantid::API; | ||
using namespace Mantid::Kernel; | ||
|
||
class MultiPeriodGroupTestBase | ||
{ | ||
|
||
protected: | ||
|
||
// Helper method to add multiperiod logs to make a workspacegroup look like a real multiperiod workspace group. | ||
void add_periods_logs(WorkspaceGroup_sptr ws) | ||
{ | ||
int nperiods = static_cast<int>(ws->size()); | ||
for (size_t i = 0; i < ws->size(); ++i) | ||
{ | ||
MatrixWorkspace_sptr currentWS = boost::dynamic_pointer_cast<MatrixWorkspace>(ws->getItem(i)); | ||
PropertyWithValue<int>* nperiodsProp = new PropertyWithValue<int>("nperiods", nperiods); | ||
currentWS->mutableRun().addLogData(nperiodsProp); | ||
PropertyWithValue<int>* currentPeriodsProp = new PropertyWithValue<int>("current_period", | ||
static_cast<int>(i + 1)); | ||
currentWS->mutableRun().addLogData(currentPeriodsProp); | ||
} | ||
} | ||
|
||
/// Helper to fabricate a workspace group consisting of equal sized matrixworkspaces. | ||
WorkspaceGroup_sptr create_good_multiperiod_workspace_group(const std::string name) | ||
{ | ||
MatrixWorkspace_sptr a = MatrixWorkspace_sptr(new WorkspaceTester); | ||
MatrixWorkspace_sptr b = MatrixWorkspace_sptr(new WorkspaceTester); | ||
|
||
WorkspaceGroup_sptr group = boost::make_shared<WorkspaceGroup>(); | ||
//group->setName(name); | ||
group->addWorkspace(a); | ||
group->addWorkspace(b); | ||
add_periods_logs(group); | ||
|
||
AnalysisDataService::Instance().addOrReplace(name + "_1", a); | ||
AnalysisDataService::Instance().addOrReplace(name + "_2", b); | ||
AnalysisDataService::Instance().addOrReplace(name, group); | ||
return group; | ||
} | ||
|
||
}; | ||
|
||
#endif /* MANTID_API_MULTIPERIODGROUPTESTBASE_H_ */ |
Oops, something went wrong.