ATLAS Offline Software
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
DataLinkVector< DC > Class Template Reference

This class is a a vector of DataLink for objects of type DC It uses an internal chain to keep track of modified entries. A call to cleanup is required after processing an event or prior to process a new event. cleanup will call the clear() method of all the touched DataLink instances. The template expects the DataLink to export the DigitCollection class type (DC) and the DigitCollection identifier type. More...

#include <DataLinkVector.h>

Inheritance diagram for DataLinkVector< DC >:
Collaboration diagram for DataLinkVector< DC >:

Classes

class  DataHolder
 class DataHolder is a simple class which holds a pointer to an object of type DC. More...
 
class  Entry
 class Entry is a link in a chained list, used for efficient cleanup of vectors. More...
 
class  iterator
 class iterator - iterator over elements in DataLinkVector which manages the Entry objects More...
 

Public Types

typedef DC value_type
 
typedef DC * pointer
 
typedef const DC * const_pointer
 
typedef DC & reference
 
typedef const DC & const_reference
 
typedef DataHolder DataLinkT
 
typedef DataLinkVector< DC > MyType
 
typedef std::vector< EntryEntryVector
 
typedef EntryVector::iterator EntryVectorIt
 

Public Member Functions

 DataLinkVector ()
 Default constructor. More...
 
 ~DataLinkVector ()
 Default destructor. More...
 
void init (unsigned int nbr)
 initialize vector with nbr DataLinks More...
 
iterator begin () const
 return iterator on first entry More...
 
iterator end () const
 return iterator on after last entry More...
 
iterator find (IdentifierHash id) const
 return iterator on the found entry or end() if out of range More...
 
bool setObjectOwnership (IdentifierHash idhash, bool flag)
 set object ownership More...
 
DataLinkToperator[] (int id)
 return reference on DataLink BEWARE: Doesn't check for boundary limits ! More...
 
virtual void cleanup ()
 cleans up the DataLinkVector goes trough all chained entries and call clear() method of DataLink and clear chain of course. More...
 
int size () const
 access to size of vector More...
 

Protected Member Functions

void chainEntry (Entry *e) const
 add pointed entry in chain of modified entries More...
 

Protected Attributes

EntryVector m_vect
 
Entrym_last
 

Friends

class iterator
 

Detailed Description

template<class DC>
class DataLinkVector< DC >

This class is a a vector of DataLink for objects of type DC It uses an internal chain to keep track of modified entries. A call to cleanup is required after processing an event or prior to process a new event. cleanup will call the clear() method of all the touched DataLink instances. The template expects the DataLink to export the DigitCollection class type (DC) and the DigitCollection identifier type.

Definition at line 33 of file DataLinkVector.h.

Member Typedef Documentation

◆ const_pointer

template<class DC >
typedef const DC* DataLinkVector< DC >::const_pointer

Definition at line 39 of file DataLinkVector.h.

◆ const_reference

template<class DC >
typedef const DC& DataLinkVector< DC >::const_reference

Definition at line 41 of file DataLinkVector.h.

◆ DataLinkT

template<class DC >
typedef DataHolder DataLinkVector< DC >::DataLinkT

Definition at line 80 of file DataLinkVector.h.

◆ EntryVector

template<class DC >
typedef std::vector<Entry> DataLinkVector< DC >::EntryVector

Definition at line 121 of file DataLinkVector.h.

◆ EntryVectorIt

template<class DC >
typedef EntryVector::iterator DataLinkVector< DC >::EntryVectorIt

Definition at line 122 of file DataLinkVector.h.

◆ MyType

template<class DC >
typedef DataLinkVector<DC> DataLinkVector< DC >::MyType

Definition at line 81 of file DataLinkVector.h.

◆ pointer

template<class DC >
typedef DC* DataLinkVector< DC >::pointer

Definition at line 38 of file DataLinkVector.h.

◆ reference

template<class DC >
typedef DC& DataLinkVector< DC >::reference

Definition at line 40 of file DataLinkVector.h.

◆ value_type

template<class DC >
typedef DC DataLinkVector< DC >::value_type

Definition at line 37 of file DataLinkVector.h.

Constructor & Destructor Documentation

◆ DataLinkVector()

template<class DC >
DataLinkVector< DC >::DataLinkVector

Default constructor.

Definition at line 407 of file DataLinkVector.h.

408  : m_last(NULL) { }

◆ ~DataLinkVector()

template<class DC >
DataLinkVector< DC >::~DataLinkVector

Default destructor.

Definition at line 412 of file DataLinkVector.h.

413 {
414  this->cleanup();
415 }

Member Function Documentation

◆ begin()

template<class DC >
DataLinkVector< DC >::iterator DataLinkVector< DC >::begin

return iterator on first entry

Definition at line 429 of file DataLinkVector.h.

430 { return iterator( this, m_vect.begin() ); }

