The Gaudi Framework  master (37c0b60a)
NTupleImplementation.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 //====================================================================
12 // NTuple class implementation
13 //--------------------------------------------------------------------
14 //
15 // Package : Gaudi/NTupleSvc ( The LHCb Offline System)
16 // Author : M.Frank
17 //
18 // +---------+----------------------------------------------+--------+
19 // | Date | Comment | Who |
20 // +---------+----------------------------------------------+--------+
21 // | 21/10/99| Initial version. | MF |
22 // +---------+----------------------------------------------+--------+
23 //====================================================================
24 #define GAUDI_NTUPLEIMP_CPP 1
25 
26 // Framework include files
28 #include <GaudiKernel/INTupleSvc.h>
31 
32 /*
33  */
34 namespace NTuple {
36  TupleImp::TupleImp( std::string title ) : m_title( std::move( title ) ) {}
37 
40  for ( auto& i : m_items ) i->release();
41  }
42 
45  m_pSelector = sel;
46  return StatusCode::SUCCESS;
47  }
48 
51 
53  void TupleImp::reset() {
54  for ( auto& i : m_items ) i->reset();
55  }
56 
60  [&]( ItemContainer::const_reference j ) { return j->name() == name; } );
61  return i != std::end( m_items ) ? const_cast<INTupleItem*>( *i ) : nullptr;
62  }
63 
66  if ( item ) {
67  INTupleItem* i = i_find( item->name() );
68  if ( !i ) {
70  return StatusCode::SUCCESS;
71  }
72  }
73  return StatusCode::FAILURE;
74  }
75 
78  INTupleItem* i = i_find( name );
79  return i ? remove( i ) : StatusCode::FAILURE;
80  }
81 
84  auto i = std::find( std::begin( m_items ), std::end( m_items ), item );
85  if ( i == std::end( m_items ) ) return StatusCode::FAILURE;
86  m_items.erase( i );
87  item->release();
88  return StatusCode::SUCCESS;
89  }
91  char* TupleImp::setBuffer( std::unique_ptr<char[]>&& buff ) {
92  m_buffer = std::move( buff );
93  return m_buffer.get();
94  }
96  char* TupleImp::setBuffer( char* buff ) {
97  m_buffer.reset( buff );
98  return m_buffer.get();
99  }
109  StatusCode TupleImp::save() { return m_ntupleSvc->save( this ); }
110 } // end namespace NTuple
NTupleImplementation.h
NTuple::TupleImp::m_buffer
std::unique_ptr< char[]> m_buffer
Buffer.
Definition: NTupleImplementation.h:37
INTupleSvc::readRecord
virtual StatusCode readRecord(NTuple::Tuple *tuple)=0
Read single record from N tuple.
DataObject::name
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition: DataObject.cpp:72
std::string
STL class.
std::move
T move(T... args)
std::find_if
T find_if(T... args)
std::unique_ptr::get
T get(T... args)
ISelectStatement
Definition: ISelectStatement.h:42
NTuple::TupleImp::attachSelector
StatusCode attachSelector(ISelectStatement *sel) override
Attach selector.
Definition: NTupleImplementation.cpp:44
NTuple::TupleImp::TupleImp
TupleImp(const TupleImp &)=delete
Standard Copy Constructor.
INTupleSvc::save
virtual StatusCode save(const std::string &fullPath)=0
Save N tuple to disk.
NTuple::TupleImp::remove
StatusCode remove(INTupleItem *item) override
Remove an item row (identified by pointer) from the N tuple.
Definition: NTupleImplementation.cpp:83
std::unique_ptr::reset
T reset(T... args)
NTuple::TupleImp::add
StatusCode add(INTupleItem *item) override
Add an item row to the N tuple.
Definition: NTupleImplementation.cpp:65
NTuple::Tuple::item
StatusCode item(const std::string &name, Item< TYPE > &result)
Locate a scalar Item of data to the N tuple type safe.
Definition: NTuple.h:472
NTuple::TupleImp::selector
ISelectStatement * selector() override
Access selector.
Definition: NTupleImplementation.cpp:50
std::vector::push_back
T push_back(T... args)
NTuple::TupleImp::m_ntupleSvc
INTupleSvc * m_ntupleSvc
Reference to N-tuple service used.
Definition: NTupleImplementation.h:39
INTupleSvc::writeRecord
virtual StatusCode writeRecord(NTuple::Tuple *tuple)=0
Write single record to N tuple.
NTuple::TupleImp::write
StatusCode write() override
Write record of the NTuple (Shortcut of writeRecord)
Definition: NTupleImplementation.cpp:101
StatusCode
Definition: StatusCode.h:65
ProduceConsume.j
j
Definition: ProduceConsume.py:104
IDataSelector.h
NTuple::TupleImp::~TupleImp
~TupleImp() override
Standard Destructor.
Definition: NTupleImplementation.cpp:39
NTuple::TupleImp::save
StatusCode save() override
Save the NTuple.
Definition: NTupleImplementation.cpp:109
std::vector::erase
T erase(T... args)
ISelectStatement.h
NTuple::TupleImp::read
StatusCode read() override
Read record of the NTuple (Shortcut of readRecord)
Definition: NTupleImplementation.cpp:105
INTupleItem
Definition: INTuple.h:37
IOTest.sel
sel
Definition: IOTest.py:106
NTuple::TupleImp::setBuffer
virtual char * setBuffer(std::unique_ptr< char[]> &&buff)
Set N tuple data buffer.
Definition: NTupleImplementation.cpp:91
NTuple::TupleImp::m_pSelector
SmartIF< ISelectStatement > m_pSelector
Possibly hanging selector.
Definition: NTupleImplementation.h:35
NTuple::TupleImp::readRecord
StatusCode readRecord() override
Read record of the NTuple.
Definition: NTupleImplementation.cpp:107
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
std::begin
T begin(T... args)
std
STL namespace.
NTuple
NTuple name space.
Definition: INTupleSvc.h:19
NTuple::TupleImp::writeRecord
StatusCode writeRecord() override
Write record of the NTuple.
Definition: NTupleImplementation.cpp:103
NTuple::TupleImp::reset
void reset() override
Reset all entries to their default values.
Definition: NTupleImplementation.cpp:53
std::end
T end(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
NTuple::TupleImp::m_items
ItemContainer m_items
Container with N tuple _Columns.
Definition: NTupleImplementation.h:29
NTuple::TupleImp::i_find
INTupleItem * i_find(const std::string &name) const override
Internally used by abstract classes.
Definition: NTupleImplementation.cpp:58
std::unique_ptr
STL class.
INTupleSvc.h