00001 #ifndef CDBBDB_OBJECT_CONVERTOR_HH 00002 #define CDBBDB_OBJECT_CONVERTOR_HH 00003 00004 // File and Version Information: 00005 // $Id: CdbBdbObjectConvertor.hh,v 1.3 2002/09/23 22:39:09 gapon Exp $ 00006 00007 #include "CdbBase/CdbObjectPtrFwd.hh" 00008 00009 #include "BdbCond/BdbObject.hh" 00010 00011 /// This is a BDB specific Object Convertor 00012 /** 00013 * This is a utility class providing an interface to technology-specific 00014 * implementations of the persistent object conversion. It's sussposed to be 00015 * a kind of "type bridge" between the technology-independent part of the API 00016 * and the technology-specific one. 00017 */ 00018 class CdbBdbObjectConvertor { 00019 00020 public: 00021 00022 /// Narrow a transient meta-data object into a real persistent object 00023 /** 00024 * This operation will verify if the specified object pointer has expected 00025 * technology, and if so it will extract the persistent handle out of this object. 00026 * 00027 * Note, that it's up to teh end user to upcast from the resulting handle to 00028 * a handle of the actual class. 00029 * 00030 * @see CdbObject 00031 * @see CdbObjectPtr 00032 * @see CdbStatus 00033 */ 00034 static CdbStatus narrow( BdbHandle(BdbObject)& thePersObj, /**< a persistent handle to be set up */ 00035 const CdbObjectPtr& thePtr /**< a smart input for an input object */ 00036 ); 00037 00038 /// Narrow a transient meta-data object into a real persistent object of specified type 00039 /** 00040 * This operation is a functional superset of the CdbBdbObjectConvertor::narrow() 00041 * method. In addition it does the type matching for specified type. If the type does 00042 * not match then it returns a error status. 00043 * 00044 * @see CdbObject 00045 * @see CdbObjectPtr 00046 * @see CdbStatus 00047 */ 00048 template< class P > 00049 static CdbStatus typeSafeNarrow( BdbHandle(P)& thePersObj, /**< a persistent handle to be set up */ 00050 const CdbObjectPtr& thePtr /**< a smart input for an input object */ 00051 ) 00052 { 00053 CdbStatus result = narrow( thePersObj, thePtr ); 00054 if( CdbStatus::Success == result ) { 00055 if( !thePersObj.isValid( ) || 00056 thePersObj.typeN( ) != ooTypeN(P)) { 00057 result = CdbStatus::Error; 00058 } 00059 } 00060 return result; 00061 } 00062 }; 00063 00064 #endif // CDBBDB_OBJECT_CONVERTOR_HH 00065
1.3-rc3