| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# StoreExplorerAlg Class Reference

Small algorith, which traverses the data store and prints generic information about all leaves, which can be loaded/accessed. More...

Inheritance diagram for StoreExplorerAlg:

[legend]
Collaboration diagram for StoreExplorerAlg:

[legend]

List of all members.

## Public Member Functions
| StoreExplorerAlg (const std::string &name, ISvcLocator *pSvcLocator)
| Standard algorithm constructor.
virtual | ~StoreExplorerAlg ()
| Standard Destructor.
template<class T>
std::string | access (T *p)
void | printObj (IRegistry *pReg, std::vector< bool > &flg)
| Print datastore leaf.
void | explore (IRegistry *pObj, std::vector< bool > &flg)
virtual StatusCode | initialize ()
| Initialize.
virtual StatusCode | finalize ()
| Finalize.
virtual StatusCode | execute ()
| Execute procedure.
## Private Attributes
long | m_print
| Job option to limit printout to first nnn events.
double | m_frequency
| Job option to set the printout frequency.
bool | m_exploreRelations
| Flag to check if relations should be followed.
long | m_printMissing
| Flag to indicate if missing entities should be printed.
long | m_total
| Internal counter to trigger printouts.
long | m_frqPrint
| Internal counter to adjust printout frequency.
bool | m_load
| Flag to load non existing items.
bool | m_testAccess
| Flag to test access to objects (DataObject and ContainedObject).
bool | m_accessForeign
| Flag to indicate if foreign files should be opened.
IDataProviderSvc * | m_dataSvc
| Reference to data provider service.
std::string | m_dataSvcName
| Name of the data provider service.
std::string | m_rootName
| Name of the root leaf (obtained at initialize).

## Detailed Description

Small algorith, which traverses the data store and prints generic information about all leaves, which can be loaded/accessed.

Author:
  : M.Frank

Version:
  : 1.0

Definition at line 32 of file StoreExplorerAlg.cpp.

## Constructor & Destructor Documentation

StoreExplorerAlg::StoreExplorerAlg | ( | const std::string & | name,
|  | ISvcLocator * | pSvcLocator |
| ) |  |  | `[inline]`

Standard algorithm constructor.

Definition at line 60 of file StoreExplorerAlg.cpp.

    00061   :     Algorithm(name, pSvcLocator), m_dataSvc(0)
    00062   {
    00063     m_total = m_frqPrint = 0;
    00064     declareProperty("Load",             m_load = false);
    00065     declareProperty("PrintEvt",         m_print = 1);
    00066     declareProperty("PrintMissing",     m_printMissing = 0);
    00067     declareProperty("PrintFreq",        m_frequency = 0.0);
    00068     declareProperty("ExploreRelations", m_exploreRelations = false);
    00069     declareProperty("DataSvc",          m_dataSvcName="EventDataSvc");
    00070     declareProperty("TestAccess",       m_testAccess = false);
    00071     declareProperty("AccessForeign",    m_accessForeign = false);
    00072   }

virtual StoreExplorerAlg::~StoreExplorerAlg | ( |  | ) | `[inline, virtual]`

Standard Destructor.

Definition at line 74 of file StoreExplorerAlg.cpp.

    00074                                   {
    00075   }

## Member Function Documentation

template<class T>

std::string StoreExplorerAlg::access | ( | T * | p | ) | `[inline]`

Definition at line 78 of file StoreExplorerAlg.cpp.

    00078                           {
    00079     if ( p )  {
    00080       std::stringstream s;
    00081       for (typename T::const_iterator i = p->begin(); i != p->end(); ++i )  {
    00082         int idx = p->index(*i);
    00083         s << idx << ":" << (*i)->clID() << ",";
    00084       }
    00085       std::string result = s.str();
    00086       return result.substr(0, result.length()-2);
    00087     }
    00088     return "Access FAILED.";
    00089   }

void StoreExplorerAlg::printObj | ( | IRegistry * | pReg,
|  | std::vector< bool > & | flg |
| ) |  |  | `[inline]`

Print datastore leaf.

