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  

/CdbBase/CdbId.hh

Go to the documentation of this file.
00001 #ifndef CDB_ID_HH
00002 #define CDB_ID_HH
00003 
00004 //-----------------------------------------------------------------------------
00005 //
00006 // File and Version Information:
00007 //      $Id: CdbId.hh,v 1.3 2002/07/17 00:44:20 gapon Exp $
00008 //
00009 // Description:
00010 //      Class CdbId. This is "extended" object identifier. It defines
00011 //      an address of some entiry in the distributed database as:
00012 //
00013 //          16-bit "origin" identifier
00014 //          16-bit "local" object's id in the scope of an origin
00015 //
00016 // Environment:
00017 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00018 //
00019 // Author List:
00020 //      Igor A. Gaponenko               Original author
00021 //
00022 // Copyright Information:
00023 //      Copyright (C) 2002              Lawrence Berkeley Laboratory
00024 //
00025 //-----------------------------------------------------------------------------
00026 
00027 //-------------------------------
00028 // Collaborating Class Headers --
00029 //-------------------------------
00030 
00031 #include "CdbBase/CdbCommon.hh"
00032 
00033 //---------------
00034 // C++ Headers --
00035 //---------------
00036 
00037 #include <iostream.h>
00038 
00039 /// Object of this class represent "extended" identifier for Condition/DB objects
00040 /**
00041   * More info...
00042   */
00043 class CdbId {
00044 
00045 public:
00046 
00047   /// Normal & also default constructor
00048   /**
00049     */
00050     CdbId( unsigned short theOriginId = 0,
00051            unsigned short theLocalId  = 0 ) :
00052         origin(theOriginId),
00053         local(theLocalId)
00054     { }
00055 
00056   /// Copy constructor
00057   /**
00058     */
00059     CdbId( const CdbId& theId )
00060     {
00061         origin = theId.origin;
00062         local  = theId.local;
00063     }
00064 
00065   /// The destructor
00066   /**
00067     * NOTE: The destructor is NOT virtual because this is an embedded
00068     *       class.
00069     */
00070     ~CdbId( ) { }
00071 
00072   /// The assignment operator
00073   /**
00074     */
00075     CdbId& operator=( const CdbId& theId )
00076     {
00077         if( this != &theId ) {
00078             origin = theId.origin;
00079             local  = theId.local;
00080         }
00081         return *this;
00082     }
00083 
00084   /// The "equal" operator
00085   /**
00086     * This operator is required to insert objects of this class
00087     * into a B-tree.
00088     */
00089     bool operator==( const CdbId& theId ) const
00090     {
00091         return ( origin == theId.origin ) && ( local == theId.local );
00092     }
00093 
00094   /// The "not-equal" operator
00095   /**
00096     */
00097     bool operator!=( const CdbId& theId ) const
00098     {
00099         return ! operator==( theId );
00100     }
00101 
00102   /// The "less" operator
00103   /**
00104     * This operator is required to insert objects of this class
00105     * into a B-tree.
00106     */
00107     bool operator<( const CdbId& theId ) const
00108     {
00109         return ( origin < theId.origin ) || (( origin == theId.origin ) && ( local < theId.local ));
00110     }
00111 
00112 public:
00113 
00114     unsigned short origin;  // The identifier of an "origin"
00115     unsigned short local;   // The local identifier of an object in the scope of an origin
00116 };
00117 
00118 inline
00119 ostream&
00120 operator<<( ostream&     o,
00121             const CdbId& theId )
00122 {
00123     o << theId.origin << "::" << theId.local;
00124     return o;
00125 }
00126 
00127 #endif  // CDB_ID_HH

 


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

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