| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions

# 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<StringProperty> DataStreamTool::Properties

Definition at line 33 of file DataStreamTool.h.

typedef std::vector<EventSelectorDataStream*> DataStreamTool::Streams

Definition at line 32 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 36 of file DataStreamTool.cpp.

      : base_class ( type, name , parent )
    {
      //declareInterface<IDataStreamTool>(this);

      m_incidentSvc       = 0;
      m_streamCount       = 0;
      m_streamID          = 0;

    }

DataStreamTool::~DataStreamTool | ( | ) | `[virtual]`

Destructor.

Definition at line 51 of file DataStreamTool.cpp.

                                    {
    }

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

Fake copy constructor (never implemented).

## Member Function Documentation

StatusCode DataStreamTool::addStream | ( | const std::string & | input ) | `[virtual]`

Implements IDataStreamTool.

Definition at line 76 of file DataStreamTool.cpp.

                                                                {

      if ( NULL != getStream(input) )   {
        MsgStream log(msgSvc(), name());
        log << MSG::WARNING << "Input stream " << input << "already in use" << endmsg;
      }

      m_streamSpecs.push_back(input);

      std::ostringstream strname;
      strname << name() << '_' << ++m_streamCount;

      EventSelectorDataStream* s = 0;

      StatusCode status = createStream(strname.str(), input , s );

      if( status.isSuccess() && 0 != s ) {
        s->addRef();
        m_streams.push_back(s);
        status = StatusCode::SUCCESS;
      }
      else {
        MsgStream log(msgSvc(), name());
        if (s) {
          s->release();
          log << MSG::ERROR << "Error connecting/creating Stream: " << s << endmsg;
        }
        log << MSG::ERROR << "Error connecting/creating Stream: " << input << endmsg;
        status = StatusCode::FAILURE;
      }

      return status;

    }

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

Implements IDataStreamTool.

Definition at line 111 of file DataStreamTool.cpp.

                                                                    {

      StatusCode status = StatusCode::SUCCESS;

      for ( StreamSpecs::const_iterator itr = inputs.begin(); itr != inputs.end() && status.isSuccess(); ++itr )    {

        status = addStream(*itr);

      }

      return status;

    }

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

Definition at line 66 of file DataStreamTool.h.

    {return m_streams.begin(); };

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

Implements IDataStreamTool.

Definition at line 248 of file DataStreamTool.cpp.

    {

      StatusCode iret, status = StatusCode::SUCCESS;
      iret.ignore();

      MsgStream log(msgSvc(), name());

      // disconnect the streams
      for ( StreamSpecs::const_iterator il = m_streamSpecs.begin(); il != m_streamSpecs.end(); il++ ) {
        EventSelectorDataStream* s = getStream(*il);
        if ( NULL != s )   {
          if ( s->isInitialized() )    {
            iret = finalizeStream(s);
            if ( !iret.isSuccess() )  {
              log << MSG::ERROR << "Error finalizing Stream" << *il << endmsg;
              status = iret;
            }
          }
          iret = eraseStream( *il );
          if ( !iret.isSuccess() )    {
            log << MSG::ERROR << "Error diconnecting Stream" << *il << endmsg;
            status = iret;
          }
        }
      }

      m_streamSpecs.clear();

      return status;
    }

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

Connect single stream by reference.

Definition at line 281 of file DataStreamTool.cpp.

    {

      if ( 0 != s )   {
        s->addRef();
        m_streams.push_back(s);
        return StatusCode::SUCCESS;
      }

      return StatusCode::FAILURE;

    }

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

Connect single stream by name.

Definition at line 294 of file DataStreamTool.cpp.

    {

      if ( NULL != getStream(info) )   {
        MsgStream log(msgSvc(), name());
        log << MSG::WARNING << "Input stream " << info << "already in use" << endmsg;
      }
      std::ostringstream nam;
      nam << name() << '_' << ++m_streamCount;
      EventSelectorDataStream* s = 0;
      StatusCode status = createStream(nam.str(), info, s);
      if ( status.isSuccess() )   {
        return connectStream(s);
      }
      s->release();
      return status;

    }

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

Implements IDataStreamTool.

Definition at line 158 of file DataStreamTool.cpp.

                                                                                                            {
      MsgStream log(msgSvc(), name());
      IService* isvc = ROOT::Reflex::PluginService::Create<IService*>(typ, nam, serviceLocator());
      if ( isvc ) {
        StatusCode status = isvc->queryInterface(IEvtSelector::interfaceID(), (void**)&sel);
        if ( status.isSuccess() ) {
          return status;
        }
        sel = 0;
        isvc->release();
      }
      return StatusCode::FAILURE;
    }

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

Implements IDataStreamTool.

Definition at line 208 of file DataStreamTool.cpp.

                                                                               {
      stream = new EventSelectorDataStream(nam, info, serviceLocator());

      return StatusCode::SUCCESS;
    }

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

Definition at line 68 of file DataStreamTool.h.

    {return m_streams.end(); };

StatusCode DataStreamTool::eraseStream | ( | const std::string & | info ) | `[virtual]`

Implements IDataStreamTool.

