![]() |
|
|
Generated: 18 Jul 2008 |
#include <GaudiKernel/DataStreamTool.h>
Inheritance diagram for DataStreamTool:


Definition at line 29 of file DataStreamTool.h.
Definition at line 32 of file DataStreamTool.h.
Definition at line 33 of file DataStreamTool.h.
| DataStreamTool::DataStreamTool | ( | const std::string & | type, | |
| const std::string & | name, | |||
| const IInterface * | parent | |||
| ) |
Standard constructor.
Definition at line 34 of file DataStreamTool.cpp.
References m_incidentSvc, m_streamCount, and m_streamID.
00037 : AlgTool ( type, name , parent ) 00038 { 00039 declareInterface<IDataStreamTool>(this); 00040 00041 m_incidentSvc = 0; 00042 m_streamCount = 0; 00043 m_streamID = 0; 00044 00045 }
| DataStreamTool::~DataStreamTool | ( | ) | [virtual] |
| StatusCode DataStreamTool::initialize | ( | ) | [virtual] |
Initialization (from CONFIGURED to INITIALIZED).
Reimplemented from AlgTool.
Reimplemented in GFALDataStreamTool.
Definition at line 53 of file DataStreamTool.cpp.
References endreq(), MSG::FATAL, AlgTool::initialize(), StatusCode::isSuccess(), apmon_utils::logger(), m_incidentSvc, AlgTool::msgSvc(), AlgTool::name(), ISvcLocator::service(), AlgTool::serviceLocator(), and StatusCode::SUCCESS.
Referenced by GFALDataStreamTool::initialize().
00053 { 00054 00055 MsgStream logger(msgSvc(), name()); 00056 00057 StatusCode status = AlgTool::initialize(); 00058 if( !status.isSuccess() ) { 00059 logger << MSG::FATAL << "Error. Cannot initialize base class." << endreq; 00060 return status; 00061 } 00062 00063 // Get the references to the services that are needed by the ApplicationMgr itself 00064 status = serviceLocator()->service("IncidentSvc", m_incidentSvc, true); 00065 if( !status.isSuccess() ) { 00066 logger << MSG::FATAL << "Error retrieving IncidentSvc." << endreq; 00067 return status; 00068 } 00069 00070 return StatusCode::SUCCESS; 00071 00072 }
| StatusCode DataStreamTool::addStream | ( | const std::string & | ) | [virtual] |
Implements IDataStreamTool.
Definition at line 74 of file DataStreamTool.cpp.
References _itoa(), createStream(), endmsg(), endreq(), MSG::ERROR, StatusCode::FAILURE, getStream(), StatusCode::isSuccess(), m_streamCount, m_streams, m_streamSpecs, AlgTool::msgSvc(), AlgTool::name(), std::vector< _Tp, _Alloc >::push_back(), Gaudi::Units::s, StatusCode::SUCCESS, and MSG::WARNING.
Referenced by addStreams().
00074 { 00075 00076 if ( NULL != getStream(input) ) { 00077 MsgStream log(msgSvc(), name()); 00078 log << MSG::WARNING << "Input stream " << input << "already in use" << endmsg; 00079 } 00080 00081 m_streamSpecs.push_back(input); 00082 00083 char txt[32]; 00084 00085 std::string strname = name() + "_" + ::_itoa(++m_streamCount, txt, 10); 00086 00087 EventSelectorDataStream* s = 0; 00088 00089 StatusCode status = createStream(strname, input , s ); 00090 00091 if( status.isSuccess() && 0 != s ) { 00092 s->addRef(); 00093 m_streams.push_back(s); 00094 status = StatusCode::SUCCESS; 00095 } 00096 else { 00097 MsgStream log(msgSvc(), name()); 00098 if (s) { 00099 s->release(); 00100 log << MSG::ERROR << "Error connecting/creating Stream: " << s << endreq; 00101 } 00102 log << MSG::ERROR << "Error connecting/creating Stream: " << input << endreq; 00103 status = StatusCode::FAILURE; 00104 } 00105 00106 return status; 00107 00108 }
| StatusCode DataStreamTool::addStreams | ( | const StreamSpecs & | ) | [virtual] |
Reimplemented in GFALDataStreamTool.
Definition at line 110 of file DataStreamTool.cpp.
References addStream(), StatusCode::isSuccess(), and StatusCode::SUCCESS.
Referenced by GFALDataStreamTool::addStreams().
00110 { 00111 00112 StatusCode status = StatusCode::SUCCESS; 00113 00114 for ( StreamSpecs::const_iterator itr = inputs.begin(); itr != inputs.end() && status.isSuccess(); ++itr ) { 00115 00116 status = addStream(*itr); 00117 00118 } 00119 00120 return status; 00121 00122 }
| StatusCode DataStreamTool::eraseStream | ( | const std::string & | ) | [virtual] |
Implements IDataStreamTool.
Definition at line 204 of file DataStreamTool.cpp.
References std::vector< _Tp, _Alloc >::end(), std::vector< _Tp, _Alloc >::erase(), StatusCode::FAILURE, getStreamIterator(), m_streams, and StatusCode::SUCCESS.
Referenced by clear(), and GFALDataStreamTool::finalize().
00204 { 00205 00206 Streams::iterator i = getStreamIterator(info); 00207 00208 if ( m_streams.end() != i ) { 00209 (*i)->release(); 00210 m_streams.erase(i); 00211 return StatusCode::SUCCESS; 00212 } 00213 00214 return StatusCode::FAILURE; 00215 }
| StatusCode DataStreamTool::finalize | ( | ) | [virtual] |
Finalize (from INITIALIZED to CONFIGURED).
Reimplemented from AlgTool.
Reimplemented in GFALDataStreamTool.
Definition at line 124 of file DataStreamTool.cpp.
References clear(), AlgTool::finalize(), StatusCode::ignore(), m_incidentSvc, IInterface::release(), and StatusCode::SUCCESS.
Referenced by GFALDataStreamTool::finalize().
00124 { 00125 00126 StatusCode status = StatusCode::SUCCESS; 00127 00128 clear().ignore(); 00129 00130 if( m_incidentSvc ) { 00131 m_incidentSvc->release(); 00132 m_incidentSvc = 0 ; 00133 } 00134 00135 status = AlgTool::finalize(); 00136 00137 return status; 00138 00139 }
| StatusCode DataStreamTool::initializeStream | ( | EventSelectorDataStream * | ) | [virtual] |
Initialize newly opened stream.
Implements IDataStreamTool.
Definition at line 141 of file DataStreamTool.cpp.
References createSelector(), StatusCode::FAILURE, IID_IProperty, IID_IService, StatusCode::isSuccess(), SmartIFBase< TYPE >::isValid(), AlgTool::outputLevel(), IInterface::release(), and Gaudi::Units::s.
00141 { 00142 IEvtSelector* sel = 0; 00143 StatusCode status = s->initialize(); 00144 if ( status.isSuccess() ) { 00145 status = createSelector(s->name(), s->selectorType(), sel); 00146 if ( status.isSuccess() ) { 00147 SmartIF<IProperty> prop(IID_IProperty, sel); //Att:IID_IProperty, IID_IService used to point to EventSelector 00148 SmartIF<IService> isvc(IID_IService, sel); 00149 s->setSelector(sel); 00150 sel->release(); // No need of this interface anymore, it is passed to the stream 00151 if ( prop.isValid( ) && isvc.isValid( ) ) { 00152 const Properties& p = s->properties(); 00153 for(Properties::const_iterator i=p.begin(); i!=p.end(); i++) { 00154 prop->setProperty((*i)).ignore(); 00155 } 00156 int output_level = this->outputLevel(); 00157 prop->setProperty(IntegerProperty("OutputLevel",output_level)).ignore(); 00158 // FIXME: (MCl) Why do we have to initialize the selector here? 00159 return isvc->sysInitialize(); 00160 } 00161 } 00162 } 00163 return StatusCode::FAILURE; 00164 }
| StatusCode DataStreamTool::finalizeStream | ( | EventSelectorDataStream * | ) | [virtual] |
Finalize no longer needed stream.
Implements IDataStreamTool.
Definition at line 182 of file DataStreamTool.cpp.
References IncidentType::EndStream, StatusCode::FAILURE, IIncidentSvc::fireIncident(), IID_IService, SmartIFBase< TYPE >::isValid(), m_incidentSvc, AlgTool::name(), Gaudi::Units::s, and StatusCode::SUCCESS.
Referenced by clear(), and GFALDataStreamTool::finalize().
00182 { 00183 if ( s ) { 00184 IEvtSelector* sel = const_cast<IEvtSelector*>(s->selector()); 00185 if ( sel ) { 00186 SmartIF<IService> isvc(IID_IService, sel); 00187 if ( isvc.isValid() ) { 00188 isvc->finalize().ignore(); 00189 s->finalize().ignore(); 00190 // Fire EndStream "Incident" 00191 m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndStream)); 00192 return StatusCode::SUCCESS; 00193 } 00194 // Failed to get service interface of sub-event selector 00195 return StatusCode::FAILURE; 00196 } 00197 // No selector (yet) attached - no need to finalize it! 00198 return StatusCode::SUCCESS; 00199 } 00200 return StatusCode::FAILURE; 00201 }
| StatusCode DataStreamTool::getNextStream | ( | const EventSelectorDataStream *& | , | |
| size_type & | ||||
| ) | [virtual] |
Reimplemented in GFALDataStreamTool.
Definition at line 330 of file DataStreamTool.cpp.
References StatusCode::FAILURE, getStream(), m_streamID, and StatusCode::SUCCESS.
00331 { 00332 00333 EventSelectorDataStream * nextStream = getStream(dsid); 00334 if ( NULL == nextStream ) return StatusCode::FAILURE; //<-end of streams reached 00335 00336 esds = nextStream; 00337 ++m_streamID; 00338 00339 return StatusCode::SUCCESS; 00340 00341 }
| StatusCode DataStreamTool::getPreviousStream | ( | const EventSelectorDataStream *& | , | |
| size_type & | ||||
| ) | [virtual] |
Definition at line 343 of file DataStreamTool.cpp.
References StatusCode::FAILURE, getStream(), m_streamID, and StatusCode::SUCCESS.
00344 { 00345 00346 EventSelectorDataStream * previousStream = getStream(dsid); 00347 if ( NULL == previousStream ) return StatusCode::FAILURE; //<-begin of streams reached 00348 00349 esds = previousStream; 00350 --m_streamID; 00351 00352 return StatusCode::SUCCESS; 00353 00354 }
| virtual Streams& DataStreamTool::getStreams | ( | ) | [inline, virtual] |
| EventSelectorDataStream * DataStreamTool::lastStream | ( | ) | [virtual] |
Implements IDataStreamTool.
Definition at line 247 of file DataStreamTool.cpp.
References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), m_streams, and std::vector< _Tp, _Alloc >::size().
00248 { 00249 if (m_streams.size() > 1 ) 00250 return *(--m_streams.end()); 00251 else return *m_streams.begin(); 00252 00253 }
| virtual Streams::iterator DataStreamTool::beginOfStreams | ( | ) | [inline, virtual] |
Definition at line 66 of file DataStreamTool.h.
References std::vector< _Tp, _Alloc >::begin(), and m_streams.
| virtual Streams::iterator DataStreamTool::endOfStreams | ( | ) | [inline, virtual] |
Definition at line 68 of file DataStreamTool.h.
References std::vector< _Tp, _Alloc >::end(), and m_streams.
| EventSelectorDataStream * DataStreamTool::getStream | ( | const std::string & | ) | [virtual] |
Retrieve stream by name.
Implements IDataStreamTool.
Definition at line 225 of file DataStreamTool.cpp.
References std::vector< _Tp, _Alloc >::end(), getStreamIterator(), and m_streams.
Referenced by addStream(), clear(), connectStream(), GFALDataStreamTool::finalize(), getNextStream(), GFALDataStreamTool::getNextStream(), and getPreviousStream().
00225 { 00226 Streams::iterator i = getStreamIterator(info); 00227 if ( m_streams.end() == i ) return NULL; 00228 return *i; 00229 }
| EventSelectorDataStream * DataStreamTool::getStream | ( | size_type | ) | [virtual] |
Definition at line 240 of file DataStreamTool.cpp.
References m_streams, and std::vector< _Tp, _Alloc >::size().
00240 { 00241 if ( (pos >= 0) && ((size_t)pos < m_streams.size()) ) // pos has to point inside the vector 00242 return m_streams[pos]; 00243 else 00244 return 0; 00245 }
| virtual size_type DataStreamTool::size | ( | ) | [inline, virtual] |
Implements IDataStreamTool.
Definition at line 75 of file DataStreamTool.h.
References m_streams, and std::vector< _Tp, _Alloc >::size().
| StatusCode DataStreamTool::clear | ( | ) | [virtual] |
Implements IDataStreamTool.
Definition at line 257 of file DataStreamTool.cpp.
References endreq(), eraseStream(), MSG::ERROR, finalizeStream(), getStream(), StatusCode::ignore(), StatusCode::isSuccess(), m_streamSpecs, AlgTool::msgSvc(), AlgTool::name(), Gaudi::Units::s, and StatusCode::SUCCESS.
Referenced by finalize().
00258 { 00259 00260 StatusCode iret, status = StatusCode::SUCCESS; 00261 iret.ignore(); 00262 00263 MsgStream log(msgSvc(), name()); 00264 00265 // disconnect the streams 00266 for ( StreamSpecs::const_iterator il = m_streamSpecs.begin(); il != m_streamSpecs.end(); il++ ) { 00267 EventSelectorDataStream* s = getStream(*il); 00268 if ( NULL != s ) { 00269 if ( s->isInitialized() ) { 00270 iret = finalizeStream(s); 00271 if ( !iret.isSuccess() ) { 00272 log << MSG::ERROR << "Error finalizing Stream" << *il << endreq; 00273 status = iret; 00274 } 00275 } 00276 iret = eraseStream( *il ); 00277 if ( !iret.isSuccess() ) { 00278 log << MSG::ERROR << "Error diconnecting Stream" << *il << endreq; 00279 status = iret; 00280 } 00281 } 00282 } 00283 00284 m_streamSpecs.clear(); 00285 00286 return status; 00287 }
| StatusCode DataStreamTool::createSelector | ( | const std::string & | , | |
| const std::string & | , | |||
| IEvtSelector *& | ||||
| ) | [protected, virtual] |
Implements IDataStreamTool.
Definition at line 167 of file DataStreamTool.cpp.
References StatusCode::FAILURE, IID_IEvtSelector, StatusCode::isSuccess(), AlgTool::msgSvc(), AlgTool::name(), IInterface::queryInterface(), IInterface::release(), and AlgTool::serviceLocator().
Referenced by initializeStream().
00167 { 00168 MsgStream log(msgSvc(), name()); 00169 IService* isvc = ROOT::Reflex::PluginService::Create<IService*>(typ, nam, serviceLocator()); 00170 if ( isvc ) { 00171 StatusCode status = isvc->queryInterface(IID_IEvtSelector, (void**)&sel); 00172 if ( status.isSuccess() ) { 00173 return status; 00174 } 00175 sel = 0; 00176 isvc->release(); 00177 } 00178 return StatusCode::FAILURE; 00179 }
| StatusCode DataStreamTool::createStream | ( | const std::string & | , | |
| const std::string & | , | |||
| EventSelectorDataStream *& | ||||
| ) | [protected, virtual] |
Implements IDataStreamTool.
Definition at line 217 of file DataStreamTool.cpp.
References AlgTool::serviceLocator(), and StatusCode::SUCCESS.
Referenced by addStream(), connectStream(), and GFALDataStreamTool::updateStreams().
00218 { 00219 stream = new EventSelectorDataStream(nam, info, serviceLocator()); 00220 00221 return StatusCode::SUCCESS; 00222 }
| StatusCode DataStreamTool::connectStream | ( | EventSelectorDataStream * | ) | [protected] |
Connect single stream by reference.
Definition at line 290 of file DataStreamTool.cpp.
References StatusCode::FAILURE, m_streams, std::vector< _Tp, _Alloc >::push_back(), Gaudi::Units::s, and StatusCode::SUCCESS.
Referenced by connectStream().
00291 { 00292 00293 if ( 0 != s ) { 00294 s->addRef(); 00295 m_streams.push_back(s); 00296 return StatusCode::SUCCESS; 00297 } 00298 00299 return StatusCode::FAILURE; 00300 00301 }
| StatusCode DataStreamTool::connectStream | ( | const std::string & | ) | [protected] |
Connect single stream by name.
Definition at line 303 of file DataStreamTool.cpp.
References _itoa(), connectStream(), createStream(), endmsg(), getStream(), StatusCode::isSuccess(), m_streamCount, AlgTool::msgSvc(), AlgTool::name(), Gaudi::Units::s, and MSG::WARNING.
00304 { 00305 00306 if ( NULL != getStream(info) ) { 00307 MsgStream log(msgSvc(), name()); 00308 log << MSG::WARNING << "Input stream " << info << "already in use" << endmsg; 00309 } 00310 char txt[32]; 00311 std::string nam = name() + "_" + ::_itoa(++m_streamCount, txt, 10); 00312 EventSelectorDataStream* s = 0; 00313 StatusCode status = createStream(nam, info, s); 00314 if ( status.isSuccess() ) { 00315 return connectStream(s); 00316 } 00317 s->release(); 00318 return status; 00319 00320 00321 }
| DataStreamTool::Streams::iterator DataStreamTool::getStreamIterator | ( | const std::string & | ) | [protected] |
Definition at line 231 of file DataStreamTool.cpp.
References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), and m_streams.
Referenced by eraseStream(), getStream(), and GFALDataStreamTool::updateStreams().
00231 { 00232 for ( Streams::iterator i = m_streams.begin(); i != m_streams.end(); i++ ) { 00233 if ( (*i)->definition() == info ) { 00234 return i; 00235 } 00236 } 00237 return m_streams.end(); 00238 }
size_type DataStreamTool::m_streamID [protected] |
Definition at line 92 of file DataStreamTool.h.
Referenced by DataStreamTool(), GFALDataStreamTool::finalize(), getNextStream(), GFALDataStreamTool::getNextStream(), and getPreviousStream().
size_type DataStreamTool::m_streamCount [protected] |
Definition at line 94 of file DataStreamTool.h.
Referenced by addStream(), GFALDataStreamTool::addStreams(), connectStream(), DataStreamTool(), GFALDataStreamTool::initialize(), and GFALDataStreamTool::updateStreams().
Streams DataStreamTool::m_streams [protected] |
Definition at line 96 of file DataStreamTool.h.
Referenced by addStream(), beginOfStreams(), connectStream(), endOfStreams(), eraseStream(), getStream(), getStreamIterator(), getStreams(), lastStream(), size(), and GFALDataStreamTool::updateStreams().
StreamSpecs DataStreamTool::m_streamSpecs [protected] |
Definition at line 98 of file DataStreamTool.h.
Referenced by addStream(), GFALDataStreamTool::addStreams(), clear(), GFALDataStreamTool::finalize(), and GFALDataStreamTool::setBlocks().
IIncidentSvc* DataStreamTool::m_incidentSvc [protected] |
Reference to the indicent service.
Definition at line 101 of file DataStreamTool.h.
Referenced by DataStreamTool(), finalize(), finalizeStream(), and initialize().
bool DataStreamTool::m_reconfigure [protected] |
Definition at line 103 of file DataStreamTool.h.