The Gaudi Framework  v33r0 (d5ea422b)
NTupleImplementation.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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
29 #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
void reset() override
Reset all entries to their default values.
INTupleItem * i_find(const std::string &name) const override
Internally used by abstract classes.
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.
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
STL namespace.
T end(T... args)
StatusCode write() override
Write record of the NTuple (Shortcut of writeRecord)
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
NTuple name space.
Definition: INTupleSvc.h:19
StatusCode save() override
Save the NTuple.
STL class.
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:37
~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:61
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.
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition: DataObject.cpp:72
T get(T... args)
T find_if(T... args)
STL class.
SmartIF< ISelectStatement > m_pSelector
Possibly hanging selector.
T begin(T... args)
ItemContainer m_items
Container with N tuple _Columns.
virtual StatusCode readRecord(NTuple::Tuple *tuple)=0
Read single record from N tuple.
constexpr static const auto FAILURE
Definition: StatusCode.h:97
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:469
StatusCode writeRecord() override
Write record of the NTuple.