Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
NTupleImplementation.cpp
Go to the documentation of this file.
1 //====================================================================
2 // NTuple class implementation
3 //--------------------------------------------------------------------
4 //
5 // Package : Gaudi/NTupleSvc ( The LHCb Offline System)
6 // Author : M.Frank
7 //
8 // +---------+----------------------------------------------+--------+
9 // | Date | Comment | Who |
10 // +---------+----------------------------------------------+--------+
11 // | 21/10/99| Initial version. | MF |
12 // +---------+----------------------------------------------+--------+
13 //====================================================================
14 #define GAUDI_NTUPLEIMP_CPP 1
15 
16 // Framework include files
19 #include "GaudiKernel/INTupleSvc.h"
21 
22 /*
23  */
24 namespace NTuple {
26  TupleImp::TupleImp( std::string title ) : m_title( std::move( title ) ) {}
27 
30  for ( auto& i : m_items ) i->release();
31  }
32 
35  m_pSelector = sel;
36  return StatusCode::SUCCESS;
37  }
38 
41 
43  void TupleImp::reset() {
44  for ( auto& i : m_items ) i->reset();
45  }
46 
50  [&]( ItemContainer::const_reference j ) { return j->name() == name; } );
51  return i != std::end( m_items ) ? const_cast<INTupleItem*>( *i ) : nullptr;
52  }
53 
56  if ( item ) {
57  INTupleItem* i = i_find( item->name() );
58  if ( !i ) {
59  m_items.push_back( item );
60  return StatusCode::SUCCESS;
61  }
62  }
63  return StatusCode::FAILURE;
64  }
65 
68  INTupleItem* i = i_find( name );
69  return i ? remove( i ) : StatusCode::FAILURE;
70  }
71 
74  auto i = std::find( std::begin( m_items ), std::end( m_items ), item );
75  if ( i == std::end( m_items ) ) return StatusCode::FAILURE;
76  m_items.erase( i );
77  item->release();
78  return StatusCode::SUCCESS;
79  }
81  char* TupleImp::setBuffer( std::unique_ptr<char[]>&& buff ) {
82  m_buffer = std::move( buff );
83  return m_buffer.get();
84  }
86  char* TupleImp::setBuffer( char* buff ) {
87  m_buffer.reset( buff );
88  return m_buffer.get();
89  }
99  StatusCode TupleImp::save() { return m_ntupleSvc->save( this ); }
100 } // end namespace NTuple
virtual const std::string & name() const =0
Access _Item name.
void reset() override
Reset all entries to their default values.
TupleImp(const TupleImp &)=delete
Standard Copy Constructor.
A select statement can either contain.
std::unique_ptr< char[]> m_buffer
Buffer.
StatusCode add(INTupleItem *item) override
Add an item row to the N tuple.
StatusCode attachSelector(ISelectStatement *sel) override
Attach selector.
ISelectStatement * selector() override
Access selector.
sel
Definition: IOTest.py:93
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
STL namespace.
T end(T...args)
StatusCode write() override
Write record of the NTuple (Shortcut of writeRecord)
NTuple name space.
Definition: INTupleSvc.h:9
StatusCode save() override
Save the NTuple.
STL class.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
INTupleSvc * m_ntupleSvc
Reference to N-tuple service used.
T push_back(T...args)
StatusCode read() override
Read record of the NTuple (Shortcut of readRecord)
NTuple interface class definition.
Definition: INTuple.h:27
~TupleImp() override
Standard Destructor.
StatusCode remove(INTupleItem *item) override
Remove an item row (identified by pointer) from the N tuple.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
virtual StatusCode writeRecord(NTuple::Tuple *tuple)=0
Write single record to N tuple.
T erase(T...args)
virtual StatusCode save(const std::string &fullPath)=0
Save N tuple to disk.
T reset(T...args)
T move(T...args)
StatusCode readRecord() override
Read record of the NTuple.
T get(T...args)
T find_if(T...args)
STL class.
SmartIF< ISelectStatement > m_pSelector
Possibly hanging selector.
T begin(T...args)
INTupleItem * i_find(const std::string &name) const override
Internally used by abstract classes.
ItemContainer m_items
Container with N tuple _Columns.
virtual StatusCode readRecord(NTuple::Tuple *tuple)=0
Read single record from N tuple.
virtual void release()=0
Destruct object.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition: DataObject.cpp:62
virtual char * setBuffer(std::unique_ptr< char[]> &&buff)
Set N tuple data buffer.
StatusCode item(const std::string &name, Item< TYPE > &result)
Locate a scalar Item of data to the N tuple type safe.
Definition: NTuple.h:459
StatusCode writeRecord() override
Write record of the NTuple.