| # Gaudi Framework, version v21r9 |

Home |  | Generated: 3 May 2010

# NTupleImplementation.cpp

Go to the documentation of this file.

    00001 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/src/Lib/NTupleImplementation.cpp,v 1.7 2006/12/10 20:29:18 leggett Exp $
    00002 //====================================================================
    00003 //  NTuple class implementation
    00004 //--------------------------------------------------------------------
    00005 //
    00006 //  Package    : Gaudi/NTupleSvc ( The LHCb Offline System)
    00007 //  Author     : M.Frank
    00008 //
    00009 //  +---------+----------------------------------------------+--------+
    00010 //  |    Date |                 Comment                      | Who    |
    00011 //  +---------+----------------------------------------------+--------+
    00012 //  | 21/10/99| Initial version.                             | MF     |
    00013 //  +---------+----------------------------------------------+--------+
    00014 //====================================================================
    00015 #define GAUDI_NTUPLEIMP_CPP 1
    00016
    00017 // Framework include files
    00018 #include "GaudiKernel/INTupleSvc.h"
    00019 #include "GaudiKernel/IDataSelector.h"
    00020 #include "GaudiKernel/ISelectStatement.h"
    00021 #include "GaudiKernel/NTupleImplementation.h"
    00022
    00023 /*
    00024 */
    00025 namespace NTuple   {
    00027   TupleImp::TupleImp ( const std::string& title )
    00028   : m_isBooked(false),
    00029     m_title(title),
    00030     m_pSelector(0),
    00031     m_buffer(0),
    00032     m_ntupleSvc(0),
    00033     m_cnvSvc(0)
    00034   {
    00035   }
    00036
    00038   TupleImp::~TupleImp ()   {
    00039     for (ItemContainer::iterator i = m_items.begin(); i != m_items.end(); i++) {
    00040       (*i)->release();
    00041     }
    00042     m_items.erase(m_items.begin(), m_items.end());
    00043     delete  [] m_buffer;
    00044     m_buffer = 0;
    00045   }
    00046
    00048   StatusCode TupleImp::attachSelector(ISelectStatement* sel)  {
    00049     if ( 0 != sel         ) sel->addRef();
    00050     if ( 0 != m_pSelector ) m_pSelector->release();
    00051     m_pSelector = sel;
    00052     return StatusCode::SUCCESS;
    00053   }
    00054
    00056   ISelectStatement* TupleImp::selector()   {
    00057     return m_pSelector;
    00058   }
    00059
    00061   void TupleImp::reset ( )   {
    00062     for (ItemContainer::iterator i = m_items.begin(); i != m_items.end(); i++) {
    00063       (*i)->reset();
    00064     }
    00065   }
    00066
    00068   INTupleItem* TupleImp::i_find ( const std::string& name )  const   {
    00069     for (ItemContainer::const_iterator i = m_items.begin();
    00070          i != m_items.end();
    00071          i++) {
    00072       if ( name == (*i)->name() )   {
    00073         INTupleItem* it = const_cast<INTupleItem*>(*i);
    00074         return it;
    00075       }
    00076     }
    00077     return 0;
    00078   }
    00079
    00081   StatusCode TupleImp::add(INTupleItem* item)   {
    00082     if ( 0 != item )    {
    00083       INTupleItem* i = i_find(item->name());
    00084       if ( 0 == i )   {
    00085         m_items.push_back( item );
    00086         return StatusCode::SUCCESS;
    00087       }
    00088     }
    00089     return StatusCode::FAILURE;
    00090   }
    00091
    00093   StatusCode TupleImp::remove ( const std::string& name )    {
    00094     INTupleItem* i = i_find(name);
    00095     return (i == 0) ?  StatusCode(StatusCode::FAILURE) : remove(i);
    00096   }
    00097
    00099   StatusCode TupleImp::remove ( INTupleItem* item )    {
    00100     for (ItemContainer::iterator i = m_items.begin(); i != m_items.end(); i++) {
    00101       if ( (*i) == item )   {
    00102         m_items.erase(i);
    00103         item->release();
    00104         return StatusCode::SUCCESS;
    00105       }
    00106     }
    00107     return StatusCode::FAILURE;
    00108   }
    00110   void TupleImp::setBuffer(char* buff)  {
    00111     if ( 0 != m_buffer ) delete m_buffer;
    00112     m_buffer = buff;
    00113   }
    00115   StatusCode TupleImp::write()    {
    00116     return m_ntupleSvc->writeRecord(this);
    00117   }
    00119   StatusCode TupleImp::writeRecord()    {
    00120     return m_ntupleSvc->writeRecord(this);
    00121   }
    00123   StatusCode TupleImp::read()    {
    00124     return m_ntupleSvc->readRecord(this);
    00125   }
    00127   StatusCode TupleImp::readRecord()    {
    00128     return m_ntupleSvc->readRecord(this);
    00129   }
    00131   StatusCode TupleImp::save()    {
    00132     return m_ntupleSvc->save(this);
    00133   }
    00134 }    // end namespace NTuple