Gaudi Framework, version v20r2

Generated: 18 Jul 2008

PoolDbDirectoryCnv Class Reference

#include <GaudiPoolDb/PoolDbDirectoryCnv.h>

Inheritance diagram for PoolDbDirectoryCnv:

Inheritance graph
[legend]
Collaboration diagram for PoolDbDirectoryCnv:

Collaboration graph
[legend]
List of all members.

Detailed Description

Description: NTuple directory converter class definition Definition of the converter to manage the directories in an database representing N-Tuples.

Author:
M.Frank
Version:
1.0

Definition at line 26 of file PoolDbDirectoryCnv.h.

Public Member Functions

 PoolDbDirectoryCnv (long typ, const CLID &clid, ISvcLocator *svc)
 Initializing Constructor.
virtual ~PoolDbDirectoryCnv ()
 Standard Destructor.
virtual StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&refpObj)
 Converter overrides: Create transient object from persistent data.
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddr, DataObject *pObj)
 Converter overrides: Resolve the references of the transient object.
virtual StatusCode updateObj (IOpaqueAddress *pAddr, DataObject *pObj)
 Converter overrides: Update transient object from persistent data.
virtual StatusCode updateObjRefs (IOpaqueAddress *pAddr, DataObject *pObj)
 Converter overrides: Update the references of an updated transient object.
virtual StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAddr)
 Converter overrides: Convert the transient object to the requested representation.
virtual StatusCode updateRep (IOpaqueAddress *pAddr, DataObject *pObj)
 Converter overrides: Update persistent object representation.
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddr, DataObject *pObj)
 Converter overrides: Update references of persistent object representation.


Constructor & Destructor Documentation

PoolDbDirectoryCnv::PoolDbDirectoryCnv ( long  typ,
const CLID clid,
ISvcLocator svc 
)

Initializing Constructor.

Parameters:
typ [IN] Concrete storage type of the converter
clid [IN] Class identifier of the object
svc [IN] Pointer to service locator object
Returns:
Reference to PoolDbBaseCnv object

Definition at line 33 of file PoolDbDirectoryCnv.cpp.

00036 : PoolDbStatCnv(typ, clid, svc)
00037 {
00038 }

virtual PoolDbDirectoryCnv::~PoolDbDirectoryCnv (  )  [inline, virtual]

Standard Destructor.

Definition at line 39 of file PoolDbDirectoryCnv.h.

00039 {  }


Member Function Documentation

StatusCode PoolDbDirectoryCnv::createObj ( IOpaqueAddress pAddr,
DataObject *&  refpObj 
) [virtual]

Converter overrides: Create transient object from persistent data.

Parameters:
pAddr [IN] Pointer to object address.
refpObj [OUT] Location to pointer to store data object
Returns:
Status code indicating success or failure.

Reimplemented from PoolDbBaseCnv.

Reimplemented in PoolDbDatabaseCnv.

Definition at line 42 of file PoolDbDirectoryCnv.cpp.

References StatusCode::SUCCESS.

00044 {
00045   refpObject = new NTuple::Directory();
00046   return StatusCode::SUCCESS;
00047 }

StatusCode PoolDbDirectoryCnv::fillObjRefs ( IOpaqueAddress pAddr,
DataObject pObj 
) [virtual]

Converter overrides: Resolve the references of the transient object.

Parameters:
pAddr [IN] Pointer to object address.
pObj [IN] Pointer to data object
Returns:
Status code indicating success or failure.

Reimplemented from PoolDbBaseCnv.

Definition at line 73 of file PoolDbDirectoryCnv.cpp.

References updateObjRefs().

00074 {
00075   return updateObjRefs(pAddr, pObj);
00076 }

StatusCode PoolDbDirectoryCnv::updateObj ( IOpaqueAddress pAddr,
DataObject pObj 
) [virtual]

Converter overrides: Update transient object from persistent data.

Parameters:
pAddr [IN] Pointer to object address.
pObj [IN] Pointer to data object
Returns:
Status code indicating success or failure.

Reimplemented from PoolDbBaseCnv.

Definition at line 174 of file PoolDbDirectoryCnv.cpp.

References StatusCode::SUCCESS.

00176 {  
00177   return StatusCode::SUCCESS;
00178 }

