Gaudi Framework, version v23r9

Home   Generated: Thu Jul 18 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TagCollectionStream.cpp
Go to the documentation of this file.
1 // $Id: TagCollectionStream.cpp,v 1.2 2006/09/18 16:06:52 hmd Exp $
2 #define GAUDISVC_PERSISTENCYSVC_OUTPUTSTREAM_CPP
3 
4 // Framework include files
5 #include "GaudiKernel/SmartIF.h"
14 #include "TagCollectionStream.h"
15 
16 // Define the algorithm factory for the standard output data writer
18 
19 static const char SEPARATOR = IDataProviderSvc::SEPARATOR;
20 
21 // Standard Constructor
23  : OutputStream(nam, pSvc), m_addrColumn(0),
24  m_isTopLeaf(false), m_collectionSvc(0)
25 {
26  declareProperty("AddressLeaf", m_addrLeaf = "/Event" );
27  declareProperty("AddressColumn", m_addrColName = "Address");
28  declareProperty("TagCollectionSvc", m_collSvcName = "NTupleSvc");
29  declareProperty("ObjectsFirst", m_objectsFirst = true);
30  declareProperty("Collection", m_tagName );
31  m_addr = new GenericAddress();
32 }
33 
34 // Standard Destructor
36  delete m_addr;
37 }
38 
39 // Connect address column, if not already connected
41  MsgStream log(msgSvc(), name());
43  if ( nt ) {
45  if ( 0 == m_addrColumn ) {
46  StatusCode sc = nt->addItem (m_addrColName,m_item);
47  if ( sc.isSuccess() ) {
48  m_addrColumn = m_item.operator->();
49  return sc;
50  }
51  log << MSG::ERROR << "Failed to add the address column:"
52  << m_addrColName << " to the tag collection " << m_tagName
53  << endmsg;
54  return sc;
55  }
56  return StatusCode::SUCCESS;
57  }
58  log << MSG::ERROR << "Failed to connect to the tag collection "
59  << m_tagName << endmsg;
60  return StatusCode::FAILURE;
61 }
62 
63 // initialize data writer
65  std::string log_node, log_file, logical_name;
67  if ( sc.isSuccess() ) {
68  Tokenizer tok(true);
69  tok.analyse(m_output, " ", "", "", "=", "'", "'");
70  m_output = "";
71  for(Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); ++i) {
72  const std::string& tag = (*i).tag();
73  const std::string& val = (*i).value();
74  switch( ::toupper(tag[0]) ) {
75  case 'C':
76  m_tagName = val;
77  break;
78  case 'A':
79  m_addrLeaf = val;
80  break;
81  default:
82  m_output += tag + "='" + val + "' ";
83  break;
84  }
85  }
87  log_node = m_tagName.substr(idx,m_tagName.find(SEPARATOR,idx+1));
88  log_file = log_node + " " + m_output + " SHARED='YES'";
89  }
90  m_addrColumn = 0; // reset pointer to item column
91  sc = OutputStream::initialize(); // Now initialize the base class
92  if ( sc.isSuccess() ) {
94  if ( src_mgr.isValid() ) {
96  if ( data_mgr.isValid() ) {
97  logical_name = data_mgr->rootName();
98  logical_name += SEPARATOR;
99  logical_name += log_node;
100  m_topLeafName = m_addrLeaf.substr(0,m_addrLeaf.find(SEPARATOR,m_addrLeaf[0]=='/' ? 1 : 0));
102  if ( src_mgr->isConnected(logical_name) ) {
103  return sc;
104  }
105  sc = src_mgr->connect(log_file);
106  if ( sc.isSuccess() ) {
107  return sc;
108  }
109  }
110  }
111  }
112  MsgStream log(msgSvc(), name());
113  log << MSG::ERROR << "Failed to initialize TagCollection Stream." << endmsg;
114  return StatusCode::FAILURE;
115 }
116 
117 // terminate data writer
119  MsgStream log(msgSvc(), name());
122  m_collectionSvc = 0;
123  m_addrColumn = 0;
124  return status;
125 }
126 
127 // Write tuple data
130  if ( !sc.isSuccess() ) {
131  MsgStream log(msgSvc(), name());
132  log << MSG::ERROR << "Failed to write tag collection " << m_tagName << ". "
133  << "[Tuple write error]" << endmsg;
134  }
135  return sc;
136 }
137 
138 // Write data objects
141  if ( !sc.isSuccess() ) {
142  MsgStream log(msgSvc(), name());
143  log << MSG::ERROR << "Failed to write tag collection " << m_tagName << ". "
144  << "[Object write error]" << endmsg;
145  }
146  return sc;
147 }
148 
149 // Write full event record
151  if ( writeTuple().isSuccess() ) {
153  }
154  return StatusCode::FAILURE;
155 }
156 
157 // Work entry point
160  if ( status.isSuccess() ) {
162  if ( status.isSuccess() ) {
163  if ( !m_addrColName.empty() ) {
165  if ( top != 0 ) {
166  IOpaqueAddress* pA = top->registry()->address();
167  if ( pA != 0 ) {
169  unsigned long* ipar = (unsigned long*)m_addr->ipar();
170  m_addr->setClID(pA->clID());
171  m_addr->setSvcType(pA->svcType());
172  par[0] = pA->par()[0];
173  par[1] = pA->par()[1];
174  ipar[0] = pA->ipar()[0];
175  ipar[1] = pA->ipar()[1];
177  if ( m_isTopLeaf ) {
178  return writeRecord();
179  }
180  // Handle redirection mode. Normal tag collection mode
181  // is the same like leaving this out....
183  if ( 0 != leaf ) {
184  IOpaqueAddress* redir = leaf->registry()->address();
185  if ( redir ) {
186  par[0] = redir->par()[0];
187  ipar[0] = ~0x0;
188  ipar[1] = redir->ipar()[1];
189  return writeRecord();
190  }
191  MsgStream log3(msgSvc(), name());
192  log3 << MSG::ERROR << "Failed to write tag collection " << m_tagName << ". "
193  << m_addrLeaf << "'s address not found." << endmsg;
194  return StatusCode::FAILURE;
195  }
196  MsgStream log2(msgSvc(), name());
197  log2 << MSG::ERROR << "Failed to write tag collection " << m_tagName << ". "
198  << m_addrLeaf << " not found." << endmsg;
199  return StatusCode::FAILURE;
200  }
201  MsgStream log1(msgSvc(), name());
202  log1 << MSG::ERROR << "Failed to write tag collection " << m_tagName << ". "
203  << m_topLeafName << "'s address not found." << endmsg;
204  return StatusCode::FAILURE;
205  }
206  MsgStream log0(msgSvc(), name());
207  log0 << MSG::ERROR << "Failed to write tag collection " << m_tagName << ". "
208  << m_topLeafName << " not found." << endmsg;
209  return StatusCode::FAILURE;
210  }
211  }
212  }
213  return status;
214 }

Generated at Thu Jul 18 2013 12:18:01 for Gaudi Framework, version v23r9 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004