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

Protected Member Functions

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

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) { }
This class is a a vector of DataLink for objects of type DC It uses an internal chain to keep track o...

◆ ~DataLinkVector()

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

Default destructor.

Definition at line 412 of file DataLinkVector.h.

413{
414 this->cleanup();
415}
virtual void cleanup()
cleans up the DataLinkVector goes trough all chained entries and call clear() method of DataLink and ...

Member Function Documentation

◆ begin()

template<class DC>
DataLinkVector< DC >::iterator DataLinkVector< DC >::begin ( ) const

return iterator on first entry

Definition at line 429 of file DataLinkVector.h.

430{ return iterator( this, m_vect.begin() ); }
class iterator - iterator over elements in DataLinkVector which manages the Entry objects
EntryVector m_vect

◆ 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());
510 m_last->setPreviousEntry(e);
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}
class Entry is a link in a chained list, used for efficient cleanup of vectors.

◆ end()

template<class DC>
DataLinkVector< DC >::iterator DataLinkVector< DC >::end ( ) const

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));}
iterator end() const
return iterator on after last entry

◆ 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}
void chainEntry(Entry *e) const
add pointed entry in chain of modified entries

◆ 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 ( ) const

access to size of vector

Definition at line 496 of file DataLinkVector.h.

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

◆ 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: