| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
NTupleImplementation.cpp
Go to the documentation of this file.
1 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/src/Lib/NTupleImplementation.cpp,v 1.7 2006/12/10 20:29:18 leggett Exp $
2 //====================================================================
3 // NTuple class implementation
4 //--------------------------------------------------------------------
5 //
6 // Package : Gaudi/NTupleSvc ( The LHCb Offline System)
7 // Author : M.Frank
8 //
9 // +---------+----------------------------------------------+--------+
10 // | Date | Comment | Who |
11 // +---------+----------------------------------------------+--------+
12 // | 21/10/99| Initial version. | MF |
13 // +---------+----------------------------------------------+--------+
14 //====================================================================
15 #define GAUDI_NTUPLEIMP_CPP 1
16
17 // Framework include files
18 #include "GaudiKernel/INTupleSvc.h"
19 #include "GaudiKernel/IDataSelector.h"
20 #include "GaudiKernel/ISelectStatement.h"
21 #include "GaudiKernel/NTupleImplementation.h"
22
23 /*
24 */
25 namespace NTuple {
27 TupleImp::TupleImp ( const std::string& title )
28 : m_isBooked(false),
29 m_title(title),
30 m_pSelector(0),
31 m_buffer(0),
32 m_ntupleSvc(0),
33 m_cnvSvc(0)
34 {
35 }
36
38 TupleImp::~TupleImp () {
39 for (ItemContainer::iterator i = m_items.begin(); i != m_items.end(); i++) {
40 (*i)->release();
41 }
42 m_items.erase(m_items.begin(), m_items.end());
43 delete [] m_buffer;
44 m_buffer = 0;
45 }
46
48 StatusCode TupleImp::attachSelector(ISelectStatement* sel) {
49 if ( 0 != sel ) sel->addRef();
50 if ( 0 != m_pSelector ) m_pSelector->release();
51 m_pSelector = sel;
52 return StatusCode::SUCCESS;
53 }
54
56 ISelectStatement* TupleImp::selector() {
57 return m_pSelector;
58 }
59
61 void TupleImp::reset ( ) {
62 for (ItemContainer::iterator i = m_items.begin(); i != m_items.end(); i++) {
63 (*i)->reset();
64 }
65 }
66
68 INTupleItem* TupleImp::i_find ( const std::string& name ) const {
69 for (ItemContainer::const_iterator i = m_items.begin();
70 i != m_items.end();
71 i++) {
72 if ( name == (*i)->name() ) {
73 INTupleItem* it = const_cast<INTupleItem*>(*i);
74 return it;
75 }
76 }
77 return 0;
78 }
79
81 StatusCode TupleImp::add(INTupleItem* item) {
82 if ( 0 != item ) {
83 INTupleItem* i = i_find(item->name());
84 if ( 0 == i ) {
85 m_items.push_back( item );
86 return StatusCode::SUCCESS;
87 }
88 }
89 return StatusCode::FAILURE;
90 }
91
93 StatusCode TupleImp::remove ( const std::string& name ) {
94 INTupleItem* i = i_find(name);
95 return (i == 0) ? StatusCode(StatusCode::FAILURE) : remove(i);
96 }
97
99 StatusCode TupleImp::remove ( INTupleItem* item ) {
100 for (ItemContainer::iterator i = m_items.begin(); i != m_items.end(); i++) {
101 if ( (*i) == item ) {
102 m_items.erase(i);
103 item->release();
104 return StatusCode::SUCCESS;
105 }
106 }
107 return StatusCode::FAILURE;
108 }
110 void TupleImp::setBuffer(char* buff) {
111 if ( 0 != m_buffer ) delete m_buffer;
112 m_buffer = buff;
113 }
115 StatusCode TupleImp::write() {
116 return m_ntupleSvc->writeRecord(this);
117 }
119 StatusCode TupleImp::writeRecord() {
120 return m_ntupleSvc->writeRecord(this);
121 }
123 StatusCode TupleImp::read() {
124 return m_ntupleSvc->readRecord(this);
125 }
127 StatusCode TupleImp::readRecord() {
128 return m_ntupleSvc->readRecord(this);
129 }
131 StatusCode TupleImp::save() {
132 return m_ntupleSvc->save(this);
133 }
134 } // end namespace NTuple