Gaudi Framework, version v23r7

Home   Generated: Wed Mar 20 2013
 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/SvcFactory.h"
28 #include "GaudiKernel/DataObject.h"
31 
32 #include "GaudiKernel/IProperty.h"
36 
37 #include "GaudiKernel/MsgStream.h"
38 #include "GaudiKernel/Property.h"
39 
40 #include "TagCollectionSvc.h"
41 
42 // Instantiation of a static factory class used by clients to create
43 // instances of this service
45 
46 
47 TagCollectionSvc::TagCollectionSvc(const std::string& name, ISvcLocator* svc)
48  : NTupleSvc(name, svc)
49 {
50 }
51 
54 }
55 
59  return status;
60 }
61 
65  return status;
66 }
67 
70  MsgStream log ( msgSvc(), name() );
71  DataObject* pO = 0;
72  StatusCode status = findObject(m_rootName, pO);
73  if ( status.isSuccess() ) {
74  status = INVALID_ROOT;
75  if ( 0 != pO->registry() ) {
76  char typ=0;
77  Tokenizer tok(true);
78  std::vector<Prop> props;
79  long loc = ident.find(" ");
80  std::string filename, auth, svc = "DbCnvSvc";
81  logname = ident.substr(0,loc);
82  tok.analyse(ident.substr(loc+1,ident.length()), " ", "", "", "=", "'", "'");
83  for ( Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); i++) {
84  const std::string& tag = (*i).tag();
85  switch( ::toupper(tag[0]) ) {
86  case 'A':
87  props.push_back( Prop("Server", (*i).value()));
88  break;
89  case 'F': /* FILE='<file name>' */
90  case 'D': /* DATAFILE='<file name>' */
91  filename = (*i).value();
92  break;
93  case 'O': /* OPT='<NEW<CREATE,WRITE>, UPDATE, READ>' */
94  switch( ::toupper((*i).value()[0]) ) {
95  case 'C':
96  case 'N':
97  case 'W': typ = 'N'; break;
98  case 'U': typ = 'U'; break;
99  case 'O':
100  case 'R':
101  switch( ::toupper((*i).value()[2]) ) {
102  case 'C': /* RECREATE */ typ = 'R'; break;
103  case 'A': /* READ */
104  default: typ = 'O'; break;
105  }
106  break;
107  default: typ = 0; break;
108  }
109  break;
110  case 'S': // SVC='<service type>'
111  switch( ::toupper(tag[1]) ) {
112  case 'V': svc = (*i).value(); break;
113  case 'H':
114  switch(::toupper((*i).value()[0])) {
115  case 'Y':
116  props.push_back( Prop("ShareFiles", (*i).value()));
117  break ;
118  }
119  break;
120  }
121  break;
122  case 'T': // TYP='<HBOOK,ROOT,OBJY,...>'
123  switch(::toupper((*i).value()[0])) {
124  case 'H':
125  svc = "HbookCnv::ConvSvc";
126  break;
127  case 'P':
128  props.push_back( Prop("DbType", (*i).value()));
129  svc = "PoolDbCnvSvc";
130  break;
131  default:
132  props.push_back( Prop("DbType", (*i).value()));
133  svc = "DbCnvSvc";
134  break;
135  }
136  break;
137  default:
138  props.push_back( Prop((*i).tag(), (*i).value()));
139  break;
140  }
141  }
142  if ( 0 != typ ) {
143  IConversionSvc* pSvc = 0;
144  status = createService(name()+'.'+logname, svc, props, pSvc);
145  if ( status.isSuccess() ) {
146  status = attachTuple(filename,logname,typ,pSvc->repSvcType());
147  if ( status.isSuccess() ) {
149  return StatusCode::SUCCESS;
150  }
151  }
152  }
153  }
154  }
155  log << MSG::ERROR << "Cannot add " << ident << " invalid filename!" << endmsg;
156  return StatusCode::FAILURE;
157 }
158 
161  const std::string& typ,
162  const std::vector<Prop>& props,
163  IConversionSvc*& pSvc) {
164  using Gaudi::Utils::TypeNameString;
166 
167  // TagCollectionSvc has to directly create a ConversionSvc to manage it directly.
168  StatusCode status = NO_INTERFACE;
169  if ( mgr.isValid() ) {
170 
171  SmartIF<IService> &isvc = mgr->createService(TypeNameString(nam, typ));
172  if (isvc.isValid()) {
173  status = isvc->queryInterface(IConversionSvc::interfaceID(), (void**)&pSvc);
174  if ( status.isSuccess() ) {
175  SmartIF<IProperty> iprop(isvc);
176  status = NO_INTERFACE;
177  if ( iprop.isValid( ) ) {
178  for ( std::vector<Prop>::const_iterator j = props.begin(); j != props.end(); j++) {
179  iprop->setProperty(StringProperty((*j).first, (*j).second)).ignore();
180  }
181  // NTupleSvc has to directly create a ConversionSvc to manage it directly.
182  status = isvc->sysInitialize();
183  if ( status.isSuccess() ) {
184  status = pSvc->setDataProvider(this);
185  if ( status.isSuccess() ) {
186  return status;
187  }
188  }
189  }
190  pSvc->release();
191  }
192  }
193  }
194  pSvc = 0;
195  return status;
196 }

Generated at Wed Mar 20 2013 17:59:40 for Gaudi Framework, version v23r7 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004