Definition at line 93 of file StoreExplorerAlg.cpp.

    00093                                                           {
    00094     MsgStream log(msgSvc(), name());
    00095     log << MSG::INFO;
    00096     for (size_t j = 1; j < flg.size(); j++ )     {
    00097       if ( !flg[j-1] && flg[j] ) log << "| ";
    00098       else if ( flg[j] ) log << "  ";
    00099       else          log << "| ";
    00100     }
    00101     log << "+--> " << pReg->name();
    00102     if ( pReg->address() )  {
    00103       log << " [Address: CLID="
    00104           << std::showbase << std::hex << pReg->address()->clID();
    00105       log << " Type=" << (void*)pReg->address()->svcType() << "]";
    00106     }
    00107     else  {
    00108       log << " [No Address]";
    00109     }
    00110     DataObject* p = pReg->object();
    00111     if ( p )   {
    00112       try  {
    00113         std::string typ = System::typeinfoName(typeid(*p));
    00114         if ( m_testAccess )  {
    00115           p->clID();
    00116         }
    00117         log << "  " << typ.substr(0,32);
    00118       }
    00119       catch (...)  {
    00120         log << "Access test FAILED";
    00121       }
    00122     }
    00123     else    {
    00124       log << "  (Unloaded) ";
    00125     }
    00126     ObjectContainerBase* base = dynamic_cast<ObjectContainerBase*>(p);
    00127     if ( base )  {
    00128       try   {
    00129         int numObj = base->numberOfObjects();
    00130         const CLID id = p->clID();
    00131         log << " [" << numObj << "]";
    00132         if ( m_testAccess )  {
    00133           CLID idd = id>>16;
    00134           switch(idd) {
    00135             case CLID_ObjectList>>16:                /* ObjectList    */
    00136               access((ObjectList<ContainedObject>*)base);
    00137               break;
    00138             case CLID_ObjectVector>>16:              /* ObjectVector  */
    00139               access((ObjectVector<ContainedObject>*)base);
    00140               break;
    00141             case (CLID_ObjectVector+0x00030000)>>16: /* Keyed Map     */
    00142               access((KeyedContainer<KeyedObject<int>,Containers::Map>*)base);
    00143               break;
    00144             case (CLID_ObjectVector+0x00040000)>>16: /* Keyed Hashmap */
    00145               access((KeyedContainer<KeyedObject<int>,Containers::HashMap>*)base);
    00146               break;
    00147             case (CLID_ObjectVector+0x00050000)>>16: /* Keyed array   */
    00148               access((KeyedContainer<KeyedObject<int>,Containers::Array>*)base);
    00149               break;
    00150           }
    00151         }
    00152       }
    00153       catch (...)  {
    00154         log << "Access test FAILED";
    00155       }
    00156     }
    00157     log << endmsg;
    00158   }

void StoreExplorerAlg::explore | ( | IRegistry * | pObj,
|  | std::vector< bool > & | flg |
| ) |  |  | `[inline]`

Definition at line 160 of file StoreExplorerAlg.cpp.

    00160                                                          {
    00161     printObj(pObj, flg);
    00162     if ( 0 != pObj )    {
    00163       SmartIF<IDataManagerSvc> mgr(eventSvc());
    00164       if ( mgr )    {
    00165         typedef std::vector<IRegistry*> Leaves;
    00166         Leaves leaves;
    00167         StatusCode sc = mgr->objectLeaves(pObj, leaves);
    00168         const std::string* par0 = 0;
    00169         if ( pObj->address() )  {
    00170           par0 = pObj->address()->par();
    00171         }
    00172         if ( sc.isSuccess() )  {
    00173           for ( Leaves::const_iterator i=leaves.begin(); i != leaves.end(); i++ )   {
    00174             const std::string& id = (*i)->identifier();
    00175             DataObject* p = 0;
    00176             if ( !m_accessForeign && (*i)->address() )  {
    00177               if ( par0 )  {
    00178                 const std::string* par1 = (*i)->address()->par();
    00179                 if ( par1 )  {
    00180                   if ( par0[0] != par1[0] )  {
    00181                     continue;
    00182                   }
    00183                 }
    00184               }
    00185             }
    00186             if ( m_load )  {
    00187               sc = eventSvc()->retrieveObject(id, p);
    00188             }
    00189             else {
    00190               sc = eventSvc()->findObject(id, p);
    00191             }
    00192             if ( sc.isSuccess() )  {
    00193               if ( id != "/Event/Rec/Relations" || m_exploreRelations )   {
    00194                 flg.push_back(i+1 == leaves.end());
    00195                 explore(*i, flg);
    00196                 flg.pop_back();
    00197               }
    00198             }
    00199             else {
    00200               flg.push_back(i+1 == leaves.end());
    00201               printObj(*i, flg);
    00202               flg.pop_back();
    00203             }
    00204           }
    00205         }
    00206       }
    00207     }
    00208   }

virtual StatusCode StoreExplorerAlg::initialize | ( |  | ) | `[inline, virtual]`

Initialize.

Reimplemented from Algorithm.

