![]() |
|
|
Generated: 8 Jan 2009 |
#include <GaudiKernel/DataStreamTool.h>


Definition at line 29 of file DataStreamTool.h.
Public Types | |
| typedef std::vector < EventSelectorDataStream * > | Streams |
| typedef std::vector < StringProperty > | Properties |
Public Member Functions | |
| DataStreamTool (const std::string &type, const std::string &name, const IInterface *parent) | |
| Standard constructor. | |
| virtual | ~DataStreamTool () |
| Destructor. | |
| virtual StatusCode | initialize () |
| Initialization (from CONFIGURED to INITIALIZED). | |
| virtual StatusCode | addStream (const std::string &) |
| virtual StatusCode | addStreams (const StreamSpecs &) |
| virtual StatusCode | eraseStream (const std::string &) |
| virtual StatusCode | finalize () |
| Finalize (from INITIALIZED to CONFIGURED). | |
| virtual StatusCode | initializeStream (EventSelectorDataStream *) |
| Initialize newly opened stream. | |
| virtual StatusCode | finalizeStream (EventSelectorDataStream *) |
| Finalize no longer needed stream. | |
| virtual StatusCode | getNextStream (const EventSelectorDataStream *&, size_type &) |
| virtual StatusCode | getPreviousStream (const EventSelectorDataStream *&, size_type &) |
| virtual Streams & | getStreams () |
| virtual EventSelectorDataStream * | lastStream () |
| virtual Streams::iterator | beginOfStreams () |
| virtual Streams::iterator | endOfStreams () |
| virtual EventSelectorDataStream * | getStream (const std::string &) |
| Retrieve stream by name. | |
| virtual EventSelectorDataStream * | getStream (size_type) |
| virtual size_type | size () |
| virtual StatusCode | clear () |
Protected Member Functions | |
| virtual StatusCode | createSelector (const std::string &, const std::string &, IEvtSelector *&) |
| virtual StatusCode | createStream (const std::string &, const std::string &, EventSelectorDataStream *&) |
| StatusCode | connectStream (EventSelectorDataStream *) |
| Connect single stream by reference. | |
| StatusCode | connectStream (const std::string &) |
| Connect single stream by name. | |
| Streams::iterator | getStreamIterator (const std::string &) |
Protected Attributes | |
| size_type | m_streamID |
| size_type | m_streamCount |
| Streams | m_streams |
| StreamSpecs | m_streamSpecs |
| IIncidentSvc * | m_incidentSvc |
| Reference to the indicent service. | |
| bool | m_reconfigure |
| typedef std::vector<EventSelectorDataStream*> DataStreamTool::Streams |
Definition at line 32 of file DataStreamTool.h.
| typedef std::vector<StringProperty> DataStreamTool::Properties |
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.
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.
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 & | input | ) | [virtual] |
Implements IDataStreamTool.
Definition at line 74 of file DataStreamTool.cpp.
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 & | inputs | ) | [virtual] |
Implements IDataStreamTool.
Reimplemented in GFALDataStreamTool.
Definition at line 110 of file DataStreamTool.cpp.
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 & | info | ) | [virtual] |
Implements IDataStreamTool.
Definition at line 204 of file DataStreamTool.cpp.
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.
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 * | s | ) | [virtual] |
Initialize newly opened stream.
Implements IDataStreamTool.
Definition at line 141 of file DataStreamTool.cpp.
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 * | s | ) | [virtual] |
Finalize no longer needed stream.
Implements IDataStreamTool.
Definition at line 182 of file DataStreamTool.cpp.
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 *& | esds, | |
| size_type & | dsid | |||
| ) | [virtual] |
Reimplemented in GFALDataStreamTool.
Definition at line 330 of file DataStreamTool.cpp.
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 *& | esds, | |
| size_type & | dsid | |||
| ) | [virtual] |
Definition at line 343 of file DataStreamTool.cpp.
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.
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] |
| virtual Streams::iterator DataStreamTool::endOfStreams | ( | ) | [inline, virtual] |
| EventSelectorDataStream * DataStreamTool::getStream | ( | const std::string & | info | ) | [virtual] |
Retrieve stream by name.
Implements IDataStreamTool.
Definition at line 225 of file DataStreamTool.cpp.
00225 { 00226 Streams::iterator i = getStreamIterator(info); 00227 if ( m_streams.end() == i ) return NULL; 00228 return *i; 00229 }
| EventSelectorDataStream * DataStreamTool::getStream | ( | size_type | pos | ) | [virtual] |
Definition at line 240 of file DataStreamTool.cpp.
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 | ( | void | ) | [inline, virtual] |
Implements IDataStreamTool.
Definition at line 75 of file DataStreamTool.h.
00075 { return m_streams.size(); };
| StatusCode DataStreamTool::clear | ( | void | ) | [virtual] |
Implements IDataStreamTool.
Definition at line 257 of file DataStreamTool.cpp.
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 & | nam, | |
| const std::string & | typ, | |||
| IEvtSelector *& | sel | |||
| ) | [protected, virtual] |
Implements IDataStreamTool.
Definition at line 167 of file DataStreamTool.cpp.
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 & | nam, | |
| const std::string & | info, | |||
| EventSelectorDataStream *& | stream | |||
| ) | [protected, virtual] |
Implements IDataStreamTool.
Definition at line 217 of file DataStreamTool.cpp.
00218 { 00219 stream = new EventSelectorDataStream(nam, info, serviceLocator()); 00220 00221 return StatusCode::SUCCESS; 00222 }
| StatusCode DataStreamTool::connectStream | ( | EventSelectorDataStream * | s | ) | [protected] |
Connect single stream by reference.
Definition at line 290 of file DataStreamTool.cpp.
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 & | info | ) | [protected] |
Connect single stream by name.
Definition at line 303 of file DataStreamTool.cpp.
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 & | info | ) | [protected] |
Definition at line 231 of file DataStreamTool.cpp.
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.
size_type DataStreamTool::m_streamCount [protected] |
Definition at line 94 of file DataStreamTool.h.
Streams DataStreamTool::m_streams [protected] |
Definition at line 96 of file DataStreamTool.h.
StreamSpecs DataStreamTool::m_streamSpecs [protected] |
Definition at line 98 of file DataStreamTool.h.
IIncidentSvc* DataStreamTool::m_incidentSvc [protected] |
bool DataStreamTool::m_reconfigure [protected] |
Definition at line 103 of file DataStreamTool.h.