| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
17 #include "GaudiKernel/INTupleSvc.h"
18 #include "GaudiKernel/IDataSelector.h"
19 #include "GaudiKernel/ISelectStatement.h"
20 #include "GaudiKernel/NTupleImplementation.h"
21
22 /*
23 */
24 namespace NTuple {
26 TupleImp::TupleImp ( std::string title )
27 : m_title(std::move(title))
28 {
29 }
30
32 TupleImp::~TupleImp () {
33 for (auto &i : m_items) i->release();
34 }
35
37 StatusCode TupleImp::attachSelector(ISelectStatement* sel) {
38 m_pSelector = sel;
39 return StatusCode::SUCCESS;
40 }
41
43 ISelectStatement* TupleImp::selector() {
44 return m_pSelector.get();
45 }
46
48 void TupleImp::reset ( ) {
49 for (auto& i : m_items ) i->reset();
50 }
51
53 INTupleItem* TupleImp::i_find ( const std::string& name ) const {
54 auto i = std::find_if( std::begin(m_items), std::end(m_items),
55 [&](ItemContainer::const_reference j)
56 { return j->name() == name; } );
57 return i!=std::end(m_items) ? const_cast<INTupleItem*>(*i) : nullptr;
58 }
59
61 StatusCode TupleImp::add(INTupleItem* item) {
62 if ( item ) {
63 INTupleItem* i = i_find(item->name());
64 if ( !i ) {
65 m_items.push_back( item );
66 return StatusCode::SUCCESS;
67 }
68 }
69 return StatusCode::FAILURE;
70 }
71
73 StatusCode TupleImp::remove ( const std::string& name ) {
74 INTupleItem* i = i_find(name);
75 return i ? remove(i) : StatusCode::FAILURE;
76 }
77
79 StatusCode TupleImp::remove ( INTupleItem* item ) {
80 auto i = std::find( std::begin(m_items), std::end(m_items), item );
81 if ( i == std::end( m_items) ) return StatusCode::FAILURE;
82 m_items.erase(i);
83 item->release();
84 return StatusCode::SUCCESS;
85 }
87 char* TupleImp::setBuffer(std::unique_ptr<char[]>&& buff) {
88 m_buffer = std::move(buff);
89 return m_buffer.get();
90 }
92 char* TupleImp::setBuffer(char* buff) {
93 m_buffer.reset( buff );
94 return m_buffer.get();
95 }
97 StatusCode TupleImp::write() {
98 return m_ntupleSvc->writeRecord(this);
99 }
101 StatusCode TupleImp::writeRecord() {
102 return m_ntupleSvc->writeRecord(this);
103 }
105 StatusCode TupleImp::read() {
106 return m_ntupleSvc->readRecord(this);
107 }
109 StatusCode TupleImp::readRecord() {
110 return m_ntupleSvc->readRecord(this);
111 }
113 StatusCode TupleImp::save() {
114 return m_ntupleSvc->save(this);
115 }
116 } // end namespace NTuple
INTupleItem::name
virtual const std::string & name() const =0
Access _Item name.
IDataSelector.h
NTuple::TupleImp::reset
void reset() override
Reset all entries to their default values.
Definition: NTupleImplementation.cpp:48
StatusCode::SUCCESS
Definition: StatusCode.h:30
NTupleImplementation.h
NTuple::TupleImp::TupleImp
TupleImp(const TupleImp &)=delete
Standard Copy Constructor.
StatusCode::FAILURE
Definition: StatusCode.h:29
ISelectStatement
A select statement can either contain.
Definition: ISelectStatement.h:32
NTuple::TupleImp::m_buffer
std::unique_ptr< char[]> m_buffer
Buffer.
Definition: NTupleImplementation.h:29
NTuple::TupleImp::add
StatusCode add(INTupleItem *item) override
Add an item row to the N tuple.
Definition: NTupleImplementation.cpp:61
NTuple::TupleImp::attachSelector
StatusCode attachSelector(ISelectStatement *sel) override
Attach selector.
Definition: NTupleImplementation.cpp:37
NTuple::TupleImp::selector
ISelectStatement * selector() override
Access selector.
Definition: NTupleImplementation.cpp:43
IOTest.sel
sel
Definition: IOTest.py:84
ISelectStatement.h
std
STL namespace.
std::end
T end(T...args)
NTuple::TupleImp::write
StatusCode write() override
Write record of the NTuple (Shortcut of writeRecord)
Definition: NTupleImplementation.cpp:97
NTuple
NTuple name space.
Definition: INTupleSvc.h:10
NTuple::TupleImp::save
StatusCode save() override
Save the NTuple.
Definition: NTupleImplementation.cpp:113
std::string
STL class.
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
NTuple::TupleImp::m_ntupleSvc
INTupleSvc * m_ntupleSvc
Reference to N-tuple service used.
Definition: NTupleImplementation.h:31
std::vector::push_back
T push_back(T...args)
NTuple::TupleImp::read
StatusCode read() override
Read record of the NTuple (Shortcut of readRecord)
Definition: NTupleImplementation.cpp:105
INTupleItem
NTuple interface class definition.
Definition: INTuple.h:26
NTuple::TupleImp::~TupleImp
~TupleImp() override
Standard Destructor.
Definition: NTupleImplementation.cpp:32
NTuple::TupleImp::remove
StatusCode remove(INTupleItem *item) override
Remove an item row (identified by pointer) from the N tuple.
Definition: NTupleImplementation.cpp:79
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
INTupleSvc::writeRecord
virtual StatusCode writeRecord(NTuple::Tuple *tuple)=0
Write single record to N tuple.
std::vector::erase
T erase(T...args)
INTupleSvc::save
virtual StatusCode save(const std::string &fullPath)=0
Save N tuple to disk.
std::unique_ptr::reset
T reset(T...args)
std::move
T move(T...args)
NTuple::TupleImp::readRecord
StatusCode readRecord() override
Read record of the NTuple.
Definition: NTupleImplementation.cpp:109
std::unique_ptr::get
T get(T...args)
std::find_if
T find_if(T...args)
std::unique_ptr
STL class.
NTuple::TupleImp::m_pSelector
SmartIF< ISelectStatement > m_pSelector
Possibly hanging selector.
Definition: NTupleImplementation.h:27
std::begin
T begin(T...args)
NTuple::TupleImp::i_find
INTupleItem * i_find(const std::string &name) const override
Internally used by abstract classes.
Definition: NTupleImplementation.cpp:53
NTuple::TupleImp::m_items
ItemContainer m_items
Container with N tuple _Columns.
Definition: NTupleImplementation.h:21
INTupleSvc::readRecord
virtual StatusCode readRecord(NTuple::Tuple *tuple)=0
Read single record from N tuple.
INTupleItem::release
virtual void release()=0
Destruct object.
DataObject::name
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition: DataObject.cpp:78
NTuple::TupleImp::setBuffer
virtual char * setBuffer(std::unique_ptr< char[]> &&buff)
Set N tuple data buffer.
Definition: NTupleImplementation.cpp:87
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:503
NTuple::TupleImp::writeRecord
StatusCode writeRecord() override
Write record of the NTuple.
Definition: NTupleImplementation.cpp:101
INTupleSvc.h