CMS 3D CMS Logo

CondIter< T > Class Template Reference

#include <CondCore/Utilities/interface/CondIter.h>

List of all members.

Public Member Functions

 CondIter ()
void create (const std::string &NameDB, const std::string &File, const std::string &User="", const std::string &Pass="", const std::string &nameBlob="")
 tell Iter to point to a database.
void free ()
 free the object T *Reference from the class CondIter: object T *Reference isn't deleted when the class CondIter is deleted.
unsigned int getMax ()
 It returns the maximum of the range of interest of the Iterator of the IOVs.
unsigned int getMin ()
 It returns the minimum of the range of interest of the Iterator of the IOVs.
void getRange (unsigned int *, unsigned int *)
 It enables to retrieve the minimum and the maximum of the range of interest of the Iterator of the IOVs.
unsigned int getStartTime ()
 get the SINCE TIME of the Interval of Validity
unsigned int getStopTime ()
 get the TILL TIME of the Interval of Validity
unsigned int getTime ()
 get the mean time of the Iterval of Validity
void jump ()
 It passes to the following IOV without returning anything.
T const * next (int test=1)
 Obtain the pointer to an object T.
void setMax (int max)
void setMax (unsigned int max)
 Set the maximum of the range of interest of the Iterator of the IOVs: thus when you call the method next() you get up to max.
void setMin (int min)
void setMin (unsigned int min)
 Set the minimum of the range of interest of the Iterator of the IOVs: thus when you call the method next() you get from min.
void setRange (int min, int max)
void setRange (unsigned int min, unsigned int max)
 Set the range of interest of the Iterator of the IOVs: thus when you call the method next() you get from min to max.
cond::TypedRef< T > const * whatRef ()
 I need this method in order to manage the memory leak.
 ~CondIter ()

Public Attributes

bool NumberOfTimes

Private Attributes

CondBasicIter bIter
cond::TypedRef< T > * ref
const T * Reference

Friends

class CondCachedIter


Detailed Description

template<class T>
class CondIter< T >

Definition at line 31 of file CondIter.h.


Constructor & Destructor Documentation

template<class T>
CondIter< T >::CondIter (  )  [inline]

Definition at line 153 of file CondIter.h.

References CondIter< T >::ref, and CondIter< T >::Reference.

00153                                                   {
00154 
00155               Reference = 0;
00156               ref = 0;  
00157           }

template<class T>
CondIter< T >::~CondIter (  )  [inline]

Definition at line 160 of file CondIter.h.

References CondIter< T >::ref.

00160                                                    {
00161 
00162               if (ref) delete ref; 
00163           }


Member Function Documentation

template<class T>
void CondIter< T >::create ( const std::string &  NameDB,
const std::string &  File,
const std::string &  User = "",
const std::string &  Pass = "",
const std::string &  nameBlob = "" 
) [inline]

tell Iter to point to a database.

After this call CondIter can be used.

It needs:

Definition at line 166 of file CondIter.h.

References CondIter< T >::bIter, CondBasicIter::create(), CondIter< T >::NumberOfTimes, CondIter< T >::ref, and CondIter< T >::Reference.

00166                                                                                                                                                                              {
00167 
00168               bIter.create(NameDB,File,User,Pass,nameBlob);
00169               NumberOfTimes = true;
00170               ref = 0; 
00171               Reference = 0;
00172 
00173           }

template<class T>
void CondIter< T >::free (  )  [inline]

free the object T *Reference from the class CondIter: object T *Reference isn't deleted when the class CondIter is deleted.

Definition at line 294 of file CondIter.h.

References CondIter< T >::ref, and CondIter< T >::Reference.

00294                                                    {
00295               Reference = 0;
00296               ref = 0;
00297           }

template<class T>
unsigned int CondIter< T >::getMax (  )  [inline]

It returns the maximum of the range of interest of the Iterator of the IOVs.

Definition at line 342 of file CondIter.h.

References CondIter< T >::bIter, and CondBasicIter::getMax().

00342 {return bIter.getMax();}

template<class T>
unsigned int CondIter< T >::getMin (  )  [inline]

It returns the minimum of the range of interest of the Iterator of the IOVs.

Definition at line 340 of file CondIter.h.

References CondIter< T >::bIter, and CondBasicIter::getMin().

00340 {return bIter.getMin();}

template<class T>
void CondIter< T >::getRange ( unsigned int Min_out,
unsigned int Max_out 
) [inline]

It enables to retrieve the minimum and the maximum of the range of interest of the Iterator of the IOVs.

Definition at line 344 of file CondIter.h.

References CondIter< T >::bIter, CondBasicIter::getMax(), and CondBasicIter::getMin().

00344                                                                                                     {
00345               *Min_out = bIter.getMin();
00346               *Max_out = bIter.getMax();
00347           }

template<class T>
unsigned int CondIter< T >::getStartTime (  )  [inline]

get the SINCE TIME of the Interval of Validity

Definition at line 352 of file CondIter.h.

References CondIter< T >::bIter, and CondBasicIter::getStartTime().

00352 {return bIter.getStartTime();}

