| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

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

# SequentialOutputStream Class Reference

Extension of OutputStream to write run records after last event. More...

`#include <SequentialOutputStream.h>`

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

List of all members.

## Public Member Functions
| SequentialOutputStream (const std::string &nam, ISvcLocator *svc)
| Standard algorithm Constructor.
virtual | ~SequentialOutputStream ()
| Standard Destructor.
virtual StatusCode | execute ()
| Working entry point.
## Protected Member Functions
virtual StatusCode | writeObjects ()
| OutputStream override: Select the different objects and write them to file.
## Private Member Functions
void | makeFilename ()
## Private Attributes
unsigned int | m_eventsPerFile
unsigned int | m_nNumbersAdded
bool | m_numericFilename
unsigned int | m_events
| Number of events written to this output stream.
unsigned int | m_iFile

## Detailed Description

Extension of OutputStream to write run records after last event.

Author:
  M.Frank

Version:
  1.0

Definition at line 13 of file SequentialOutputStream.h.

## Constructor & Destructor Documentation

SequentialOutputStream::SequentialOutputStream | ( | const std::string & | nam,
|  | ISvcLocator * | svc
| ) |  |

Standard algorithm Constructor.

Definition at line 27 of file SequentialOutputStream.cpp.

    : OutputStream( name, svc ), m_events( 0 ), m_iFile( 1 )
    {
       declareProperty( "EventsPerFile", m_eventsPerFile
                        = boost::numeric::bounds< unsigned int>::highest() );
       declareProperty( "NumericFilename", m_numericFilename = false );
       declareProperty( "NumbersAdded", m_nNumbersAdded = 6 );
    }

virtual SequentialOutputStream::~SequentialOutputStream | ( | ) | `[inline, virtual]`

Standard Destructor.

Definition at line 25 of file SequentialOutputStream.h.

    {}

## Member Function Documentation

StatusCode SequentialOutputStream::execute | ( | ) | `[virtual]`

Working entry point.

Reimplemented from OutputStream.

Definition at line 51 of file SequentialOutputStream.cpp.

    {
       // Clear any previously existing item list
       clearSelection();
       // Test whether this event should be output
       if ( isEventAccepted() )  {
          StatusCode sc = writeObjects();
          clearSelection();
          m_events++;
          return sc;
       }
       return StatusCode::SUCCESS;
    }

void SequentialOutputStream::makeFilename | ( | ) | `[private]`

Definition at line 66 of file SequentialOutputStream.cpp.

    {
       if ( m_events % m_eventsPerFile != 0 ) return;

       bf::path outputPath( m_outputName );
       string filename = outputPath.filename();
       bf::path dir = outputPath.parent_path();
       string stem = outputPath.stem();
       string extension = outputPath.extension();

       if ( !dir.empty() ) {
          if ( !bf::exists( dir ) ) {
             stringstream stream;
             stream << "Directory " << dir << " does not exist.";
             throw GaudiException( stream.str(), "error", StatusCode::FAILURE );
          }
       }

       if ( m_numericFilename ) {
          if ( m_events == 0 ) {
             try {
                m_iFile = lexical_cast< unsigned int >( stem );
             } catch( const bad_lexical_cast& /* cast */ ) {
                stringstream stream;
                stream << "Filename " << filename
                       << " is not a number, which was needed.";
                throw GaudiException( stream.str(), "error", StatusCode::FAILURE );
             }
          }
          stringstream iFileStream;
          iFileStream << m_iFile;
          string iFile( iFileStream.str() );
          unsigned int length = 0;

          if ( stem.length() > iFile.length() ) {
             length = stem.length() - iFile.length();
          }

          stringstream name;
          if ( !dir.empty() ) {
             name << dir << "/";
          }
          for ( unsigned int i = 0; i < length; ++i ) {
             name << "0";
          }
          name << iFile << extension;
          m_outputName = name.str();
       } else {
          if ( m_iFile != 1 ) {
             size_t pos = stem.rfind( "_" );
             stem = stem.substr( 0, pos );
          }

          stringstream iFileStream;
          iFileStream << m_iFile;
          string iFile( iFileStream.str() );

          unsigned int length = 0;
          if ( m_nNumbersAdded > iFile.length() ) {
             length = m_nNumbersAdded - iFile.length();
          }

          stringstream name;
          name << dir << "/" << stem;
          for ( unsigned int i = 0; i < length; ++i ) {
             if ( i == 0 ) name << "_";
             name << "0";
          }
          name << iFile << extension;
          m_outputName = name.str();
       }
       ++m_iFile;
    }

StatusCode SequentialOutputStream::writeObjects | ( | ) | `[protected, virtual]`

OutputStream override: Select the different objects and write them to file.

Reimplemented from OutputStream.

Definition at line 38 of file SequentialOutputStream.cpp.

    {
       try {
          makeFilename();
       } catch ( const GaudiException& except ) {
          MsgStream log(msgSvc(), name());
          log << MSG::ERROR << except.message() << endmsg;
          return StatusCode::FAILURE;
       }
       return OutputStream::writeObjects();
    }

## Member Data Documentation

unsigned int SequentialOutputStream::m_events`[private]`

Number of events written to this output stream.

Reimplemented from OutputStream.

Definition at line 37 of file SequentialOutputStream.h.

unsigned int SequentialOutputStream::m_eventsPerFile`[private]`

Definition at line 32 of file SequentialOutputStream.h.

unsigned int SequentialOutputStream::m_iFile`[private]`

Definition at line 38 of file SequentialOutputStream.h.

unsigned int SequentialOutputStream::m_nNumbersAdded`[private]`

Definition at line 33 of file SequentialOutputStream.h.

bool SequentialOutputStream::m_numericFilename`[private]`

Definition at line 34 of file SequentialOutputStream.h.

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

- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiSvc/src/PersistencySvc/SequentialOutputStream.h
- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiSvc/src/PersistencySvc/SequentialOutputStream.cpp

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