The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
NTupleImplementation.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 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\***********************************************************************************/
15
16namespace NTuple {
17 TupleImp::TupleImp( std::string title ) : m_title( std::move( title ) ) {}
19 for ( auto& i : m_items ) i->release();
20 }
21
27
30
33 for ( auto& i : m_items ) i->reset();
34 }
35
37 INTupleItem* TupleImp::i_find( const std::string& name ) const {
38 auto i = std::find_if( std::begin( m_items ), std::end( m_items ),
39 [&]( ItemContainer::const_reference j ) { return j->name() == name; } );
40 return i != std::end( m_items ) ? const_cast<INTupleItem*>( *i ) : nullptr;
41 }
42
45 if ( item ) {
46 INTupleItem* i = i_find( item->name() );
47 if ( !i ) {
48 m_items.push_back( item );
50 }
51 }
53 }
54
56 StatusCode TupleImp::remove( const std::string& name ) {
57 INTupleItem* i = i_find( name );
58 return i ? remove( i ) : StatusCode::FAILURE;
59 }
60
63 auto i = std::find( std::begin( m_items ), std::end( m_items ), item );
64 if ( i == std::end( m_items ) ) return StatusCode::FAILURE;
65 m_items.erase( i );
66 item->release();
68 }
69
70 char* TupleImp::setBuffer( std::unique_ptr<char[]>&& buff ) {
71 m_buffer = std::move( buff );
72 return m_buffer.get();
73 }
74
75 char* TupleImp::setBuffer( char* buff ) {
76 m_buffer.reset( buff );
77 return m_buffer.get();
78 }
79
80 StatusCode TupleImp::write() { return m_ntupleSvc->writeRecord( this ); }
82 StatusCode TupleImp::writeRecord() { return m_ntupleSvc->writeRecord( this ); }
84 StatusCode TupleImp::read() { return m_ntupleSvc->readRecord( this ); }
86 StatusCode TupleImp::readRecord() { return m_ntupleSvc->readRecord( this ); }
88 StatusCode TupleImp::save() { return m_ntupleSvc->save( this ); }
89} // namespace NTuple
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
NTuple interface class definition.
Definition INTuple.h:32
A select statement can either contain.
StatusCode item(const std::string &name, Item< TYPE > &result)
Locate a scalar Item of data to the N tuple type safe.
Definition NTuple.h:464
StatusCode save() override
Save the NTuple.
INTupleItem * i_find(const std::string &name) const override
Internally used by abstract classes.
virtual char * setBuffer(std::unique_ptr< char[]> &&buff)
Set N tuple data buffer.
StatusCode write() override
Write record of the NTuple (Shortcut of writeRecord)
TupleImp(const TupleImp &)=delete
Standard Copy Constructor.
const std::string & title() const override
Object title.
ISelectStatement * selector() override
Access selector.
StatusCode attachSelector(ISelectStatement *sel) override
Attach selector.
StatusCode readRecord() override
Read record of the NTuple.
StatusCode writeRecord() override
Write record of the NTuple.
StatusCode add(INTupleItem *item) override
Add an item row to the N tuple.
SmartIF< ISelectStatement > m_pSelector
Possibly hanging selector.
void reset() override
Reset all entries to their default values.
StatusCode remove(INTupleItem *item) override
Remove an item row (identified by pointer) from the N tuple.
ItemContainer m_items
Container with N tuple _Columns.
std::string m_title
N tuple title.
~TupleImp() override
Standard Destructor.
std::unique_ptr< char[]> m_buffer
Buffer.
INTupleSvc * m_ntupleSvc
Reference to N-tuple service used.
StatusCode read() override
Read record of the NTuple (Shortcut of readRecord)
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
NTuple name space.
Definition INTupleSvc.h:16
STL namespace.