ATLAS Offline Software
Loading...
Searching...
No Matches
TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait > Class Template Reference

Base class for nested containers. More...

#include <NestedContainer.h>

Collaboration diagram for TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >:

Public Types

typedef T value_type
 Type of atomic element.
typedef const T const_value_type
 const Type of atomic element.
typedef Trait trait_type
 Type of trait.
typedef std::vector< std::pair< ExpandedIdentifier, const T * > > FlatContainer
 fill vector with all entries in the container. needed to dump to Peter's flat file format

Public Member Functions

 NestedContainerBase ()
 constructor
 ~NestedContainerBase ()=default
 destructor
void set (const ExpandedIdentifier &id, const T &t)
 set a value.
const T & get (const ExpandedIdentifier &id) const
 get a value.
const T & get (const ExpandedIdentifier &id, size_t &resolvelevel) const
const T & get () const
 get the default value
void set (const T &t)
 set the default value
void clear ()
 clear entire container
void clear (const ExpandedIdentifier &id)
 clear only entries specified
const DaughterContainerdaughters () const
 return the vector of daughters
size_t numObjects () const
 return the total number of valid calibration objects
bool operator== (const NestedContainerBase &rhs) const
 equality operator, used for compressing
bool operator== (const T &rhs) const
 another equality operator, used for compressing
size_t footprint () const
 return the memory allocated by the container and its daughters
void crunch ()
 reduce the footprint as much as possible by removing the extra space allocated by the vectors
void printindent () const
 some IO for debugging
void print () const
void getall (FlatContainer &entries) const

Private Types

typedef std::vector< Daughter > DaughterContainer
 typedef of container

Private Attributes

DaughterContainer m_daughters
 Container of Daughters.
m_default
 Type of atomic element.

Detailed Description

template<int NestingLevel, class Daughter, class T, class Trait>
class TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >

Base class for nested containers.

Definition at line 150 of file NestedContainer.h.

Member Typedef Documentation

◆ const_value_type

template<int NestingLevel, class Daughter, class T, class Trait>
typedef const T TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::const_value_type

const Type of atomic element.

Definition at line 161 of file NestedContainer.h.

◆ DaughterContainer

template<int NestingLevel, class Daughter, class T, class Trait>
typedef std::vector<Daughter> TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::DaughterContainer
private

typedef of container

Definition at line 154 of file NestedContainer.h.

◆ FlatContainer

template<int NestingLevel, class Daughter, class T, class Trait>
typedef std::vector< std::pair<ExpandedIdentifier, const T*> > TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::FlatContainer

fill vector with all entries in the container. needed to dump to Peter's flat file format

Definition at line 346 of file NestedContainer.h.

◆ trait_type

template<int NestingLevel, class Daughter, class T, class Trait>
typedef Trait TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::trait_type

Type of trait.

Definition at line 162 of file NestedContainer.h.

◆ value_type

template<int NestingLevel, class Daughter, class T, class Trait>
typedef T TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::value_type

Type of atomic element.

Definition at line 160 of file NestedContainer.h.

Constructor & Destructor Documentation

◆ NestedContainerBase()

template<int NestingLevel, class Daughter, class T, class Trait>
TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::NestedContainerBase ( )
inline

constructor

Definition at line 165 of file NestedContainer.h.

Base class for nested containers.
T m_default
Type of atomic element.
DaughterContainer m_daughters
Container of Daughters.

◆ ~NestedContainerBase()

template<int NestingLevel, class Daughter, class T, class Trait>
TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::~NestedContainerBase ( )
default

destructor

Member Function Documentation

◆ clear() [1/2]

template<int NestingLevel, class Daughter, class T, class Trait>
void TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::clear ( )
inline

clear entire container

Definition at line 238 of file NestedContainer.h.

238 {
239 for( typename DaughterContainer::iterator it = m_daughters.begin() ; it != m_daughters.end(); ++it )
241 m_daughters.clear() ;
243 }
static void clear(Daughter &d, const ExpandedIdentifier &id)
clear container for given id

◆ clear() [2/2]

template<int NestingLevel, class Daughter, class T, class Trait>
void TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::clear ( const ExpandedIdentifier & id)
inline

clear only entries specified

Definition at line 246 of file NestedContainer.h.