Definition at line 195 of file DataStreamTool.cpp.

                                                                     {

      Streams::iterator i = getStreamIterator(info);

      if ( m_streams.end() != i )   {
        (*i)->release();
        m_streams.erase(i);
        return StatusCode::SUCCESS;
      }

      return StatusCode::FAILURE;
    }

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

Reimplemented from AlgTool.

Definition at line 125 of file DataStreamTool.cpp.

                                        {
      clear().ignore();
      m_incidentSvc = 0; // release

      return AlgTool::finalize();
    }

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

Finalize no longer needed stream.

Implements IDataStreamTool.

Definition at line 173 of file DataStreamTool.cpp.

                                                                          {
      if ( s )    {
        IEvtSelector* sel = const_cast<IEvtSelector*>(s->selector());
        if ( sel )    {
          SmartIF<IService> isvc(sel);
          if ( isvc.isValid() )   {
            isvc->finalize().ignore();
            s->finalize().ignore();
            // Fire EndStream "Incident"
            m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndStream));
            return StatusCode::SUCCESS;
          }
          // Failed to get service interface of sub-event selector
          return StatusCode::FAILURE;
        }
        // No selector (yet) attached - no need to finalize it!
        return StatusCode::SUCCESS;
      }
      return StatusCode::FAILURE;
    }

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

Implements IDataStreamTool.

Definition at line 321 of file DataStreamTool.cpp.

    {

      EventSelectorDataStream * nextStream = getStream(dsid);
      if ( NULL == nextStream ) return StatusCode::FAILURE; //<-end of streams reached

      esds = nextStream;
      ++m_streamID;

      return StatusCode::SUCCESS;

    }

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

Implements IDataStreamTool.

Definition at line 334 of file DataStreamTool.cpp.

    {

      EventSelectorDataStream * previousStream = getStream(dsid);
      if (  NULL == previousStream ) return StatusCode::FAILURE; //<-begin of streams reached

      esds = previousStream;
      --m_streamID;

      return StatusCode::SUCCESS;

    }

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

Implements IDataStreamTool.

Definition at line 231 of file DataStreamTool.cpp.

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

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

Retrieve stream by name.

Implements IDataStreamTool.

Definition at line 216 of file DataStreamTool.cpp.

                                                                               {
      Streams::iterator i = getStreamIterator(info);
      if ( m_streams.end() == i ) return NULL;
      return *i;
    }

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

Definition at line 222 of file DataStreamTool.cpp.

                                                                                            {
      for ( Streams::iterator i = m_streams.begin(); i != m_streams.end(); i++ )    {
        if ( (*i)->definition() == info )    {
          return i;
        }
      }
      return m_streams.end();
    }

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

Definition at line 62 of file DataStreamTool.h.

    { return m_streams; };

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

Reimplemented from AlgTool.

Definition at line 55 of file DataStreamTool.cpp.

                                          {

      MsgStream logger(msgSvc(), name());

      StatusCode status = AlgTool::initialize();
      if( !status.isSuccess() )  {
        logger << MSG::FATAL << "Error. Cannot initialize base class." << endmsg;
        return status;
      }

      // Get the references to the services that are needed by the ApplicationMgr itself
      m_incidentSvc = serviceLocator()->service("IncidentSvc");
      if( !m_incidentSvc.isValid() )  {
        logger << MSG::FATAL << "Error retrieving IncidentSvc." << endmsg;
        return StatusCode::FAILURE;
      }

      return StatusCode::SUCCESS;

    }

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

Initialize newly opened stream.

Implements IDataStreamTool.

Definition at line 132 of file DataStreamTool.cpp.

                                                                            {
      IEvtSelector* sel = 0;
      StatusCode status = s->initialize();
      if ( status.isSuccess() )   {
        status = createSelector(s->name(), s->selectorType(), sel);
        if ( status.isSuccess() )   {
          SmartIF<IProperty> prop(sel); //Att: IProperty, IService used to point to EventSelector
          SmartIF<IService>  isvc(sel);
          s->setSelector(sel);
          sel->release();  // No need of this interface anymore, it is passed to the stream
          if ( prop.isValid( ) && isvc.isValid( ) )   {
            const Properties& p = s->properties();
            for(Properties::const_iterator i=p.begin(); i!=p.end(); i++)   {
              prop->setProperty((*i)).ignore();
            }
            int output_level = this->outputLevel();
            prop->setProperty(IntegerProperty("OutputLevel",output_level)).ignore();
            // FIXME: (MCl) Why do we have to initialize the selector here?
            return isvc->sysInitialize();
          }
        }
      }
      return StatusCode::FAILURE;
    }

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

Implements IDataStreamTool.

Definition at line 238 of file DataStreamTool.cpp.

    {
      if (m_streams.size() > 1 )
        return *(--m_streams.end());
      else return *m_streams.begin();

    }

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

Fake assignment operator (never implemented).

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

Implements IDataStreamTool.

Definition at line 75 of file DataStreamTool.h.

    { return m_streams.size(); };

## Member Data Documentation

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.

size_type DataStreamTool::m_streamCount`[protected]`

Definition at line 94 of file DataStreamTool.h.

size_type DataStreamTool::m_streamID`[protected]`

Definition at line 92 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.

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

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines