11 #ifndef HISTFACTORY_HISTREF_H
12 #define HISTFACTORY_HISTREF_H
19 namespace HistFactory {
31 HistRef(TH1 * h =
nullptr) : fHist(h) {}
33 HistRef(
const HistRef& other ) :
35 if (other.fHist) fHist.reset(CopyObject(other.fHist.get()));
38 HistRef(HistRef&& other) :
39 fHist(std::move(other.fHist)) {}
44 HistRef & operator= (
const HistRef & other) {
45 if (
this == &other)
return *
this;
47 fHist.reset(CopyObject(other.fHist.get()));
51 HistRef& operator=(HistRef&& other) {
52 fHist = std::move(other.fHist);
56 TH1 * GetObject()
const {
return fHist.get(); }
59 void SetObject(TH1 *h) {
64 void operator= (TH1 * h) { SetObject(h); }
67 TH1* ReleaseObject() {
68 return fHist.release();
74 static TH1 * CopyObject(
const TH1 * h);
75 std::unique_ptr<TH1> fHist;