◆ chainEntry()

template<class DC >
void DataLinkVector< DC >::chainEntry ( Entry e) const
protected

add pointed entry in chain of modified entries

Definition at line 502 of file DataLinkVector.h.

503 {
504  if( m_last == NULL ) {
505  e->setPreviousEntry(e);
506  m_last = e;
507  }
508  else {
509  e->setPreviousEntry(m_last->previousEntry());
511  }
512 }

◆ cleanup()

template<class DC >
void DataLinkVector< DC >::cleanup
virtual

cleans up the DataLinkVector goes trough all chained entries and call clear() method of DataLink and clear chain of course.

Definition at line 474 of file DataLinkVector.h.

475 {
476  Entry *e;
477  // assign last to e and check if it is not NULL
478  if( (e = m_last) )
479  {
480  // for chained entries
481  do {
482  Entry * tmp = e->previousEntry();
483  e->setPreviousEntry(NULL); // clear chain pointer
484  if (e->ownObject()) // delete object
485  delete (e->dataLink()).getDataPtr();
486  e->dataLink().reset(); // reset keeps it in identified state.
487  e->setOwnObject(false); // doesn't own object
488  e = tmp; // go to next entry
489  } while( e != m_last ); // until we end where we started
490  m_last = NULL; // clear chain hook
491  }
492 }

◆ end()

template<class DC >
DataLinkVector< DC >::iterator DataLinkVector< DC >::end

return iterator on after last entry

Definition at line 435 of file DataLinkVector.h.

436 { return iterator( this, m_vect.end()); }

◆ find()

template<class DC >
DataLinkVector< DC >::iterator DataLinkVector< DC >::find ( IdentifierHash  id) const

return iterator on the found entry or end() if out of range

Definition at line 441 of file DataLinkVector.h.

442 { return ( (id >= m_vect.size() )
443  ?end():iterator(this,m_vect.begin()+id));}

◆ init()

template<class DC >
void DataLinkVector< DC >::init ( unsigned int  nbr)

initialize vector with nbr DataLinks

Definition at line 420 of file DataLinkVector.h.

421 {
422  // fill in vector of Entry
423  m_vect.resize(nbr);
424 }

◆ operator[]()

template<class DC >
DataLinkVector< DC >::DataLinkT & DataLinkVector< DC >::operator[] ( int  id)

return reference on DataLink BEWARE: Doesn't check for boundary limits !

Definition at line 461 of file DataLinkVector.h.

462 {
463  Entry* e = &(m_vect[id]);
464  if( !e->previousEntry() )
465  chainEntry( e );
466  return e->dataLink();
467 }

◆ setObjectOwnership()

template<class DC >
bool DataLinkVector< DC >::setObjectOwnership ( IdentifierHash  idhash,
bool  flag 
)

set object ownership

Definition at line 448 of file DataLinkVector.h.

449 {
450  if ( idhash >= m_vect.size() )
451  return false;
452  Entry& e = *(m_vect.begin()+idhash);
453  e.setOwnObject(flag);
454  return true;
455 }

◆ size()

template<class DC >
int DataLinkVector< DC >::size

access to size of vector

Definition at line 496 of file DataLinkVector.h.

496  {
497  return m_vect.size();
498 }

Friends And Related Function Documentation

◆ iterator

template<class DC >
friend class iterator
friend

Definition at line 175 of file DataLinkVector.h.

Member Data Documentation

◆ m_last

template<class DC >
Entry* DataLinkVector< DC >::m_last
mutableprotected

Definition at line 217 of file DataLinkVector.h.

◆ m_vect

template<class DC >
EntryVector DataLinkVector< DC >::m_vect
mutableprotected

Definition at line 216 of file DataLinkVector.h.


The documentation for this class was generated from the following file:
DataLinkVector::Entry::previousEntry
Entry * previousEntry()
access to next entry
Definition: DataLinkVector.h:290
DataLinkVector::chainEntry
void chainEntry(Entry *e) const
add pointed entry in chain of modified entries
Definition: DataLinkVector.h:502
DataLinkVector::m_last
Entry * m_last
Definition: DataLinkVector.h:217
DataLinkVector::Entry::setPreviousEntry
void setPreviousEntry(Entry *entry)
set previous entry
Definition: DataLinkVector.h:311
DataLinkVector::m_vect
EntryVector m_vect
Definition: DataLinkVector.h:216
master.flag
bool flag
Definition: master.py:29
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
DataLinkVector::cleanup
virtual void cleanup()
cleans up the DataLinkVector goes trough all chained entries and call clear() method of DataLink and ...
Definition: DataLinkVector.h:474
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
DataLinkVector::end
iterator end() const
return iterator on after last entry
Definition: DataLinkVector.h:435
DataLinkVector::iterator
friend class iterator
Definition: DataLinkVector.h:175