11 template <
typename Uncerta
intyApproachT>
13 : pimpl_(new OwningModel<UncertaintyApproachT>(std::move(uncertaintyApproach)),
14 [](void *uncertaintyApproachBytes) {
15 using Model = OwningModel<UncertaintyApproachT>;
16 auto *
const model =
static_cast<Model *
>(uncertaintyApproachBytes);
19 uncertaintyOperation_([](
void *uncertaintyApproachBytes,
20 const std::vector<double> &values,
const int numCoreErrMember,
22 using Model = OwningModel<UncertaintyApproachT>;
23 auto *
const model =
static_cast<Model *
>(uncertaintyApproachBytes);
24 return model->Uncertainty(values, numCoreErrMember, cl, uncertainty);
26 correlationOperation_(
27 [](
void *uncertaintyApproachBytes,
const std::vector<double> &valuesA,
28 const std::vector<double> &valuesB,
const int numCoreErrMember) ->
double {
29 using Model = OwningModel<UncertaintyApproachT>;
30 auto *
const model =
static_cast<Model *
>(uncertaintyApproachBytes);
31 return model->Correlation(valuesA, valuesB, numCoreErrMember);
33 clone_([](
void *uncertaintyApproachBytes) ->
void * {
34 using Model = OwningModel<UncertaintyApproachT>;
35 auto *
const model =
static_cast<Model *
>(uncertaintyApproachBytes);
36 return new Model(*model);
41 void Uncertainty(
const std::vector<double> &values,
const int numCoreErrMember,
const double cl,
44 uncertaintyOperation_(pimpl_.get(), values, numCoreErrMember, cl, uncertainty);
47 double Correlation(
const std::vector<double> &valuesA,
const std::vector<double> &valuesB,
48 const int numCoreErrMember)
const
50 return correlationOperation_(pimpl_.get(), valuesA, valuesB, numCoreErrMember);
60 : pimpl_(other.clone_(other.pimpl_.get()), other.pimpl_.get_deleter()),
61 clone_(other.clone_), correlationOperation_(other.correlationOperation_),
62 uncertaintyOperation_(other.uncertaintyOperation_)
78 swap(pimpl_, copy.pimpl_);
79 swap(clone_, copy.clone_);
80 swap(correlationOperation_, copy.correlationOperation_);
81 swap(uncertaintyOperation_, copy.uncertaintyOperation_);
90 template <
typename Uncerta
intyApproachT>
struct OwningModel
92 OwningModel(UncertaintyApproachT uncertaintyApporach)
93 : uncertaintyApporach_(std::move(uncertaintyApporach))
97 double Correlation(
const std::vector<double> &valuesA,
const std::vector<double> &valuesB,
98 const int numCoreErrMember)
100 return uncertaintyApporach_.Correlation(valuesA, valuesB, numCoreErrMember);
102 void Uncertainty(
const std::vector<double> &values,
const int numCoreErrMember,
105 return uncertaintyApporach_.Uncertainty(values, numCoreErrMember, cl, uncertainty);
107 UncertaintyApproachT uncertaintyApporach_;
110 using DestroyOperation = void(
void *);
111 using CloneOperation =
void *(
void *);
112 using UncertaintyOperation = void(
void *,
const std::vector<double> &,
const int,
const double,
114 using CorrelationOperation = double(
void *,
const std::vector<double> &,
115 const std::vector<double> &,
const int);
117 std::unique_ptr<void, DestroyOperation *> pimpl_;
118 CloneOperation *clone_{
nullptr};
119 UncertaintyOperation *uncertaintyOperation_{
nullptr};
120 CorrelationOperation *correlationOperation_{
nullptr};
Definition: IUncertainty.h:9
void Uncertainty(const std::vector< double > &values, const int numCoreErrMember, const double cl, PDFUncertainty &uncertainty) const
Definition: IUncertainty.h:41
IUncertainty & operator=(IUncertainty &&other)=default
IUncertainty(IUncertainty &&other) noexcept=default
IUncertainty & operator=(IUncertainty const &other)
Assignment operator for ICPDF objects.
Definition: IUncertainty.h:74
IUncertainty(UncertaintyApproachT uncertaintyApproach)
Definition: IUncertainty.h:12
double Correlation(const std::vector< double > &valuesA, const std::vector< double > &valuesB, const int numCoreErrMember) const
Definition: IUncertainty.h:47
IUncertainty(const IUncertainty &other)
Copy constructor for ICPDF objects.
Definition: IUncertainty.h:59
Definition: AllFlavorsShape.h:14
Structure for storage of uncertainty info calculated over a PDF error set.
Definition: Uncertainty.h:10