Bdb packages | Design docs | Source docs | Guidelines | Recent releases

Search | Site Map .

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/CdbBdbShared/CdbBdbSTimeLineInterval.hh

Go to the documentation of this file.
00001 #ifndef CDBBDBSHARED_TIMELINE_INTERVAL_HH
00002 #define CDBBDBSHARED_TIMELINE_INTERVAL_HH
00003 
00004 //-----------------------------------------------------------------------------
00005 //
00006 // File and Version Information:
00007 //      $Id: CdbBdbSTimeLineInterval.hh,v 1.3 2002/05/09 20:49:33 gapon Exp $
00008 //
00009 // Description:
00010 //      Class CdbBdbSTimeLineInterval. Objects of this embedded class represent
00011 //      intervals in the "TimeLine" data structure.
00012 //
00013 //      This is a template class, whose only template parameter lets to specify
00014 //      the actual contents (payload) of the interval.
00015 //
00016 //      The template parameter "V" is expected to provide the following public
00017 //      interface:
00018 //
00019 //      - default constructor
00020 //      - copy constructor
00021 //      - non-virtual destructor
00022 //      - assignment operator
00023 //  
00024 // Environment:
00025 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00026 //
00027 // Author List:
00028 //      Igor A. Gaponenko               Original author
00029 //
00030 // Copyright Information:
00031 //      Copyright (C) 2002              Lawrence Berkeley Laboratory
00032 //
00033 //-----------------------------------------------------------------------------
00034 
00035 //--------------------
00036 // Database Headers --
00037 //--------------------
00038 
00039 #include "BdbUtil/Bdb.hh"
00040 
00041 //-------------------------------
00042 // Collaborating Class Headers --
00043 //-------------------------------
00044 
00045 #include "CdbBase/CdbCommon.hh"
00046 
00047 #include "BdbTime/BdbTime.hh"
00048 
00049 //---------------
00050 // C++ Headers --
00051 //---------------
00052 
00053 #include <iostream.h>
00054 
00055 /// Objects of this class represent "TimeLine" intervals
00056 /**
00057   * This is an embedded class, whose interface 
00058   */
00059 template< class V >
00060 class CdbBdbSTimeLineInterval {
00061 
00062 public:
00063 
00064   /// Normal & also default constructor
00065   /**
00066     */
00067     explicit CdbBdbSTimeLineInterval( const BdbTime& theBegin = BdbTime::minusInfinity,
00068                                       const BdbTime& theEnd   = BdbTime::minusInfinity ) :
00069         begin(theBegin),
00070         end  (theEnd)
00071     { }
00072 
00073   /// Normal constructor requering non default value
00074   /**
00075     */
00076     explicit CdbBdbSTimeLineInterval( const V&       theValue,
00077                                       const BdbTime& theBegin = BdbTime::minusInfinity,
00078                                       const BdbTime& theEnd   = BdbTime::minusInfinity ) :
00079         value(theValue),
00080         begin(theBegin),
00081         end  (theEnd)
00082     { }
00083 
00084   /// Copy constructor
00085   /**
00086     */
00087     CdbBdbSTimeLineInterval( const CdbBdbSTimeLineInterval<V>& theInterval ) :
00088         value(theInterval.value),
00089         begin(theInterval.begin),
00090         end  (theInterval.end)
00091     { }
00092 
00093   /// The destructor
00094   /**
00095     * NOTE: The destructor is NOT virtual because this is an embedded
00096     *       class.
00097     */
00098     ~CdbBdbSTimeLineInterval( ) { }
00099 
00100   /// The assignment operator
00101   /**
00102     */
00103     CdbBdbSTimeLineInterval& operator=( const CdbBdbSTimeLineInterval<V>& theInterval )
00104     {
00105         if( this != &theInterval ) {
00106             value = theInterval.value;
00107             begin = theInterval.begin;
00108             end   = theInterval.end;
00109         }
00110         return *this;
00111     }
00112 
00113 public:
00114 
00115   // The actual payload of the interval
00116 
00117     V value;
00118 
00119   // The meta-data information:
00120 
00121     BdbTime begin;      // Begin of the "validity" period
00122     BdbTime end;        // End   of the "validity" period
00123 };
00124 
00125 template< class V >
00126 inline
00127 ostream&
00128 operator<<( ostream&                          o,
00129             const CdbBdbSTimeLineInterval<V>& theInterval )
00130 {
00131     o << "[ " << theInterval.begin.getGmtSec( ) << "." << theInterval.begin.getGmtNsec( ) << " , "
00132       <<         theInterval.end.getGmtSec( )   << "." << theInterval.end.getGmtNsec( )   << " ) "
00133       << theInterval.value << endl;
00134     return o;
00135 }
00136 
00137 #endif  // CDBBDBSHARED_TIMELINE_INTERVAL_HH

 


BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us

Page Owner: Jacek Becla
Last Update: October 04, 2002