Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
caf::Proxy< T[N]> Class Template Reference

#include "SRProxy/BasicTypesProxy.h"

Inheritance diagram for caf::Proxy< T[N]>:
caf::ArrayVectorProxyBase

Public Member Functions

 Proxy (TDirectory *d, TTree *tr, const std::string &name, const long &base, int offset)
 
 ~Proxy ()
 
Proxyoperator= (const Proxy< T[N]> &)=delete
 
 Proxy (const Proxy< T[N]> &v)=delete
 
const Proxy< T > & operator[] (size_t i) const
 
Proxy< T > & operator[] (size_t i)
 
Proxy< T[N]> & operator= (const T(&x)[N])
 
void CheckEquals (const T(&x)[N]) const
 
std::string Name () const
 

Protected Member Functions

void EnsureElem (int i) const
 
void CheckIndex (size_t i, size_t size) const
 
TTree * GetTreeForName () const
 
std::string IndexField () const
 
std::string Subscript (int i) const
 add [i], or something more complex for nested CAFs More...
 

Protected Attributes

std::array< Proxy< T > *, N > fElems
 
TDirectory * fDir
 
TTree * fTree
 
std::string fName
 
CAFType fType
 
const long & fBase
 
int fOffset
 
Proxy< long long > * fIdxP
 
long fIdx
 

Detailed Description

template<class T, unsigned int N>
class caf::Proxy< T[N]>

Definition at line 249 of file BasicTypesProxy.h.

Constructor & Destructor Documentation

template<class T , unsigned int N>
caf::Proxy< T[N]>::Proxy ( TDirectory *  d,
TTree *  tr,
const std::string name,
const long &  base,
int  offset 
)
inline

Definition at line 252 of file BasicTypesProxy.h.

254  {
255  }
const XML_Char * name
Definition: expat.h:151
ArrayVectorProxyBase(TDirectory *d, TTree *tr, const std::string &name, const long &base, int offset)
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
Float_t d
Definition: plot.C:236
template<class T , unsigned int N>
caf::Proxy< T[N]>::~Proxy ( )
inline

Definition at line 257 of file BasicTypesProxy.h.

References e, T, and registry_explorer::v.

258  {
259  for(Proxy<T>* e: fElems) delete e;
260  }
Float_t e
Definition: plot.C:35
std::array< Proxy< T > *, N > fElems
template<class T , unsigned int N>
caf::Proxy< T[N]>::Proxy ( const Proxy< T[N]> &  v)
delete

Member Function Documentation

template<class T , unsigned int N>
void caf::Proxy< T[N]>::CheckEquals ( const T(&)  x[N]) const
inline

Definition at line 284 of file BasicTypesProxy.h.

References MECModelEnuComparisons::i, and submit_syst::x.

285  {
286  for(unsigned int i = 0; i < N; ++i) (*this)[i].CheckEquals(x[i]);
287  }
void caf::ArrayVectorProxyBase::CheckIndex ( size_t  i,
size_t  size 
) const
protectedinherited

Definition at line 404 of file BasicTypesProxy.cxx.

References om::cout, allTimeWatchdog::endl, and caf::ArrayVectorProxyBase::fName.

405  {
406  // This is the only way to get good error messages. But it also seems like
407  // the call to size() here is necessary in Nested mode to trigger some
408  // side-effect within ROOT, otherwise we get some bogus index out-of-range
409  // crashes.
410  if(i >= size){
411  std::cout << std::endl << fName << "[" << (signed)i << "] out of range (size() == " << size << "). Aborting." << std::endl;
412  abort();
413  }
414  }
OStream cout
Definition: OStream.cxx:6
template<class T , unsigned int N>
void caf::Proxy< T[N]>::EnsureElem ( int  i) const
inlineprotected

Definition at line 290 of file BasicTypesProxy.h.

References MECModelEnuComparisons::i.

291  {
292  CheckIndex(i, N);
293  if(!fElems[i]) fElems[i] = new Proxy<T>(fDir, fTree, Subscript(i), fIdx, i);
294  }
std::string Subscript(int i) const
add [i], or something more complex for nested CAFs
void CheckIndex(size_t i, size_t size) const
std::array< Proxy< T > *, N > fElems
TTree * caf::ArrayVectorProxyBase::GetTreeForName ( ) const
protectedinherited

Definition at line 482 of file BasicTypesProxy.cxx.