template<class T>
unsigned int CondIter< T >::getStopTime (  )  [inline]

get the TILL TIME of the Interval of Validity

Definition at line 354 of file CondIter.h.

References CondIter< T >::bIter, and CondBasicIter::getStopTime().

00354 {return bIter.getStopTime();}

template<class T>
unsigned int CondIter< T >::getTime ( void   )  [inline]

get the mean time of the Iterval of Validity

Definition at line 350 of file CondIter.h.

References CondIter< T >::bIter, and CondBasicIter::getTime().

00350 {return bIter.getTime();}

template<class T>
void CondIter< T >::jump (  )  [inline]

It passes to the following IOV without returning anything.

Definition at line 275 of file CondIter.h.

References CondIter< T >::bIter, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), CondBasicIter::getMin(), i, CondBasicIter::ioviterator, and CondIter< T >::NumberOfTimes.

00275                                                     {
00276     
00277               if (NumberOfTimes){
00278                   unsigned int minTemp = bIter.getMin(); 
00279           
00280                   for (unsigned int i=0; i< minTemp; i++){//iter_Min <= run since at least I have one IOV for each run 
00281     //control if the min is too high
00282                       if (!((bIter.ioviterator)->next())) {
00283                           std::cout << "No data. Minimum too high." << std::endl;
00284     //return a pointer to NULL
00285                       }
00286                       if (((bIter.ioviterator)->validity().second)>=minTemp) i = minTemp; //Minimum reached 
00287                   }
00288                   NumberOfTimes = false;
00289               }
00290               else (bIter.ioviterator)->next();
00291           }

template<class T>
T const * CondIter< T >::next ( int  test = 1  )  [inline]

Obtain the pointer to an object T.

If it is the last T the method returns a null pointer. As default the next() delete the previous object. Set "test = 0" in order to store the datum.

Definition at line 180 of file CondIter.h.

References CondIter< T >::bIter, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), CondBasicIter::getMax(), CondBasicIter::getMin(), CondBasicIter::getStartTime(), CondBasicIter::getStopTime(), i, int, CondBasicIter::ioviterator, CondBasicIter::iter_Max, CondBasicIter::iter_Min, CondIter< T >::NumberOfTimes, CondBasicIter::payloadContainer, CondBasicIter::pooldb, CondIter< T >::ref, CondIter< T >::Reference, CondBasicIter::setStartTime(), CondBasicIter::setStopTime(), CondBasicIter::setTime(), and pyDBSRunClass::temp.

00180                                                                  {
00181              
00182               if ((bIter.iter_Min)==0 && (bIter.iter_Max)==0){
00183 // method next without range
00184 
00185                   if( (bIter.ioviterator)->next() ){
00186        
00187                       std::cout<<"PayloadContainerName "<<bIter.payloadContainer<<"\n";
00188                       std::cout<<"since \t till \t payloadToken"<<std::endl;
00189                       std::cout<< (bIter.ioviterator)->validity().first<<" \t "<< (bIter.ioviterator)->validity().second<<" \t "<<(bIter.ioviterator)->payloadToken()<<std::endl; 
00190                       if (test && ref) {
00191 //                 delete Reference;
00192                           delete ref;
00193                       }   
00194                       ref = new cond::TypedRef<T> (*(bIter.pooldb),(bIter.ioviterator)->payloadToken());
00195                       Reference = (const T*) ref->ptr();
00196                       bIter.setStartTime((bIter.ioviterator)->validity().first);
00197                       bIter.setStopTime((bIter.ioviterator)->validity().second);
00198     
00199                       long long int temp = (long long int) (( bIter.getStartTime()+ bIter.getStopTime()) / 2.);
00200                       if (temp<0) temp = - temp;
00201                       bIter.setTime((unsigned int) temp);
00202                       return Reference;
00203                   }
00204                   else {
00205                       std::cout << "No more data ! " << std::endl;
00206                       Reference = 0;
00207                       ref = 0;
00208                       return Reference;
00209     //return a pointer to NULL
00210                   }
00211               }
00212               else{    
00213 //test to see if it is the first time
00214                   if (NumberOfTimes){
00215                       unsigned int minTemp = bIter.getMin(); 
00216                       for (unsigned int i=0; i< minTemp; i++){//iter_Min <= run since at least I have one IOV for each run  
00217     //control if the min is too high
00218                           if (!((bIter.ioviterator)->next())) {
00219                               std::cout << "No data. Minimum too high." << std::endl;
00220                               Reference = 0;
00221                               ref = 0;
00222                               return Reference;
00223     //return a pointer to NULL
00224                           }
00225                           if (((bIter.ioviterator)->validity().second)>=minTemp) i = minTemp; //Minimum reached 
00226                       }
00227                       NumberOfTimes = false;
00228                   }
00229                   if( (bIter.ioviterator)->next() ){
00230                       if (((bIter.ioviterator)->validity().first)>=(bIter.getMax())){
00231                           std::cout << "No more data in the range" << std::endl;
00232                           Reference = 0;
00233                           ref = 0;
00234                           return Reference;
00235         //return a pointer to NULL
00236                       }
00237                       else {
00238                           std::cout<<"PayloadContainerName "<<bIter.payloadContainer<<"\n";
00239                           std::cout<<"since \t till \t payloadToken"<<std::endl;
00240                           std::cout<< (bIter.ioviterator)->validity().first<<" \t "<< (bIter.ioviterator)->validity().second<<" \t "<<(bIter.ioviterator)->payloadToken()<<std::endl; 
00241 
00242     
00243                           if (test && ref) {
00244 //                     delete Reference;
00245                               delete ref;
00246                           }   //test to choose if mantain the object or not
00247                           ref = new cond::TypedRef<T> (*(bIter.pooldb),(bIter.ioviterator)->payloadToken());
00248                           Reference = (const T*) ref->ptr();
00249                           bIter.setStartTime((bIter.ioviterator)->validity().first);
00250                           bIter.setStopTime((bIter.ioviterator)->validity().second);
00251     
00252                           long long int temp = (long long int) (( bIter.getStartTime()+ bIter.getStopTime()) / 2.);
00253                           if (temp<0) temp = - temp;
00254                           bIter.setTime((unsigned int) temp);   
00255                           return Reference;
00256                       }
00257                   }
00258       
00259                   else {
00260                       std::cout << "No more data ! " << std::endl;
00261                       Reference = 0;
00262                       ref = 0;
00263                       return Reference;
00264     //return a pointer to NULL
00265                   }
00266               }
00267 
00268           }

