9#include "MantidDataObjects/DllConfig.h"
10#include "MantidHistogramData/Histogram.h"
26namespace DataObjects {
93MANTID_DATAOBJECTS_DLL HistogramData::Histogram
stripData(HistogramData::Histogram histogram);
95template <
class T> std::unique_ptr<T>
createHelper() {
return std::make_unique<T>(); }
99template <> MANTID_DATAOBJECTS_DLL std::unique_ptr<API::HistoWorkspace>
createHelper();
102template <> MANTID_DATAOBJECTS_DLL std::unique_ptr<EventWorkspace>
createHelper();
104template <> MANTID_DATAOBJECTS_DLL std::unique_ptr<API::MatrixWorkspace>
createHelper();
115 const HistogramData::Histogram &histArg);
119template <
class UseIndexInfo>
126template <
class T,
class P,
class IndexArg,
class HistArg,
127 class =
typename std::enable_if<std::is_base_of<API::MatrixWorkspace, P>::value>::type>
128std::unique_ptr<T>
create(
const P &parent,
const IndexArg &indexArg,
const HistArg &histArg) {
133 std::unique_ptr<T> ws;
134 if (std::is_base_of<API::HistoWorkspace, T>::value && parent.id() ==
"EventWorkspace") {
136 ws = detail::createHelper<T>();
140 ws =
dynamic_cast<const T &
>(parent).cloneEmpty();
141 }
catch (std::bad_cast &) {
143 ws = detail::createConcreteHelper<T>();
152 ws->setInstrument(parent.getInstrument());
153 ws->initialize(indexArg, HistogramData::Histogram(histArg));
154 detail::initializeFromParent<typename detail::IsIndexInfo<IndexArg>::type>(parent, *ws);
162template <
class T,
class IndexArg,
class HistArg,
163 typename std::enable_if<!std::is_base_of<API::MatrixWorkspace, IndexArg>::value>::type * =
nullptr>
164std::unique_ptr<T>
create(
const IndexArg &indexArg,
const HistArg &histArg) {
165 auto ws = std::make_unique<T>();
166 ws->initialize(indexArg, HistogramData::Histogram(histArg));
170template <
class T,
class IndexArg,
class HistArg,
171 typename std::enable_if<!std::is_base_of<API::MatrixWorkspace, IndexArg>::value>::type * =
nullptr>
172std::unique_ptr<T>
create(
const std::shared_ptr<const Geometry::Instrument> &instrument,
const IndexArg &indexArg,
173 const HistArg &histArg) {
174 auto ws = std::make_unique<T>();
175 ws->setInstrument(std::move(instrument));
176 ws->initialize(indexArg, HistogramData::Histogram(histArg));
180template <class T, class P, typename std::enable_if<std::is_base_of<API::MatrixWorkspace, P>::value>::type * =
nullptr>
181std::unique_ptr<T>
create(
const P &parent) {
182 const auto numHistograms = parent.getNumberHistograms();
183 auto ws = create<T>(parent, numHistograms,
detail::stripData(parent.histogram(0)));
184 for (
size_t i = 0; i < numHistograms; ++i) {
185 ws->setSharedX(i, parent.sharedX(i));
193template <class T, class P, typename std::enable_if<std::is_base_of<API::MatrixWorkspace, P>::value>::type * =
nullptr>
194std::unique_ptr<T>
create(
const P &parent,
const HistogramData::Histogram &histogram) {
195 return create<T>(parent, parent.getNumberHistograms(), histogram);
198template <class T, class P, typename std::enable_if<std::is_base_of<API::MatrixWorkspace, P>::value>::type * =
nullptr>
199std::unique_ptr<T>
create(
const P &parent,
const HistogramData::BinEdges &binEdges) {
200 return create<T>(parent, parent.getNumberHistograms(), binEdges);
203template <class T, class P, typename std::enable_if<std::is_base_of<API::MatrixWorkspace, P>::value>::type * =
nullptr>
204std::unique_ptr<T>
create(
const P &parent,
const HistogramData::Points &points) {
205 return create<T>(parent, parent.getNumberHistograms(), points);
IPeaksWorkspace_sptr workspace
Base MatrixWorkspace Abstract Class.
MANTID_DATAOBJECTS_DLL HistogramData::Histogram stripData(HistogramData::Histogram histogram)
void initializeFromParent(const API::MatrixWorkspace &parent, API::MatrixWorkspace &workspace)
Initialize a MatrixWorkspace from its parent including instrument, unit, number of spectra and Run.
std::unique_ptr< T > createHelper()
std::unique_ptr< T > createConcreteHelper()
void fixDistributionFlag(API::MatrixWorkspace &, const HistArg &)
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
Helper class which provides the Collimation Length for SANS instruments.