![]() |
|
|
Generated: 8 Jan 2009 |
#include <HFileCnv.h>


Description: Definition of the converter to open HBOOK RZ files
Dependencies:
History :
+---------+----------------------------------------------+--------+
| Date | Comment | Who |
+---------+----------------------------------------------+--------+
| 21/10/99| Initial version. | MF |
+---------+----------------------------------------------+--------+
Author: M.Frank Version: 1.0
Definition at line 47 of file HFileCnv.h.
Public Member Functions | |
| virtual StatusCode | createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) |
| Create the transient representation of an object. | |
| virtual StatusCode | createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) |
| Convert the transient object to the requested representation. | |
| virtual StatusCode | updateRep (IOpaqueAddress *pAddress, DataObject *pObject) |
| Convert the transient object to the requested representation. | |
| virtual StatusCode | initialize () |
| Initialize the converter. | |
| HFileCnv (ISvcLocator *svc) | |
| Standard constructor. | |
| virtual | ~HFileCnv () |
| Standard destructor. | |
Static Public Member Functions | |
| static const CLID & | classID () |
| Inquire class type. | |
Private Attributes | |
| int | m_LRECL |
| int | m_NRECL |
| std::string | m_MODE |
Friends | |
| class | CnvFactory< HFileCnv > |
| HbookCnv::HFileCnv::HFileCnv | ( | ISvcLocator * | svc | ) | [inline] |
Standard constructor.
Definition at line 66 of file HFileCnv.h.
00067 : HDirectoryCnv(svc, CLID_NTupleFile) 00068 , m_LRECL ( 1024 ) 00069 , m_NRECL ( -1 ) 00070 , m_MODE ( "P" ) 00071 {}
| virtual HbookCnv::HFileCnv::~HFileCnv | ( | ) | [inline, virtual] |
| StatusCode HbookCnv::HFileCnv::createObj | ( | IOpaqueAddress * | pAddress, | |
| DataObject *& | refpObject | |||
| ) | [virtual] |
Create the transient representation of an object.
Reimplemented from HbookCnv::HDirectoryCnv.
Definition at line 76 of file HFileCnv.cpp.
00076 { 00077 MsgStream log(msgSvc(), "HbookNFileCnv"); 00078 unsigned long* ipar = (unsigned long*)pAddress->ipar(); 00079 std::string fname = pAddress->par()[0]; 00080 std::string oname = pAddress->registry()->name().c_str()+1; 00081 // V.B.: char mode[3] = { char(ipar[1]), 'P', 0 }; 00082 // V.B.: long istat, lrec=1024, lun = ::F77GETLUN(); 00083 std::string mode ( 1 , char(ipar[1]) ) ; 00084 mode += m_MODE ; 00085 long istat, lrec=m_LRECL, lun = ::F77GETLUN(); 00086 // Do the init 00087 ::INIT_HBOOK(250000); 00088 // Do not forget to remove the first "/" 00089 if ( mode[0] == 'O' ) mode[0] = ' '; 00090 if ( std::string::npos != mode.find('Q') && 0 < m_NRECL ) 00091 { ::SETQUEST( 10 , m_NRECL ) ; } 00092 ::HROPEN(lun, oname, fname, mode, lrec, istat); 00093 00094 if ( istat != 0 ) { 00095 log << MSG::ERROR << "Error opening HBook RZ file:" << fname 00096 << " as " << oname << endreq; 00097 return StatusCode::FAILURE; 00098 } 00099 else if ( mode[0] == 'N' ) { 00100 log << MSG::INFO << "Opened NEW HBook RZ file:" << fname 00101 << " as " << oname << endreq; 00102 } 00103 else if ( mode[0] == 'U' ) { 00104 log << MSG::INFO << "Updating EXISTING HBook RZ file:" << fname 00105 << " as " << oname << endreq; 00106 } 00107 else { 00108 log << MSG::INFO << "Opening EXISTING HBook RZ file:" << fname 00109 << " as " << oname << endreq; 00110 } 00111 NTuple::File* pFile = new NTuple::File((unsigned char)objType(), fname, oname); 00112 ipar[0] = lun; 00113 pFile->setOpen(true); 00114 refpObject = pFile; 00115 return StatusCode::SUCCESS; 00116 }
| StatusCode HbookCnv::HFileCnv::createRep | ( | DataObject * | pObject, | |
| IOpaqueAddress *& | refpAddress | |||
| ) | [virtual] |
Convert the transient object to the requested representation.
Reimplemented from HbookCnv::HDirectoryCnv.
Definition at line 120 of file HFileCnv.cpp.
00120 { 00121 IRegistry* pRegistry = pObject->registry(); 00122 if ( 0 != pRegistry ) { 00123 refpAddress = pRegistry->address(); 00124 return HFileCnv::updateRep( refpAddress, pObject ); 00125 } 00126 return StatusCode::FAILURE; 00127 }
| StatusCode HbookCnv::HFileCnv::updateRep | ( | IOpaqueAddress * | pAddress, | |
| DataObject * | pObject | |||
| ) | [virtual] |
Convert the transient object to the requested representation.
Reimplemented from HbookCnv::HDirectoryCnv.
Definition at line 131 of file HFileCnv.cpp.
00131 { 00132 NTuple::File* pFile = dynamic_cast<NTuple::File*>(pObject); 00133 if ( pFile->isOpen() ) { 00134 MsgStream log(msgSvc(), "HbookNFileCnv"); 00135 std::string oname = pFile->logicalName(); 00136 long lun = pAddress->ipar()[0]; 00137 ::HREND(oname.c_str(), oname.length()); 00138 F77CLOSE(lun); 00139 log << MSG::INFO << "Closing HBook RZ file:" << pFile->name() 00140 << " as " << pObject->registry()->identifier() << endreq; 00141 pFile->setOpen(false); 00142 return StatusCode::SUCCESS; 00143 } 00144 return StatusCode::FAILURE; 00145 }
| static const CLID& HbookCnv::HFileCnv::classID | ( | ) | [inline, static] |
Inquire class type.
Reimplemented from HbookCnv::HDirectoryCnv.
Definition at line 59 of file HFileCnv.h.
00059 { 00060 return CLID_NTupleFile; 00061 }
| StatusCode HbookCnv::HFileCnv::initialize | ( | ) | [virtual] |
Initialize the converter.
Reimplemented from Converter.
Definition at line 31 of file HFileCnv.cpp.
00032 { 00033 StatusCode sc = HbookCnv::HDirectoryCnv::initialize() ; 00034 if ( sc.isFailure() ) { return sc ; } 00035 00036 // Get Tool Service 00037 IToolSvc* tSvc = 0 ; 00038 MsgStream log ( msgSvc() , "HbookNFileCnv" ) ; 00039 ServiceLocatorHelper hlp( *serviceLocator() , log , "HbookNFileCnv" ) ; 00040 sc = hlp.getService( "ToolSvc", 00041 true , 00042 IToolSvc::interfaceID() , 00043 (void**)&tSvc ) ; 00044 if ( sc.isSuccess() && 0 != tSvc ) 00045 { 00046 IAlgTool* tool = 0 ; 00047 sc = tSvc->retrieve( "HbookTool" , IAlgTool::interfaceID() , tool ) ; 00048 if ( sc.isSuccess() && 0 != tool ) 00049 { 00050 IntegerProperty lrecl ( "LRECL" , m_LRECL ) ; 00051 IntegerProperty nrecl ( "NRECL" , m_NRECL ) ; 00052 StringProperty mode ( "MODE" , m_MODE ) ; 00053 IProperty* prop = 0 ; 00054 sc = tool->queryInterface( IProperty::interfaceID() , 00055 (void**)&prop ) ; 00056 if ( sc.isSuccess() && 0 != prop ) 00057 { 00058 if ( prop->getProperty ( &lrecl ).isSuccess() ) 00059 { m_LRECL = lrecl.value() ; } 00060 if ( prop->getProperty ( &nrecl ).isSuccess() ) 00061 { m_NRECL = nrecl.value() ; } 00062 if ( prop->getProperty ( &mode ).isSuccess() ) 00063 { m_MODE = mode.value() ; } 00064 prop->release() ; 00065 prop = 0 ; 00066 } 00067 tSvc->releaseTool( tool ) ; 00068 tool = 0 ; 00069 } 00070 tSvc->release() ; 00071 }; 00072 00073 return StatusCode::SUCCESS ; 00074 };
friend class CnvFactory< HFileCnv > [friend] |
Definition at line 49 of file HFileCnv.h.
int HbookCnv::HFileCnv::m_LRECL [private] |
Definition at line 76 of file HFileCnv.h.
int HbookCnv::HFileCnv::m_NRECL [private] |
Definition at line 77 of file HFileCnv.h.
std::string HbookCnv::HFileCnv::m_MODE [private] |
Definition at line 78 of file HFileCnv.h.