template<class T>
void CondIter< T >::setMax ( int  max  )  [inline]

Definition at line 335 of file CondIter.h.

References CondIter< T >::bIter, and CondBasicIter::setMax().

00335                                                             {
00336               bIter.setMax(max);
00337           }

template<class T>
void CondIter< T >::setMax ( unsigned int  max  )  [inline]

Set the maximum of the range of interest of the Iterator of the IOVs: thus when you call the method next() you get up to max.

Definition at line 323 of file CondIter.h.

References CondIter< T >::bIter, and CondBasicIter::setMax().

00323                                                                      {
00324               bIter.setMax(max);
00325           }

template<class T>
void CondIter< T >::setMin ( int  min  )  [inline]

Definition at line 331 of file CondIter.h.

References CondIter< T >::bIter, and CondBasicIter::setMin().

00331                                                             {
00332               bIter.setMin(min);
00333           }

template<class T>
void CondIter< T >::setMin ( unsigned int  min  )  [inline]

Set the minimum of the range of interest of the Iterator of the IOVs: thus when you call the method next() you get from min.

Definition at line 319 of file CondIter.h.

References CondIter< T >::bIter, and CondBasicIter::setMin().

00319                                                                      {
00320               bIter.setMin(min);
00321           }

template<class T>
void CondIter< T >::setRange ( int  min,
int  max 
) [inline]

Definition at line 327 of file CondIter.h.

References CondIter< T >::bIter, and CondBasicIter::setRange().

00327                                                                       {
00328               bIter.setRange(min,max);
00329           }

template<class T>
void CondIter< T >::setRange ( unsigned int  min,
unsigned int  max 
) [inline]

Set the range of interest of the Iterator of the IOVs: thus when you call the method next() you get from min to max.

Definition at line 315 of file CondIter.h.

References CondIter< T >::bIter, and CondBasicIter::setRange().

00315                                                                                         {
00316               bIter.setRange(min,max);
00317           }

template<class T>
cond::TypedRef< T > const * CondIter< T >::whatRef (  )  [inline]

I need this method in order to manage the memory leak.

If I use method "next(0)" I mantain the Ref which may cause a memory leak if I don't delete it. In order to delete it I need its pointer: the method "whatRef" gives me the pointer.

Definition at line 302 of file CondIter.h.

References CondIter< T >::ref.

00302                                                                           {
00303 
00304               return ref;
00305     
00306           }


Friends And Related Function Documentation

template<class T>
friend class CondCachedIter [friend]

Definition at line 48 of file CondIter.h.


Member Data Documentation

template<class T>
CondBasicIter CondIter< T >::bIter [private]

Definition at line 37 of file CondIter.h.

Referenced by CondIter< T >::create(), CondIter< T >::getMax(), CondIter< T >::getMin(), CondIter< T >::getRange(), CondIter< T >::getStartTime(), CondIter< T >::getStopTime(), CondIter< T >::getTime(), CondIter< T >::jump(), CondIter< T >::next(), CondIter< T >::setMax(), CondIter< T >::setMin(), and CondIter< T >::setRange().

template<class T>
bool CondIter< T >::NumberOfTimes

Definition at line 41 of file CondIter.h.

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

template<class T>
cond::TypedRef<T>* CondIter< T >::ref [private]

Definition at line 36 of file CondIter.h.

Referenced by CondIter< T >::CondIter(), CondIter< T >::create(), CondIter< T >::free(), CondIter< T >::next(), CondIter< T >::whatRef(), and CondIter< T >::~CondIter().

template<class T>
const T* CondIter< T >::Reference [private]

Definition at line 35 of file CondIter.h.

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


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:16:38 2009 for CMSSW by  doxygen 1.5.4