StatusCode PoolDbDirectoryCnv::updateObjRefs ( IOpaqueAddress pAddr,
DataObject pObj 
) [virtual]

Converter overrides: Update the references of an updated transient object.

Parameters:
pAddr [IN] Pointer to object address.
pObj [IN] Pointer to data object
Returns:
Status code indicating success or failure.

Reimplemented from PoolDbBaseCnv.

Definition at line 79 of file PoolDbDirectoryCnv.cpp.

References CLID_ColumnWiseTuple, CLID_RowWiseTuple, CLID_StatisticsDirectory, CLID_StatisticsFile, PoolDbNTupleDescriptor::container, PoolDbStatCnv::containerName(), IPoolDbMgr::createAddress(), IPoolDbMgr::createSelect(), StatusCode::FAILURE, PoolDbStatCnv::fileName(), std::basic_string< _CharT, _Traits, _Alloc >::find(), pool::DbReflex::forTypeName(), IRegistry::identifier(), StatusCode::ignore(), pool::INVALID, StatusCode::isSuccess(), std::basic_string< _CharT, _Traits, _Alloc >::length(), PoolDbBaseCnv::m_dataMgr, PoolDbBaseCnv::m_dbMgr, PoolDbBaseCnv::makeError(), Converter::msgSvc(), std::basic_string< _CharT, _Traits, _Alloc >::npos, IDataManagerSvc::objectLeaves(), IPoolDbMgr::read(), IDataManagerSvc::registerAddress(), IOpaqueAddress::registry(), pool::Token::release(), PoolDbBaseCnv::repSvcType(), Gaudi::Units::s, std::basic_string< _CharT, _Traits, _Alloc >::substr(), and PoolDbStatCnv::topLevel().

Referenced by fillObjRefs().

00081 {
00082   typedef std::vector<PoolDbNTupleDescriptor*> REFS;
00083   REFS refs;
00084   StatusCode status = StatusCode(StatusCode::FAILURE,true);
00085   MsgStream log(msgSvc(), "PoolDbDatabaseCnv");
00086   if ( pAddr ) {
00087     IRegistry* pReg = pAddr->registry();
00088     if ( pReg )  {
00089       std::string ident   = pReg->identifier();
00090       std::string fname   = fileName(pReg);
00091       std::string cntName = containerName(pReg);
00092       std::auto_ptr<pool::DbSelect> iter(m_dbMgr->createSelect("*", fname, "GaudiStatisticsDescription"));
00093       if ( iter.get() )  {
00094         pool::DbObjectCallBack cb(pool::DbReflex::forTypeName("PoolDbNTupleDescriptor"));
00095         typedef std::vector<IRegistry*> Leaves;
00096         pool::Token* token = 0;
00097         Leaves leaves;
00098         while( iter->next(token).isSuccess() )  {
00099           m_dbMgr->read(&cb, *token).ignore();
00100           PoolDbNTupleDescriptor* ref = (PoolDbNTupleDescriptor*)cb.object();
00101           std::string s = ref->container.substr(0,cntName.length());
00102           if ( s == cntName )  {
00103             if ( ref->container.length() > cntName.length()+1 )  {
00104               if ( ref->container.find('/',cntName.length()+1) == std::string::npos ) {
00105                 refs.push_back(ref);
00106                 token->release();
00107                 continue;
00108               }
00109             }
00110           }
00111           delete ref;
00112           token->release();
00113         }
00114         status = m_dataMgr->objectLeaves(pObject, leaves);
00115         if ( status.isSuccess() )    {
00116           for(REFS::iterator i = refs.begin(); i != refs.end(); ++i)  {
00117             REFS::value_type& ref = *i;
00118             if ( ref )   {
00119               bool need_to_add = true;
00120               for(Leaves::iterator j=leaves.begin(); j != leaves.end(); ++j )  {
00121                 std::string curr_leaf = containerName(*j);
00122                 if ( curr_leaf == ref->container )  {
00123                   need_to_add = false;
00124                   break;
00125                 }
00126               }
00127               if ( need_to_add )  {
00128                 IOpaqueAddress* pA= 0;
00129                 if ( ref->clid == CLID_StatisticsDirectory ||
00130                      ref->clid == CLID_StatisticsFile      || 
00131                      ref->clid == CLID_RowWiseTuple        ||
00132                      ref->clid == CLID_ColumnWiseTuple      )
00133                 {
00134                   std::string spar[]   = { fname, ref->container};
00135                   unsigned long ipar[] = { pool::INVALID, pool::INVALID};
00136                   status = m_dbMgr->createAddress(repSvcType(),
00137                                                   ref->clid,
00138                                                   spar,
00139                                                   ipar,
00140                                                   pA);
00141                 }
00142                 if ( status.isSuccess() )  {
00143                   std::string top = topLevel(pReg);
00144                   std::string leaf_name = top + ref->container.substr(7);
00145                   status = m_dataMgr->registerAddress(leaf_name, pA);
00146                   if ( status.isSuccess() )  {
00147                     continue;
00148                   }
00149                   makeError("Failed to register leaves to directory:"+ident,false).ignore();
00150                   break;
00151                 }
00152                 makeError("Failed to create leave address to directory:"+ident,false).ignore();
00153                 break;
00154               }
00155             }
00156             makeError("Failed to add leaves to directory:"+ident,false).ignore();
00157             break;
00158           }
00159         }
00160       }
00161       else  {
00162         return makeError("Failed to access required tuple data description.",false);
00163       }
00164     }
00165   }
00166   for(REFS::iterator k = refs.begin(); k != refs.end(); ++k)  {
00167     if ( *k ) delete (*k);
00168   }
00169   return status;
00170 }

