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

CdbBdbSConfigElement.hh

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

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