246 {
247 if( NestingLevel == id.level() ) clear() ;
248 else {
249 unsigned int thisindex = id.index(NestingLevel+1) ;
250 if(thisindex<m_daughters.size())
252 }
253 }
void clear()
clear entire container

◆ crunch()

template<int NestingLevel, class Daughter, class T, class Trait>
void TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::crunch ( )
inline

reduce the footprint as much as possible by removing the extra space allocated by the vectors

Definition at line 292 of file NestedContainer.h.

292 {
293 // first the daughters
294 for( typename DaughterContainer::iterator it = m_daughters.begin() ; it != m_daughters.end(); ++it )
296 // now use, if anything is there
297 if( m_daughters.size()>0 ) {
298 // find the first daughter that is valid
299 size_t firstvaliddaughter(0);
300 bool allequal(true) ;
301 for(size_t idau=0; idau<m_daughters.size() && allequal; ++idau) {
303 if( allequal ) {
305 if( isvalid ) {
307 } else {
309 }
310 }
311 }
312 if(allequal) {
313 // set the default value to the value form the first daughter
315 if( firstvaliddaughter < m_daughters.size() )
317 clear() ; // this clears pointers in the daughters. would rather replace that with destructors.
320 } else if(m_daughters.size()<m_daughters.capacity()) {
322 newdaughters.reserve( m_daughters.size() ) ;
323 newdaughters.insert( newdaughters.end(), m_daughters.begin(), m_daughters.end() ) ;
325 }
326 }
327 }
std::vector< Daughter > DaughterContainer
typedef of container
static bool empty(Daughter &d)
empty daughter container
static bool isequal(const Daughter &lhs, const Daughter &rhs)
equality operator
static void crunch(Daughter &d)
compress daugther size

◆ daughters()

template<int NestingLevel, class Daughter, class T, class Trait>
const DaughterContainer & TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::daughters ( ) const
inline

return the vector of daughters

Definition at line 256 of file NestedContainer.h.

256{ return m_daughters ; }

◆ footprint()

template<int NestingLevel, class Daughter, class T, class Trait>
size_t TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::footprint ( ) const
inline

return the memory allocated by the container and its daughters

Definition at line 282 of file NestedContainer.h.

282 {
283 size_t total = Trait::footprint(m_default) + (m_daughters.capacity()-m_daughters.size())*sizeof(Daughter) ;
284 for( typename DaughterContainer::const_iterator it = m_daughters.begin() ; it != m_daughters.end(); ++it )
286 return total ;
287 }
static size_t footprint(const Daughter &d)
return allocated memory

◆ get() [1/3]

template<int NestingLevel, class Daughter, class T, class Trait>
const T & TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::get ( ) const
inline

get the default value

Definition at line 232 of file NestedContainer.h.

232{ return m_default ; }

◆ get() [2/3]

template<int NestingLevel, class Daughter, class T, class Trait>
const T & TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::get ( const ExpandedIdentifier & id) const
inline

get a value.

return the default value if no valid entry for id exists.

Definition at line 205 of file NestedContainer.h.

205 {
206 if( NestingLevel < id.level() ) {
207 unsigned int thisindex = id.index(NestingLevel+1) ;
208 if(thisindex<m_daughters.size()) {
210 // only return this value if it is valid. otherwise, return the default.
211 if( Trait::isvalid(rc) ) return rc ;
212 }
213 }
214 return m_default ;
215 }
static const T & get(const Daughter &d, const ExpandedIdentifier &id)
get value for given id

◆ get() [3/3]

template<int NestingLevel, class Daughter, class T, class Trait>
const T & TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::get ( const ExpandedIdentifier & id,
size_t & resolvelevel ) const
inline

Definition at line 217 of file NestedContainer.h.

218 {
219 if( NestingLevel < id.level() ) {
220 unsigned int thisindex = id.index(NestingLevel+1) ;
221 if(thisindex<m_daughters.size()) {
223 if( Trait::isvalid(rc) ) return rc ;
224 }
225 }
227 return m_default ;
228 }

◆ getall()

template<int NestingLevel, class Daughter, class T, class Trait>
void TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::getall ( FlatContainer & entries) const
inline

Definition at line 347 of file NestedContainer.h.

