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

CdbRooRoConfigElementR.rdl

Go to the documentation of this file.
00001 #ifndef CDBROOREADONLY_CONFIG_ELEMENT_R_RDL
00002 #define CDBROOREADONLY_CONFIG_ELEMENT_R_RDL
00003 
00004 // File and Version Information:
00005 //      $Id: CdbRooRoConfigElementR.rdl,v 1.2 2004/11/17 16:40:55 gapon Exp $
00006 
00007 #include "CdbBase/CdbTimeUtils.hh"
00008 
00009 #include "CdbRooReadonly/CdbRooRoTimeR.hh"
00010 
00011 #include <iostream>
00012 
00013 /// Objects of this class represent simple condition configuration elements
00014 /**
00015   * This is an embedded class.
00016   */
00017 class CdbRooRoConfigElementR {
00018 
00019 public:
00020 
00021   /// Normal & default constructor
00022   /**
00023     * The default constructor will put the element into the "NO ACCESS" state.
00024     * This state can be checked by calling the corresponding method defined below.
00025     *
00026     * @see CdbRooRoConfigElementR::accessIsAllowed( )
00027     */
00028     explicit CdbRooRoConfigElementR( const BdbTime& theRevisionId   = BdbTime::minusInfinity,
00029                                      UShort_t       thePartitionId  = 0,
00030                                      bool           useRevisionFlag = true ) :
00031         _revision   (theRevisionId),
00032         _partition  (thePartitionId),
00033         _useRevision(useRevisionFlag)
00034     { }
00035 
00036   /// The destructor
00037   /**
00038     * NOTE: The destructor is NOT virtual because this is an embedded
00039     *       class.
00040     */
00041     virtual ~CdbRooRoConfigElementR( ) { }
00042 
00043   /// The "equal" operator
00044   /**
00045     * This operator is required to compare objects of this class.
00046     */
00047     inline bool operator==( const CdbRooRoConfigElementR& theElement ) const
00048     {
00049         return ( revision   ( ) == theElement.revision   ( )) &&
00050                ( partition  ( ) == theElement.partition  ( )) &&
00051                ( useRevision( ) == theElement.useRevision( ));
00052     }
00053 
00054   /// The "not-equal" operator
00055   /**
00056     */
00057     inline bool operator!=( const CdbRooRoConfigElementR& theElement ) const
00058     {
00059         return ! operator==( theElement );
00060     }
00061 
00062   /// Check if the current element is not in the "NO ACCESS" state
00063 
00064     bool accessIsAllowed( ) const {
00065         return BdbTime::minusInfinity != revision( );
00066     }
00067 
00068     BdbTime  revision   ( ) const { return _revision.getBdbTime( ); }
00069     UShort_t partition  ( ) const { return _partition; }
00070     bool     useRevision( ) const { return _useRevision; }
00071 
00072 private:
00073 
00074     CdbRooRoTimeR  _revision;     // Revision ID
00075 
00076     UShort_t _partition;          // Partition ID
00077 
00078   // The following flag is indicating if specified revision is supposed
00079   // to be used for partitioned conditions rather than its (the partition's)
00080   // "modification time".
00081   //
00082   // NOTE: This flag does not make any sense for the non-partitioned
00083   //       conditions.
00084 
00085     Bool_t _useRevision;
00086 };
00087 
00088 inline
00089 std::ostream&
00090 operator<<( std::ostream&                 o,
00091             const CdbRooRoConfigElementR& theElement )
00092 {
00093     o << "REVISION: " << CdbTimeUtils::time2string( theElement.revision( ), true, true ) << ", "
00094       << "PARTITION: " << theElement.partition( ) << ", "
00095       << "USE REVISION: " << ( theElement.useRevision( ) ? "Yes" : "No" );
00096     return o;
00097 }
00098 
00099 #endif  // CDBROOREADONLY_CONFIG_ELEMENT_R_RDL

Generated on Mon Dec 5 18:22:10 2005 for CDB by doxygen1.3-rc3