00001 #ifndef CDBBDBSHARED_COLLECTION_BTE_HH 00002 #define CDBBDBSHARED_COLLECTION_BTE_HH 00003 00004 // File and Version Information: 00005 // $Id: CdbBdbSCollectionBte.hh,v 1.3 2004/08/06 05:54:24 bartoldu Exp $ 00006 00007 #include "BdbUtil/Bdb.hh" 00008 00009 #include "CdbBase/CdbCommon.hh" 00010 00011 #include "CdbBdbShared/CdbBdbSCollectionElementP.hh" 00012 00013 /// Objects of this class represent entries in the corresponding B-tree 00014 /** 00015 * Objects of this embedded class represent simple pairs of the "key-value" 00016 * entries in a B-tree, which is meant to sort CollectionElement-s. 00017 */ 00018 class CdbBdbSCollectionBte { 00019 00020 public: 00021 00022 // Default and normal constructors 00023 00024 CdbBdbSCollectionBte( ) 00025 { } 00026 00027 CdbBdbSCollectionBte( d_UShort theKey ) : 00028 key(theKey) 00029 { } 00030 00031 CdbBdbSCollectionBte( d_UShort theKey, 00032 const BdbRef(CdbBdbSCollectionElementP)& theValue ) : 00033 key(theKey), 00034 value(theValue) 00035 { } 00036 00037 /// Copy constructor 00038 00039 CdbBdbSCollectionBte( const CdbBdbSCollectionBte& theEntry ) 00040 { 00041 key = theEntry.key; 00042 value = theEntry.value; 00043 } 00044 00045 /// The destructor 00046 /** 00047 * NOTE: The destructor is NOT virtual because this is an embedded 00048 * class. 00049 */ 00050 ~CdbBdbSCollectionBte( ) { } 00051 00052 /// The assignment operator 00053 /** 00054 */ 00055 CdbBdbSCollectionBte& operator=( const CdbBdbSCollectionBte& theEntry ) 00056 { 00057 if( this != &theEntry ) { 00058 key = theEntry.key; 00059 value = theEntry.value; 00060 } 00061 return *this; 00062 } 00063 00064 /// The "equal" operator 00065 /** 00066 * NOTE: This comparisioon is only done for "key". 00067 */ 00068 bool operator==( const CdbBdbSCollectionBte& theEntry ) const 00069 { 00070 return key == theEntry.key; 00071 } 00072 00073 /// The "less" operator 00074 /** 00075 * NOTE: This comparisioon is only done for "key". 00076 */ 00077 bool operator<( const CdbBdbSCollectionBte& theEntry ) const 00078 { 00079 return key < theEntry.key; 00080 } 00081 00082 public: 00083 00084 d_UShort key; // The key 00085 BdbRef(CdbBdbSCollectionElementP) value; // The value of the coresponding data object 00086 }; 00087 00088 inline std::ostream& 00089 operator<<( std::ostream& o, 00090 const CdbBdbSCollectionBte& theEntry ) 00091 { 00092 return o << theEntry.key <<std::endl; 00093 } 00094 00095 #endif // CDBBDBSHARED_COLLECTION_BTE_HH
1.3-rc3