References om::cout, allTimeWatchdog::endl, caf::ArrayVectorProxyBase::fDir, caf::ArrayVectorProxyBase::fName, caf::ArrayVectorProxyBase::fTree, caf::ArrayVectorProxyBase::fType, caf::kFlatMultiTree, string, caf::StripSubscripts(), and make_root_from_grid_output::tr.

483  {
484  if(fType != kFlatMultiTree) return fTree; // all in the same tree
485 
486  const std::string sname = StripSubscripts(fName);
487  TTree* tr = (TTree*)fDir->Get(sname.c_str());
488  if(!tr){
489  std::cout << "Couldn't find TTree " << sname
490  << " in " << fDir->GetName() << std::endl;
491  abort();
492  }
493  return tr;
494  }
std::string StripSubscripts(const std::string &s)
OStream cout
Definition: OStream.cxx:6
enum BeamMode string
std::string caf::ArrayVectorProxyBase::IndexField ( ) const
protectedinherited
std::string caf::ArrayVectorProxyBase::Name ( void  ) const
inlineinherited
template<class T , unsigned int N>
Proxy& caf::Proxy< T[N]>::operator= ( const Proxy< T[N]> &  )
delete
template<class T , unsigned int N>
Proxy<T[N]>& caf::Proxy< T[N]>::operator= ( const T(&)  x[N])
inline

Definition at line 278 of file BasicTypesProxy.h.

References MECModelEnuComparisons::i, and submit_syst::x.

279  {
280  for(unsigned int i = 0; i < N; ++i) (*this)[i] = x[i];
281  return *this;
282  }
template<class T , unsigned int N>
const Proxy<T>& caf::Proxy< T[N]>::operator[] ( size_t  i) const
inline

Definition at line 265 of file BasicTypesProxy.h.

References MECModelEnuComparisons::i.

266  {
267  EnsureElem(i);
268  if(fIdxP) fIdx = *fIdxP;
269  return *fElems[i];
270  }
Proxy< long long > * fIdxP
void EnsureElem(int i) const
std::array< Proxy< T > *, N > fElems
template<class T , unsigned int N>
Proxy<T>& caf::Proxy< T[N]>::operator[] ( size_t  i)
inline

Definition at line 271 of file BasicTypesProxy.h.

References MECModelEnuComparisons::i.

272  {
273  EnsureElem(i);
274  if(fIdxP) fIdx = *fIdxP;
275  return *fElems[i];
276  }
Proxy< long long > * fIdxP
void EnsureElem(int i) const
std::array< Proxy< T > *, N > fElems
std::string caf::ArrayVectorProxyBase::Subscript ( int  i) const
protectedinherited

add [i], or something more complex for nested CAFs

Definition at line 468 of file BasicTypesProxy.cxx.

References caf::ArrayVectorProxyBase::fName, caf::ArrayVectorProxyBase::fType, compare_h5_caf::idx, caf::kNested, caf::NSubscripts(), and art::to_string().

469  {
470  // Only have to do the at() business for the nested case for subscripts
471  // from the 3rd one on
472  if(fType != kNested || NSubscripts(fName) < 2){
473  return fName+"["+std::to_string(i)+"]";
474  }
475 
476  const int idx = fName.find_last_of('.');
477 
478  return fName.substr(0, idx)+".@"+fName.substr(idx+1)+".at("+std::to_string(i)+")";
479  }
int NSubscripts(const std::string &name)
Count the subscripts in the name.
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32

Member Data Documentation

const long& caf::ArrayVectorProxyBase::fBase
protectedinherited

Definition at line 137 of file BasicTypesProxy.h.

TDirectory* caf::ArrayVectorProxyBase::fDir
protectedinherited

Definition at line 133 of file BasicTypesProxy.h.

Referenced by caf::ArrayVectorProxyBase::GetTreeForName().

template<class T , unsigned int N>
std::array<Proxy<T>*, N> caf::Proxy< T[N]>::fElems
mutableprotected

Definition at line 296 of file BasicTypesProxy.h.

long caf::ArrayVectorProxyBase::fIdx
mutableprotectedinherited

Definition at line 140 of file BasicTypesProxy.h.

Proxy<long long>* caf::ArrayVectorProxyBase::fIdxP
protectedinherited
std::string caf::ArrayVectorProxyBase::fName
protectedinherited
int caf::ArrayVectorProxyBase::fOffset
protectedinherited

Definition at line 138 of file BasicTypesProxy.h.

TTree* caf::ArrayVectorProxyBase::fTree
protectedinherited
CAFType caf::ArrayVectorProxyBase::fType
protectedinherited

The documentation for this class was generated from the following file: