25 static void Print(
bool abbrev =
true);
44 template<
class T>
class Proxy;
48 template<
class T>
class Proxy 51 static_assert(std::is_arithmetic_v<T> || std::is_enum_v<T> || std::is_same_v<T, std::string>,
"Invalid type for basic type Proxy");
70 operator T()
const {
return GetValue();}
81 void CheckEquals(
const T& x)
const;
84 T GetValueNested()
const;
85 T GetValueFlatSingle()
const;
86 T GetValueFlatMulti()
const;
92 typedef typename std::conditional_t<std::is_enum_v<T>,
int,
T>
U;
126 void CheckIndex(
size_t i,
size_t size)
const;
127 TTree* GetTreeForName()
const;
174 Proxy& operator=(
const Proxy<std::vector<T>>&) =
delete;
186 for(
unsigned int i = 0;
i < x.size(); ++
i) at(
i) = x[
i];
193 fSize.CheckEquals(x.size());
194 for(
unsigned int i = 0;
i <
std::min(
size(), x.size()); ++
i) at(
i).CheckEquals(x[
i]);
199 template<
class U>
class iterator
208 iterator(const Proxy<std::vector<T>>* p, int i) : fParent(p), fIdx(i) {}
214 iterator<const T>
begin()
const {
return iterator<const T>(
this, 0 );}
215 iterator< T>
begin() {
return iterator< T>(
this, 0 );}
216 iterator<const T>
end()
const {
return iterator<const T>(
this,
size());}
217 iterator< T>
end() {
return iterator< T>(
this,
size());}
223 CheckIndex(i,
size());
224 if(i >= fElems.size()) fElems.resize(i+1);
226 if(fIdxP) fIdx = *fIdxP;
228 if(!fElems[i]) fElems[
i] =
new Proxy<T>(fDir, GetTreeForName(), Subscript(i), fIdx,
i);
239 template<
class T>
bool operator<(const Proxy<std::vector<T>>&
a,
240 const std::vector<T>&
b)
242 const size_t N = a.size();
243 if(N !=
b.size())
return N <
b.size();
244 for(
size_t i = 0;
i < N; ++
i){
245 if(a[
i] !=
b[
i])
return a[
i] <
b[
i];
269 if(fIdxP) fIdx = *fIdxP;
275 if(fIdxP) fIdx = *fIdxP;
281 for(
unsigned int i = 0;
i < N; ++
i) (*
this)[
i] =
x[
i];
287 for(
unsigned int i = 0;
i < N; ++
i) (*
this)[
i].CheckEquals(
x[
i]);
294 if(!fElems[i]) fElems[
i] =
new Proxy<T>(fDir, fTree, Subscript(i), fIdx,
i);
312 for(
auto it = fVals.rbegin();
it != fVals.rend(); ++
it)
313 *
it->first =
it->second;
318 fVals.emplace_back(p, v);
322 std::vector<std::pair<T*, T>>
fVals;
354 for(
const Restorer*
r: fRestorers)
if(
r)
return true;
360 fRestorers.push_back(0);
365 return !fRestorers.empty();
370 assert(!fRestorers.empty());
371 if(fRestorers.back()) ++fGeneration;
372 delete fRestorers.back();
373 fRestorers.pop_back();
380 if(!InTransaction())
return 0;
385 template<
class T>
friend class Proxy;
389 assert(!fRestorers.empty());
390 if(!fRestorers.back()){
394 fRestorers.back()->
Add(p);
Proxy< T > & at(size_t i) const
T max(const caf::Proxy< T > &a, T b)
static void ToFile(const std::string &fname)
Proxy< long long > * fIdxP
TDC::value_type operator+=(TDC lhs, TDC rhs)
static std::set< std::string > fgBranches
static bool InTransaction()
static void BeginTransaction()
Proxy(TDirectory *d, TTree *tr, const std::string &name, const long &base, int offset)
Proxy< T > & operator[](size_t i)
Proxy< std::vector< T > > & operator=(const std::vector< U > &x)
static void Backup(Proxy< T > &p)
iterator< U > & operator++()
void EnsureSize(size_t i) const
Implies CheckIndex()
bool operator!=(const iterator< U > &it) const
Proxy< T[N]> & operator=(const T(&x)[N])
const Proxy< std::vector< T > > * fParent
Proxy< T > & operator[](size_t i) const
const XML_Char int const XML_Char int const XML_Char * base
std::vector< std::pair< T *, T > > fVals
CAFType GetCAFType(const TDirectory *dir, TTree *tr)
TFormLeafInfo * fLeafInfo
std::vector< Proxy< T > * > fElems
static void Print(bool abbrev=true)
static long long Generation()
int NSubscripts(const std::string &name)
Count the subscripts in the name.
void resize(T &x, std::vector< int > dims)
Proxy(TDirectory *d, TTree *tr, const std::string &name, const long &base, int offset)
bool operator==(const iterator< U > &it) const
std::conditional_t< std::is_enum_v< T >, int, T > U
void CheckEquals(const std::vector< U > &x) const
static float min(const float a, const float b, const float c)
static const std::set< std::string > & GetBranches()
void EnsureElem(int i) const
assert(nhit_max >=nhit_nbins)
Proxy< T > & operator[](size_t i)
static void AddBranch(const std::string &b)
static std::vector< Restorer * > fRestorers
This module creates Common Analysis Files.
T min(const caf::Proxy< T > &a, T b)
const Proxy< T > & operator[](size_t i) const
Proxy< T > & at(size_t i)
static long long fGeneration
std::array< Proxy< T > *, N > fElems
void CheckEquals(const T(&x)[N]) const
iterator< const T > end() const
iterator< const T > begin() const
T max(T a, const caf::Proxy< T > &b)