Definition at line 211 of file StoreExplorerAlg.cpp.

    00211                                     {
    00212     MsgStream log(msgSvc(), name());
    00213     m_rootName = "";
    00214     StatusCode sc = service(m_dataSvcName, m_dataSvc, true);
    00215     if ( sc.isSuccess() )  {
    00216       SmartIF<IDataManagerSvc> mgr(m_dataSvc);
    00217       if ( mgr )  {
    00218         m_rootName = mgr->rootName();
    00219         return sc;
    00220       }
    00221       log << MSG::ERROR << "Failed to retrieve IDataManagerSvc interface." << endmsg;
    00222       return StatusCode::FAILURE;
    00223     }
    00224     log << MSG::ERROR << "Failed to access service \""
    00225         << m_dataSvcName << "\"." << endmsg;
    00226     return StatusCode::FAILURE;
    00227   }

virtual StatusCode StoreExplorerAlg::finalize | ( | void |  | ) | `[inline, virtual]`

Finalize.

Reimplemented from Algorithm.

Definition at line 230 of file StoreExplorerAlg.cpp.

    00230                                 {
    00231     if ( m_dataSvc ) m_dataSvc->release();
    00232     m_dataSvc = 0;
    00233     return StatusCode::SUCCESS;
    00234   }

virtual StatusCode StoreExplorerAlg::execute | ( |  | ) | `[inline, virtual]`

Execute procedure.

Definition at line 237 of file StoreExplorerAlg.cpp.

    00237                                   {
    00238     MsgStream log(msgSvc(), name());
    00239     SmartDataPtr<DataObject>   root(m_dataSvc,m_rootName);
    00240     if ( ((m_print > m_total++) || (m_frequency*m_total > m_frqPrint)) && root )    {
    00241       if ( m_frequency*m_total > m_frqPrint )  {
    00242         m_frqPrint++;
    00243       }
    00244       std::string store_name = "Unknown";
    00245       IRegistry* pReg = root->registry();
    00246       if ( pReg )  {
    00247         SmartIF<IService> isvc(pReg->dataSvc());
    00248         if ( isvc )  {
    00249           store_name = isvc->name();
    00250         }
    00251       }
    00252       log << MSG::INFO << "========= " << m_rootName << "["
    00253           << "0x" << std::hex << (unsigned long) root.ptr() << std::dec
    00254           << "@" << store_name << "]:" << endmsg;
    00255       std::vector<bool> flg;
    00256       flg.push_back(true);
    00257       explore(root->registry(), flg);
    00258       return StatusCode::SUCCESS;
    00259     }
    00260     else if ( root )   {
    00261       return StatusCode::SUCCESS;
    00262     }
    00263     log << MSG::ERROR << "Cannot retrieve \"/Event\"!" << endmsg;
    00264     return StatusCode::FAILURE;
    00265   }

## Member Data Documentation

long StoreExplorerAlg::m_print`[private]`

Job option to limit printout to first nnn events.

Definition at line 34 of file StoreExplorerAlg.cpp.

double StoreExplorerAlg::m_frequency`[private]`

Job option to set the printout frequency.

Definition at line 36 of file StoreExplorerAlg.cpp.

bool StoreExplorerAlg::m_exploreRelations`[private]`

Flag to check if relations should be followed.

Definition at line 38 of file StoreExplorerAlg.cpp.

long StoreExplorerAlg::m_printMissing`[private]`

Flag to indicate if missing entities should be printed.

Definition at line 40 of file StoreExplorerAlg.cpp.

long StoreExplorerAlg::m_total`[private]`

Internal counter to trigger printouts.

Definition at line 42 of file StoreExplorerAlg.cpp.

long StoreExplorerAlg::m_frqPrint`[private]`

Internal counter to adjust printout frequency.

Definition at line 44 of file StoreExplorerAlg.cpp.

bool StoreExplorerAlg::m_load`[private]`

Flag to load non existing items.

Definition at line 46 of file StoreExplorerAlg.cpp.

bool StoreExplorerAlg::m_testAccess`[private]`

Flag to test access to objects (DataObject and ContainedObject).

Definition at line 48 of file StoreExplorerAlg.cpp.

bool StoreExplorerAlg::m_accessForeign`[private]`

Flag to indicate if foreign files should be opened.

Definition at line 50 of file StoreExplorerAlg.cpp.

IDataProviderSvc* StoreExplorerAlg::m_dataSvc`[private]`

Reference to data provider service.

Definition at line 52 of file StoreExplorerAlg.cpp.

std::string StoreExplorerAlg::m_dataSvcName`[private]`

Name of the data provider service.

Definition at line 54 of file StoreExplorerAlg.cpp.

std::string StoreExplorerAlg::m_rootName`[private]`

Name of the root leaf (obtained at initialize).

Definition at line 56 of file StoreExplorerAlg.cpp.

The documentation for this class was generated from the following file:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/GaudiSvc/src/DataSvc/StoreExplorerAlg.cpp