| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# DataStreamTool Class Reference

`#include <GaudiKernel/DataStreamTool.h>`

Inheritance diagram for DataStreamTool:
[legend]
Collaboration diagram for DataStreamTool:
[legend]

List of all members.

## 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 ()
virtual StatusCode | addStream (const std::string &)
virtual StatusCode | addStreams (const StreamSpecs &)
virtual StatusCode | eraseStream (const std::string &)
virtual StatusCode | finalize ()
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
SmartIF< IIncidentSvc > | m_incidentSvc
| Reference to the incident service.
bool | m_reconfigure
## Private Member Functions
| DataStreamTool (const DataStreamTool &)
| Fake copy constructor (never implemented).
DataStreamTool & | operator= (const DataStreamTool &)
| Fake assignment operator (never implemented).

## Detailed Description

Author:
  Andres Felipe Osorio Oliveros

  Marco Clemencic

Date:
  2006-09-21

Definition at line 29 of file DataStreamTool.h.

## Member Typedef Documentation

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.

## Constructor & Destructor Documentation

DataStreamTool::DataStreamTool | ( | const std::string & | type,
|  | const std::string & | name,
|  | const IInterface * | parent |
| ) |  |  |

Standard constructor.

Definition at line 34 of file DataStreamTool.cpp.

    00037   : base_class ( 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]`

Destructor.

Definition at line 49 of file DataStreamTool.cpp.

    00049                                 {
    00050 }

DataStreamTool::DataStreamTool | ( | const DataStreamTool & |  | ) | `[private]`

Fake copy constructor (never implemented).

## Member Function Documentation

StatusCode DataStreamTool::initialize | ( |  | ) | `[virtual]`

Reimplemented from AlgTool.

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." << endmsg;
    00060     return status;
    00061   }
    00062
    00063   // Get the references to the services that are needed by the ApplicationMgr itself
    00064   m_incidentSvc = serviceLocator()->service("IncidentSvc");
    00065   if( !m_incidentSvc.isValid() )  {
    00066     logger << MSG::FATAL << "Error retrieving IncidentSvc." << endmsg;
    00067     return StatusCode::FAILURE;
    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 << endmsg;
    00101     }
    00102     log << MSG::ERROR << "Error connecting/creating Stream: " << input << endmsg;
    00103     status = StatusCode::FAILURE;
    00104   }
    00105
    00106   return status;
    00107
    00108 }

StatusCode DataStreamTool::addStreams | ( | const StreamSpecs & | inputs | ) | `[virtual]`

Implements IDataStreamTool.

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 194 of file DataStreamTool.cpp.

    00194                                                                  {
    00195
    00196   Streams::iterator i = getStreamIterator(info);
    00197
    00198   if ( m_streams.end() != i )   {
    00199     (*i)->release();
    00200     m_streams.erase(i);
    00201     return StatusCode::SUCCESS;
    00202   }
    00203
    00204   return StatusCode::FAILURE;
    00205 }

StatusCode DataStreamTool::finalize | ( |  | ) | `[virtual]`

Reimplemented from AlgTool.

Definition at line 124 of file DataStreamTool.cpp.

    00124                                     {
    00125   clear().ignore();
    00126   m_incidentSvc = 0; // release
    00127
    00128   return AlgTool::finalize();
    00129 }

StatusCode DataStreamTool::initializeStream | ( | EventSelectorDataStream * | s | ) | `[virtual]`

Initialize newly opened stream.

Implements IDataStreamTool.

Definition at line 131 of file DataStreamTool.cpp.

    00131                                                                         {
    00132   IEvtSelector* sel = 0;
    00133   StatusCode status = s->initialize();
    00134   if ( status.isSuccess() )   {
    00135     status = createSelector(s->name(), s->selectorType(), sel);
    00136     if ( status.isSuccess() )   {
    00137       SmartIF<IProperty> prop(sel); //Att: IProperty, IService used to point to EventSelector
    00138       SmartIF<IService>  isvc(sel);
    00139       s->setSelector(sel);
    00140       sel->release();  // No need of this interface anymore, it is passed to the stream
    00141       if ( prop.isValid( ) && isvc.isValid( ) )   {
    00142         const Properties& p = s->properties();
    00143         for(Properties::const_iterator i=p.begin(); i!=p.end(); i++)   {
    00144           prop->setProperty((*i)).ignore();
    00145         }
    00146         int output_level = this->outputLevel();
    00147         prop->setProperty(IntegerProperty("OutputLevel",output_level)).ignore();
    00148         // FIXME: (MCl) Why do we have to initialize the selector here?
    00149         return isvc->sysInitialize();
    00150       }
    00151     }
    00152   }
    00153   return StatusCode::FAILURE;
    00154 }

StatusCode DataStreamTool::finalizeStream | ( | EventSelectorDataStream * | s | ) | `[virtual]`

Finalize no longer needed stream.

Implements IDataStreamTool.

Definition at line 172 of file DataStreamTool.cpp.

    00172                                                                       {
    00173   if ( s )    {
    00174     IEvtSelector* sel = const_cast<IEvtSelector*>(s->selector());
    00175     if ( sel )    {
    00176       SmartIF<IService> isvc(sel);
    00177       if ( isvc.isValid() )   {
    00178         isvc->finalize().ignore();
    00179         s->finalize().ignore();
    00180         // Fire EndStream "Incident"
    00181         m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndStream));
    00182         return StatusCode::SUCCESS;
    00183       }
    00184       // Failed to get service interface of sub-event selector
    00185       return StatusCode::FAILURE;
    00186     }
    00187     // No selector (yet) attached - no need to finalize it!
    00188     return StatusCode::SUCCESS;
    00189   }
    00190   return StatusCode::FAILURE;
    00191 }

StatusCode DataStreamTool::getNextStream | ( | const EventSelectorDataStream *& | esds,
|  | size_type & | dsid |
| ) |  |  | `[virtual]`

Definition at line 320 of file DataStreamTool.cpp.

    00321 {
    00322
    00323   EventSelectorDataStream * nextStream = getStream(dsid);
    00324   if ( NULL == nextStream ) return StatusCode::FAILURE; //<-end of streams reached
    00325
    00326   esds = nextStream;
    00327   ++m_streamID;
    00328
    00329   return StatusCode::SUCCESS;
    00330
    00331 }

StatusCode DataStreamTool::getPreviousStream | ( | const EventSelectorDataStream *& | esds,
|  | size_type & | dsid |
| ) |  |  | `[virtual]`

Definition at line 333 of file DataStreamTool.cpp.

    00334 {
    00335
    00336   EventSelectorDataStream * previousStream = getStream(dsid);
    00337   if (  NULL == previousStream ) return StatusCode::FAILURE; //<-begin of streams reached
    00338
    00339   esds = previousStream;
    00340   --m_streamID;
    00341
    00342   return StatusCode::SUCCESS;
    00343
    00344 }

virtual Streams& DataStreamTool::getStreams | ( |  | ) | `[inline, virtual]`

Definition at line 62 of file DataStreamTool.h.

    00062 { return m_streams; };

EventSelectorDataStream * DataStreamTool::lastStream | ( |  | ) | `[virtual]`

Implements IDataStreamTool.

Definition at line 237 of file DataStreamTool.cpp.

    00238 {
    00239   if (m_streams.size() > 1 )
    00240     return *(--m_streams.end());
    00241   else return *m_streams.begin();
    00242
    00243 }

virtual Streams::iterator DataStreamTool::beginOfStreams | ( |  | ) | `[inline, virtual]`

Definition at line 66 of file DataStreamTool.h.

    00066 {return m_streams.begin(); };

virtual Streams::iterator DataStreamTool::endOfStreams | ( |  | ) | `[inline, virtual]`

Definition at line 68 of file DataStreamTool.h.

    00068 {return m_streams.end(); };

EventSelectorDataStream * DataStreamTool::getStream | ( | const std::string & | info | ) | `[virtual]`

Retrieve stream by name.

Implements IDataStreamTool.

Definition at line 215 of file DataStreamTool.cpp.

    00215                                                                            {
    00216   Streams::iterator i = getStreamIterator(info);
    00217   if ( m_streams.end() == i ) return NULL;
    00218   return *i;
    00219 }

EventSelectorDataStream * DataStreamTool::getStream | ( | size_type | pos | ) | `[virtual]`

Definition at line 230 of file DataStreamTool.cpp.

    00230                                                                    {
    00231   if ( (pos >= 0) && ((size_t)pos < m_streams.size()) ) // pos has to point inside the vector
    00232     return m_streams[pos];
    00233   else
    00234     return 0;
    00235 }

virtual size_type DataStreamTool::size | ( |  | ) | `[inline, virtual]`

Implements IDataStreamTool.

Definition at line 75 of file DataStreamTool.h.

    00075 { return m_streams.size(); };

StatusCode DataStreamTool::clear | ( |  | ) | `[virtual]`

Implements IDataStreamTool.

Definition at line 247 of file DataStreamTool.cpp.

    00248 {
    00249
    00250   StatusCode iret, status = StatusCode::SUCCESS;
    00251   iret.ignore();
    00252
    00253   MsgStream log(msgSvc(), name());
    00254
    00255   // disconnect the streams
    00256   for ( StreamSpecs::const_iterator il = m_streamSpecs.begin(); il != m_streamSpecs.end(); il++ ) {
    00257     EventSelectorDataStream* s = getStream(*il);
    00258     if ( NULL != s )   {
    00259       if ( s->isInitialized() )    {
    00260         iret = finalizeStream(s);
    00261         if ( !iret.isSuccess() )  {
    00262           log << MSG::ERROR << "Error finalizing Stream" << *il << endmsg;
    00263           status = iret;
    00264         }
    00265       }
    00266       iret = eraseStream( *il );
    00267       if ( !iret.isSuccess() )    {
    00268         log << MSG::ERROR << "Error diconnecting Stream" << *il << endmsg;
    00269         status = iret;
    00270       }
    00271     }
    00272   }
    00273
    00274   m_streamSpecs.clear();
    00275
    00276   return status;
    00277 }

StatusCode DataStreamTool::createSelector | ( | const std::string & | nam,
|  | const std::string & | typ,
|  | IEvtSelector *& | sel |
| ) |  |  | `[protected, virtual]`

Implements IDataStreamTool.

Definition at line 157 of file DataStreamTool.cpp.

    00157                                                                                                         {
    00158   MsgStream log(msgSvc(), name());
    00159   IService* isvc = ROOT::Reflex::PluginService::Create<IService*>(typ, nam, serviceLocator());
    00160   if ( isvc ) {
    00161     StatusCode status = isvc->queryInterface(IEvtSelector::interfaceID(), (void**)&sel);
    00162     if ( status.isSuccess() ) {
    00163       return status;
    00164     }
    00165     sel = 0;
    00166     isvc->release();
    00167   }
    00168   return StatusCode::FAILURE;
    00169 }

StatusCode DataStreamTool::createStream | ( | const std::string & | nam,
|  | const std::string & | info,
|  | EventSelectorDataStream *& | stream |
| ) |  |  | `[protected, virtual]`

Implements IDataStreamTool.

Definition at line 207 of file DataStreamTool.cpp.

    00208                                                                            {
    00209   stream = new EventSelectorDataStream(nam, info, serviceLocator());
    00210
    00211   return StatusCode::SUCCESS;
    00212 }

StatusCode DataStreamTool::connectStream | ( | EventSelectorDataStream * | s | ) | `[protected]`

Connect single stream by reference.

Definition at line 280 of file DataStreamTool.cpp.

    00281 {
    00282
    00283   if ( 0 != s )   {
    00284     s->addRef();
    00285     m_streams.push_back(s);
    00286     return StatusCode::SUCCESS;
    00287   }
    00288
    00289   return StatusCode::FAILURE;
    00290
    00291 }

StatusCode DataStreamTool::connectStream | ( | const std::string & | info | ) | `[protected]`

Connect single stream by name.

Definition at line 293 of file DataStreamTool.cpp.

    00294 {
    00295
    00296   if ( NULL != getStream(info) )   {
    00297     MsgStream log(msgSvc(), name());
    00298     log << MSG::WARNING << "Input stream " << info << "already in use" << endmsg;
    00299   }
    00300   char txt[32];
    00301   std::string nam = name() + "_" + ::_itoa(++m_streamCount, txt, 10);
    00302   EventSelectorDataStream* s = 0;
    00303   StatusCode status = createStream(nam, info, s);
    00304   if ( status.isSuccess() )   {
    00305     return connectStream(s);
    00306   }
    00307   s->release();
    00308   return status;
    00309
    00310
    00311 }

DataStreamTool::Streams::iterator DataStreamTool::getStreamIterator | ( | const std::string & | info | ) | `[protected]`

Definition at line 221 of file DataStreamTool.cpp.

    00221                                                                                         {
    00222   for ( Streams::iterator i = m_streams.begin(); i != m_streams.end(); i++ )    {
    00223     if ( (*i)->definition() == info )    {
    00224       return i;
    00225     }
    00226   }
    00227   return m_streams.end();
    00228 }

DataStreamTool& DataStreamTool::operator= | ( | const DataStreamTool & |  | ) | `[private]`

Fake assignment operator (never implemented).

## Member Data Documentation

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.

SmartIF<IIncidentSvc> DataStreamTool::m_incidentSvc`[protected]`

Reference to the incident service.

Definition at line 101 of file DataStreamTool.h.

bool DataStreamTool::m_reconfigure`[protected]`

Definition at line 103 of file DataStreamTool.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r11/GaudiKernel/GaudiKernel/DataStreamTool.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r11/GaudiKernel/src/Lib/DataStreamTool.cpp