StatusCode PoolDbDirectoryCnv::createRep ( DataObject pObj,
IOpaqueAddress *&  refpAddr 
) [virtual]

Converter overrides: Convert the transient object to the requested representation.

Parameters:
pObj [IN] Pointer to data object
refpAddr [OUT] Location to store pointer to object address.
Returns:
Status code indicating success or failure.

Reimplemented from PoolDbBaseCnv.

Definition at line 50 of file PoolDbDirectoryCnv.cpp.

References CLID_StatisticsDirectory, CLID_StatisticsFile, PoolDbStatCnv::containerName(), pool::Guid::Data1, StatusCode::FAILURE, PoolDbStatCnv::fileName(), pool::Guid::null(), Converter::objType(), Gaudi::Utils::Histos::path(), DataObject::registry(), and PoolDbStatCnv::saveDescription().

00052 {
00053   std::string dsc;
00054   pool::Guid guid(pool::Guid::null());
00055   guid.Data1 = objType();
00056 
00057   if ( objType() == CLID_StatisticsDirectory )  {
00058     dsc = "Directory containing statistics results.";
00059   }
00060   else if ( objType() == CLID_StatisticsFile )  {
00061     dsc = "File containing statistics results.";
00062   }
00063   else  {
00064     return StatusCode::FAILURE;
00065   }
00066   std::string ident = containerName(pObject->registry());
00067   std::string path  = fileName(pObject->registry());
00068   return saveDescription(path, ident, dsc, "", guid, objType(), "UPDATE");
00069 }

StatusCode PoolDbDirectoryCnv::updateRep ( IOpaqueAddress pAddr,
DataObject pObj 
) [virtual]

Converter overrides: Update persistent object representation.

Parameters:
pObj [IN] Pointer to data object
refpAddr [OUT] Location to store pointer to object address.
Returns:
Status code indicating success or failure.

Reimplemented from PoolDbBaseCnv.

Definition at line 182 of file PoolDbDirectoryCnv.cpp.

References StatusCode::SUCCESS.

00184 {
00185   return StatusCode::SUCCESS;
00186 }

StatusCode PoolDbDirectoryCnv::updateRepRefs ( IOpaqueAddress pAddr,
DataObject pObj 
) [virtual]

Converter overrides: Update references of persistent object representation.

Parameters:
pObj [IN] Pointer to data object
refpAddr [OUT] Location to store pointer to object address.
Returns:
Status code indicating success or failure.

Reimplemented from PoolDbBaseCnv.

Definition at line 190 of file PoolDbDirectoryCnv.cpp.

References StatusCode::SUCCESS.

00192 {
00193   return StatusCode::SUCCESS;
00194 }


The documentation for this class was generated from the following files:
Generated at Fri Jul 18 12:08:56 2008 for Gaudi Framework, version v20r2 by Doxygen version 1.5.1 written by Dimitri van Heesch, © 1997-2004