CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

CondIter< DataT > Class Template Reference

#include <CondIter.h>

Inheritance diagram for CondIter< DataT >:
CondBasicIter

List of all members.

Public Member Functions

virtual void clear ()
 CondIter (bool cacheIt=false)
DataT const * next ()
void reset ()
void rewind ()
 ~CondIter ()

Protected Member Functions

virtual bool load (cond::DbSession &sess, std::string const &itoken)

Private Attributes

std::vector< cond::PayloadRef
< DataT > > 
cache
cond::PayloadRef< DataT > data
bool initialized
size_t n
bool useCache

Detailed Description

template<class DataT>
class CondIter< DataT >

Definition at line 13 of file CondIter.h.


Constructor & Destructor Documentation

template<class DataT>
CondIter< DataT >::CondIter ( bool  cacheIt = false) [inline]

Definition at line 35 of file CondIter.h.

: initialized(false), useCache(cacheIt),n(0){}
template<class DataT>
CondIter< DataT >::~CondIter ( ) [inline]

Definition at line 36 of file CondIter.h.

{}

Member Function Documentation

template<class DataT>
virtual void CondIter< DataT >::clear ( void  ) [inline, virtual]

Implements CondBasicIter.

Definition at line 43 of file CondIter.h.

                       {
    reset();
    cache.clear();
  }
template<class DataT>
virtual bool CondIter< DataT >::load ( cond::DbSession sess,
std::string const &  itoken 
) [inline, protected, virtual]

Implements CondBasicIter.

Definition at line 16 of file CondIter.h.

                                                                   {
    if (useCache)
      if (n>=cache.size()) {
        cache.resize(n+1); 
        return cache.back().load(sess,itoken);
      } else return true;
    else return data.load(sess,itoken);
  }
template<class DataT>
DataT const* CondIter< DataT >::next ( void  ) [inline]

Obtain the pointer to an object T. If it is the last T the method returns a null pointer.

Definition at line 52 of file CondIter.h.

                       {
    bool ok=false;
    if (!initialized) {
      n=0;
      ok =init();
      initialized=true;
    }
    else {
      ++n;
      ok = forward();
    }
    if (!ok) return 0;
    ok = make();
    if (!ok) return 0;
    return  useCache ?  &(*cache[n]) : &(*data); 

  }
template<class DataT>
void CondIter< DataT >::reset ( void  ) [inline]

Definition at line 39 of file CondIter.h.

Referenced by CondIter< T >::clear(), and CondIter< T >::rewind().

{ initialized=false; data.clear();}
template<class DataT>
void CondIter< DataT >::rewind ( ) [inline]

Definition at line 41 of file CondIter.h.

{ reset();}

Member Data Documentation

template<class DataT>
std::vector<cond::PayloadRef<DataT> > CondIter< DataT >::cache [private]

Definition at line 29 of file CondIter.h.

Referenced by CondIter< T >::clear(), CondIter< T >::load(), and CondIter< T >::next().

template<class DataT>
cond::PayloadRef<DataT> CondIter< DataT >::data [private]

Definition at line 28 of file CondIter.h.

Referenced by CondIter< T >::load(), CondIter< T >::next(), and CondIter< T >::reset().

template<class DataT>
bool CondIter< DataT >::initialized [private]

Definition at line 26 of file CondIter.h.

Referenced by CondIter< T >::next(), and CondIter< T >::reset().

template<class DataT>
size_t CondIter< DataT >::n [private]

Definition at line 30 of file CondIter.h.

Referenced by CondIter< T >::load(), and CondIter< T >::next().

template<class DataT>
bool CondIter< DataT >::useCache [private]

Definition at line 27 of file CondIter.h.

Referenced by CondIter< T >::load(), and CondIter< T >::next().