347 {
348 // add the daughters
349 for(unsigned int idau = 0; idau<m_daughters.size(); ++idau) {
351 // first get them
353 // now update the identifiers to have the dauhgter index set correctly
354 for(unsigned int j=0; j< dauentries.size(); ++j )
355 dauentries[j].first.index(NestingLevel+1) = idau ;
356 // and append
357 entries.insert(entries.end(),dauentries.begin(),dauentries.end()) ;
358 }
359 // add the default value
363 }
364 }
std::vector< std::pair< ExpandedIdentifier, const T * > > FlatContainer
fill vector with all entries in the container. needed to dump to Peter's flat file format
static void getall(const Daughter &d, std::vector< std::pair< ExpandedIdentifier, const T * > > &entries)
copy all object pointers into a vector of (id,pointer) pairs

◆ numObjects()

template<int NestingLevel, class Daughter, class T, class Trait>
size_t TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::numObjects ( ) const
inline

return the total number of valid calibration objects

Definition at line 260 of file NestedContainer.h.

260 {
261 size_t rc(0) ;
262 assert( std::distance(m_daughters.begin(),m_daughters.end())==(int)m_daughters.size()) ;
263 assert( m_daughters.size() < 1000 ) ;
264 for( typename DaughterContainer::const_iterator it = m_daughters.begin() ; it != m_daughters.end(); ++it )
266 if( Trait::isvalid(m_default) ) ++rc ;
267 return rc ;
268 }
static Double_t rc
static size_t numObjects(const Daughter &d)
total number of atomic objects in daugther

◆ operator==() [1/2]

template<int NestingLevel, class Daughter, class T, class Trait>
bool TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::operator== ( const NestedContainerBase< NestingLevel, Daughter, T, Trait > & rhs) const
inline

equality operator, used for compressing

Definition at line 272 of file NestedContainer.h.

272 {
273 return m_daughters.size()==0 && rhs.m_daughters.size()==0 && Trait::isequal(m_default,rhs.m_default) ;
274 }

◆ operator==() [2/2]

template<int NestingLevel, class Daughter, class T, class Trait>
bool TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::operator== ( const T & rhs) const
inline

another equality operator, used for compressing

Definition at line 277 of file NestedContainer.h.

277 {
278 return m_daughters.size()==0 && Trait::isequal(m_default,rhs) ;
279 }

◆ print()

template<int NestingLevel, class Daughter, class T, class Trait>
void TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::print ( ) const
inline

Definition at line 334 of file NestedContainer.h.

334 {
335 printindent() ;
337 std::cout << "level = " << id.name(NestingLevel) << " (" << NestingLevel << ")" << std::endl ;
338 for(unsigned int i=0; i< m_daughters.size(); ++i) {
339 printindent() ;
340 std::cout << "daughter " << i << std::endl ;
342 }
343 }
void printindent() const
some IO for debugging
static void print(const Daughter &d)
print daugther info

◆ printindent()

template<int NestingLevel, class Daughter, class T, class Trait>
void TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::printindent ( ) const
inline

some IO for debugging

Definition at line 330 of file NestedContainer.h.

330 {
331 for(int i=0; i<NestingLevel; ++i)
332 std::cout << '\t' ;
333 }

◆ set() [1/2]

template<int NestingLevel, class Daughter, class T, class Trait>
void TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::set ( const ExpandedIdentifier & id,
const T & t )
inline

set a value.

using 'level' in id we can specify if we want to set the default value.

Definition at line 191 of file NestedContainer.h.

191 {
192 if( NestingLevel == id.level() ) {
193 // set the default value
195 } else {
196 unsigned int thisindex = id.index(NestingLevel+1) ;
197 // expand daughter array if necessary
198 if(thisindex>=m_daughters.size())
201 }
202 }
static void set(Daughter &d, const ExpandedIdentifier &id, const T &t)
set value for given id

◆ set() [2/2]

template<int NestingLevel, class Daughter, class T, class Trait>
void TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::set ( const T & t)
inline

set the default value

Definition at line 235 of file NestedContainer.h.

Member Data Documentation

◆ m_daughters

template<int NestingLevel, class Daughter, class T, class Trait>
DaughterContainer TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::m_daughters
private

Container of Daughters.

Definition at line 156 of file NestedContainer.h.

◆ m_default

template<int NestingLevel, class Daughter, class T, class Trait>
T TRTCond::NestedContainerBase< NestingLevel, Daughter, T, Trait >::m_default
private

Type of atomic element.

Definition at line 157 of file NestedContainer.h.


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