Gaudi Framework, version v25r2

Home   Generated: Wed Jun 4 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TagCollectionSvc.cpp
Go to the documentation of this file.
1 //====================================================================
2 // TagCollectionSvc.cpp
3 //--------------------------------------------------------------------
4 //
5 // Package : GaudiSvc/TagCollectionSvc ( The LHCb Offline System)
6 //
7 // Description: implementation of the NTuple service
8 //
9 // Author : M.Frank
10 // History :
11 // +---------+----------------------------------------------+---------
12 // | Date | Comment | Who
13 // +---------+----------------------------------------------+---------
14 // | 29/10/98| Initial version | MF
15 // | 29/09/99| Added access to ICnvManager for missing |
16 // | | converters | MF
17 // | 20/09/00| Connect dynamically to conversion service |
18 // | | for N-tuple persistency | MF
19 // +---------+----------------------------------------------+---------
20 //
21 //====================================================================
22 #define GAUDISVC_TAGCOLLECTIONSVC_CPP
23 
24 // Framework include files
25 #include "GaudiKernel/SmartIF.h"
26 #include "GaudiKernel/Tokenizer.h"
27 #include "GaudiKernel/DataObject.h"
30 
31 #include "GaudiKernel/IProperty.h"
35 
36 #include "GaudiKernel/MsgStream.h"
37 #include "GaudiKernel/Property.h"
38 
39 #include "TagCollectionSvc.h"
40 
41 // Instantiation of a static factory class used by clients to create
42 // instances of this service
44 
45 
46 TagCollectionSvc::TagCollectionSvc(const std::string& name, ISvcLocator* svc)
47  : NTupleSvc(name, svc)
48 {
49 }
50 
53 }
54 
58  return status;
59 }
60 
64  return status;
65 }
66 
68 StatusCode TagCollectionSvc::connect(const std::string& ident, std::string& logname) {
69  MsgStream log ( msgSvc(), name() );
70  DataObject* pO = 0;
71  StatusCode status = findObject(m_rootName, pO);
72  if ( status.isSuccess() ) {
73  status = INVALID_ROOT;
74  if ( 0 != pO->registry() ) {
75  char typ=0;
76  Tokenizer tok(true);
77  std::vector<Prop> props;
78  long loc = ident.find(" ");
79  std::string filename, auth, svc = "DbCnvSvc";
80  logname = ident.substr(0,loc);
81  tok.analyse(ident.substr(loc+1,ident.length()), " ", "", "", "=", "'", "'");
82  for ( Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); i++) {
83  const std::string& tag = (*i).tag();
84  switch( ::toupper(tag[0]) ) {
85  case 'A':
86  props.push_back( Prop("Server", (*i).value()));
87  break;
88  case 'F': /* FILE='<file name>' */
89  case 'D': /* DATAFILE='<file name>' */
90  filename = (*i).value();
91  break;
92  case 'O': /* OPT='<NEW<CREATE,WRITE>, UPDATE, READ>' */
93  switch( ::toupper((*i).value()[0]) ) {
94  case 'C':
95  case 'N':
96  case 'W': typ = 'N'; break;
97  case 'U': typ = 'U'; break;
98  case 'O':
99  case 'R':
100  switch( ::toupper((*i).value()[2]) ) {
101  case 'C': /* RECREATE */ typ = 'R'; break;
102  case 'A': /* READ */
103  default: typ = 'O'; break;
104  }
105  break;
106  default: typ = 0; break;
107  }
108  break;
109  case 'S': // SVC='<service type>'
110  switch( ::toupper(tag[1]) ) {
111  case 'V': svc = (*i).value(); break;
112  case 'H':
113  switch(::toupper((*i).value()[0])) {
114  case 'Y':
115  props.push_back( Prop("ShareFiles", (*i).value()));
116  break ;
117  }
118  break;
119  }
120  break;
121  case 'T': // TYP='<HBOOK,ROOT,OBJY,...>'
122  switch(::toupper((*i).value()[0])) {
123  case 'H':
124  svc = "HbookCnv::ConvSvc";
125  break;
126  case 'P':
127  props.push_back( Prop("DbType", (*i).value()));
128  svc = "PoolDbCnvSvc";
129  break;
130  default:
131  props.push_back( Prop("DbType", (*i).value()));
132  svc = "DbCnvSvc";
133  break;
134  }
135  break;
136  default:
137  props.push_back( Prop((*i).tag(), (*i).value()));
138  break;
139  }
140  }
141  if ( 0 != typ ) {
142  IConversionSvc* pSvc = 0;
143  status = createService(name()+'.'+logname, svc, props, pSvc);
144  if ( status.isSuccess() ) {
145  status = attachTuple(filename,logname,typ,pSvc->repSvcType());
146  if ( status.isSuccess() ) {
147  m_connections.insert(Connections::value_type(m_rootName+'/'+logname,Connection(pSvc)));
148  return StatusCode::SUCCESS;
149  }
150  }
151  }
152  }
153  }
154  log << MSG::ERROR << "Cannot add " << ident << " invalid filename!" << endmsg;
155  return StatusCode::FAILURE;
156 }
157 
160  const std::string& typ,
161  const std::vector<Prop>& props,
162  IConversionSvc*& pSvc) {
163  using Gaudi::Utils::TypeNameString;
165 
166  // TagCollectionSvc has to directly create a ConversionSvc to manage it directly.
167  StatusCode status = NO_INTERFACE;
168  if ( mgr.isValid() ) {
169 
170  SmartIF<IService> &isvc = mgr->createService(TypeNameString(nam, typ));
171  if (isvc.isValid()) {
172  status = isvc->queryInterface(IConversionSvc::interfaceID(), (void**)&pSvc);
173  if ( status.isSuccess() ) {
174  SmartIF<IProperty> iprop(isvc);
175  status = NO_INTERFACE;
176  if ( iprop.isValid( ) ) {
177  for ( std::vector<Prop>::const_iterator j = props.begin(); j != props.end(); j++) {
178  iprop->setProperty(StringProperty((*j).first, (*j).second)).ignore();
179  }
180  // NTupleSvc has to directly create a ConversionSvc to manage it directly.
181  status = isvc->sysInitialize();
182  if ( status.isSuccess() ) {
183  status = pSvc->setDataProvider(this);
184  if ( status.isSuccess() ) {
185  return status;
186  }
187  }
188  }
189  pSvc->release();
190  }
191  }
192  }
193  pSvc = 0;
194  return status;
195 }

Generated at Wed Jun 4 2014 14:48:58 for Gaudi Framework, version v25r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004