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"
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 
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 
49  if ( 0 != sel ) sel->addRef();
50  if ( 0 != m_pSelector ) m_pSelector->release();
51  m_pSelector = sel;
52  return StatusCode::SUCCESS;
53  }
54 
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 
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 
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  }
116  return m_ntupleSvc->writeRecord(this);
117  }
120  return m_ntupleSvc->writeRecord(this);
121  }
124  return m_ntupleSvc->readRecord(this);
125  }
128  return m_ntupleSvc->readRecord(this);
129  }
132  return m_ntupleSvc->save(this);
133  }
134 } // end namespace NTuple
virtual StatusCode write()
Write record of the NTuple (Shortcut of writeRecord)
virtual void setBuffer(char *buff)
Set N tuple data buffer.
A select statement can either contain.
virtual INTupleItem * i_find(const std::string &name) const
Internally used by abstract classes.
virtual StatusCode attachSelector(ISelectStatement *sel)
Attach selector.
virtual StatusCode remove(INTupleItem *item)
Remove an item row (identified by pointer) from the N tuple.
virtual StatusCode add(INTupleItem *item)
Add an item row to the N tuple.
virtual void reset()
Reset all entries to their default values.
virtual const std::string & name() const =0
Access _Item name.
TupleImp(const TupleImp &)
Standard Copy Constructor.
INTupleSvc * m_ntupleSvc
Reference to N-tuple service used.
virtual StatusCode read()
Read record of the NTuple (Shortcut of readRecord)
NTuple interface class definition.
Definition: INTuple.h:27
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual StatusCode writeRecord(NTuple::Tuple *tuple)=0
Write single record to N tuple.
virtual StatusCode save(const std::string &fullPath)=0
Save N tuple to disk.
virtual StatusCode save()
Save the NTuple.
virtual StatusCode readRecord()
Read record of the NTuple.
virtual ~TupleImp()
Standard Destructor.
char * m_buffer
Buffer size.
virtual StatusCode writeRecord()
Write record of the NTuple.
virtual unsigned long release()=0
Release Interface instance.
ItemContainer m_items
Container with N tuple _Columns.
virtual StatusCode readRecord(NTuple::Tuple *tuple)=0
Read single record from N tuple.
tuple item
print s1,s2
Definition: ana.py:146
virtual void release()=0
Destruct object.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
ISelectStatement * m_pSelector
Possibly hanging selector.
StatusCode item(const std::string &name, Item< TYPE > &result)
Locate a scalar Item of data to the N tuple type safe.
Definition: NTuple.h:500
virtual ISelectStatement * selector()
Access selector.
list i
Definition: ana.py:128