Jpp
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
JSUPPORT::JTreeRecorder< T > Class Template Referenceabstract

ROOT TTree object output. More...

#include <JTreeRecorder.hh>

Inheritance diagram for JSUPPORT::JTreeRecorder< T >:
JROOT::JTreeWriterObjectOutput< T > JLANG::JAccessibleObjectOutput< T > JROOT::JRootOutputFile JLANG::JObjectOutput< T > JLANG::JObjectOutput< T > JLANG::JAccessible JROOT::JRootFile JLANG::JThrow< JAccessible > JLANG::JAccessible JLANG::JStorage< JClass_t, JMemory_t > JLANG::JThrow< JAccessible > JLANG::JPointer< JClass_t > JLANG::JAbstractPointer< JClass_t > JLANG::JEquals< JAbstractPointer< JClass_t > >

Public Types

typedef JPointer< JClass_t > pointer_type
 
typedef JMemory_t< JClass_t > memory_type
 

Public Member Functions

 JTreeRecorder ()
 Default constructor. More...
 
 JTreeRecorder (const char *file_name)
 Constructor. More...
 
virtual void open (const char *file_name)
 Open file. More...
 
virtual void close ()
 Close file. More...
 
virtual bool put (const T &object)
 Object output. More...
 
void SetCircular (Long64_t size)
 Set circular buffer size. More...
 
void Reset ()
 Reset TTree. More...
 
virtual bool is_open () const =0
 Check is device is open. More...
 
TFile * getFile () const
 Get file. More...
 
virtual bool is_open () const
 Check is file is open. More...
 
virtual void reset ()
 Reset pointer. More...
 
virtual void reset ()
 Reset pointer. More...
 
template<class T >
void reset (const JPointer< T > &pointer)
 Reset pointer. More...
 
template<class T >
void reset (const JPointer< T > &pointer)
 Reset pointer. More...
 
void reset (JClass_t *p)
 Reset pointer. More...
 
void recreate ()
 Recreate object in memory. More...
 
void create ()
 Create object in memory. More...
 
void create (const unsigned int size)
 Create array of objects in memory. More...
 
virtual JClass_t * get () const
 Get pointer. More...
 
virtual void set (JClass_t *p)
 Set pointer. More...
 
template<class T >
void set (const JPointer< T > &pointer)
 Set pointer. More...
 
JClass_t *const & getReference () const
 Get rereference to internal pointer. More...
 
JClass_t *& getReference ()
 Get rereference to internal pointer. More...
 
virtual bool equals (const JAbstractPointer &object) const
 Equals. More...
 
bool is_valid () const
 Check validity of pointer. More...
 
JClass_t * operator-> () const
 Smart pointer operator. More...
 
 operator JClass_t * () const
 Type conversion operator. More...
 

Static Public Member Functions

static void Throw (const bool option)
 Enable/disable throw option. More...
 
static int Throw (const JException &error, const int value=-1)
 Throw exception or return error. More...
 

Protected Member Functions

JTreeWriter< T > & getTreeWriter ()
 Get TreeWriter. More...
 
void SetDirectory (TDirectory *dir)
 Set directory. More...
 
void release ()
 Release memory. More...
 

Protected Attributes

JTreeWriter< T > * out
 
bool del
 
JClass_t * __p
 pointer to object More...
 

Static Protected Attributes

static bool do_throw
 throw option More...
 

Detailed Description

template<class T>
class JSUPPORT::JTreeRecorder< T >

ROOT TTree object output.

This class implements the JLANG::JAccessibleObjectOutput interface.

Definition at line 28 of file JTreeRecorder.hh.

Member Typedef Documentation

◆ pointer_type

template<class JClass_t, template< class > class JMemory_t = JNew>
typedef JPointer<JClass_t> JLANG::JStorage< JClass_t, JMemory_t >::pointer_type
inherited

Definition at line 32 of file JStorage.hh.

◆ memory_type

template<class JClass_t, template< class > class JMemory_t = JNew>
typedef JMemory_t<JClass_t> JLANG::JStorage< JClass_t, JMemory_t >::memory_type
inherited

Definition at line 33 of file JStorage.hh.

Constructor & Destructor Documentation

◆ JTreeRecorder() [1/2]

template<class T>
JSUPPORT::JTreeRecorder< T >::JTreeRecorder ( )
inline

Default constructor.

Definition at line 37 of file JTreeRecorder.hh.

38  {}

◆ JTreeRecorder() [2/2]

template<class T>
JSUPPORT::JTreeRecorder< T >::JTreeRecorder ( const char *  file_name)
inline

Constructor.

Parameters
file_namefile name

Definition at line 46 of file JTreeRecorder.hh.

47  {
48  open(file_name);
49  }

Member Function Documentation

◆ open()

template<class T>
virtual void JSUPPORT::JTreeRecorder< T >::open ( const char *  file_name)
inlinevirtual

Open file.

Parameters
file_namefile name

Reimplemented from JROOT::JRootOutputFile.

Definition at line 57 of file JTreeRecorder.hh.

58  {
59  JRootOutputFile::open(file_name);
60 
61  if (is_open()) {
62  this->SetDirectory(getFile());
63  }
64  }

◆ close()

template<class T>
virtual void JSUPPORT::JTreeRecorder< T >::close ( )
inlinevirtual

Close file.

Reimplemented from JROOT::JRootOutputFile.

Definition at line 70 of file JTreeRecorder.hh.

71  {
72  // Write objects in memory.
73 
74  if (is_open()) {
75  getFile()->Write();
76  }
77 
78  // Detach TTree from TDirectory to avoid deletion of TTree.
79 
80  this->SetDirectory(0);
81 
82  // Close file.
83 
84  if (is_open()) {
85  getFile()->Close();
86  }
87 
88  reset();
89 
90  // Reset TTree.
91 
92  this->Reset();
93  }

◆ getTreeWriter()

template<class T>
JTreeWriter<T>& JROOT::JTreeWriterObjectOutput< T >::getTreeWriter ( )
inlineprotectedinherited

Get TreeWriter.

Returns
TreeWriter

Definition at line 59 of file JTreeWriterObjectOutput.hh.

60  {
61  return *out;
62  }

◆ SetDirectory()

template<class T>
void JROOT::JTreeWriterObjectOutput< T >::SetDirectory ( TDirectory *  dir)
inlineprotectedinherited

Set directory.

Parameters
dirpointer to directory

Definition at line 70 of file JTreeWriterObjectOutput.hh.

71  {
72  out->SetDirectory(dir);
73 
74  del = (dir == NULL);
75  }

◆ put()

template<class T>
virtual bool JROOT::JTreeWriterObjectOutput< T >::put ( const T &  object)
inlinevirtualinherited

Object output.

Parameters
objectobject
Returns
true if OK; else false

Implements JLANG::JObjectOutput< T >.

Definition at line 88 of file JTreeWriterObjectOutput.hh.

89  {
90  return (out->Write(object) > 0);
91  }

◆ SetCircular()

template<class T>
void JROOT::JTreeWriterObjectOutput< T >::SetCircular ( Long64_t  size)
inlineinherited

Set circular buffer size.

Parameters
sizenumber of entries

Definition at line 99 of file JTreeWriterObjectOutput.hh.

100  {
101  out->SetCircular(size);
102  }

◆ Reset()

template<class T>
void JROOT::JTreeWriterObjectOutput< T >::Reset ( )
inlineinherited

Reset TTree.

Definition at line 108 of file JTreeWriterObjectOutput.hh.

109  {
110  out->Reset();
111  }

◆ is_open() [1/2]

virtual bool JLANG::JAccessible::is_open ( ) const
pure virtualinherited

◆ Throw() [1/2]

static void JLANG::JThrow< JAccessible >::Throw ( const bool  option)
inlinestaticinherited

Enable/disable throw option.

Parameters
optiontrue enable; false disable

Definition at line 37 of file JThrow.hh.

38  {
39  do_throw = option;
40  }

◆ Throw() [2/2]

static int JLANG::JThrow< JAccessible >::Throw ( const JException error,
const int  value = -1 
)
inlinestaticinherited

Throw exception or return error.

Parameters
errorexception
valuereturn code
Returns
return code

Definition at line 50 of file JThrow.hh.

51  {
52  using namespace std;
53 
54  if (do_throw) {
55  throw error;
56  }
57 
58  cerr << error.what() << endl;
59 
60  return value;
61  }

◆ getFile()

TFile* JROOT::JRootFile::getFile ( ) const
inlineinherited

Get file.

Returns
pointer to file

Definition at line 65 of file JRootFile.hh.

66  {
67  return get();
68  }

◆ is_open() [2/2]

virtual bool JROOT::JRootFile::is_open ( ) const
inlinevirtualinherited

Check is file is open.

Returns
true if open; else false

Implements JLANG::JAccessible.

Definition at line 76 of file JRootFile.hh.

77  {
78  return (is_valid() && getFile()->IsOpen());
79  }

◆ reset() [1/5]

template<class JClass_t, template< class > class JMemory_t = JNew>
virtual void JLANG::JStorage< JClass_t, JMemory_t >::reset ( )
inlinevirtualinherited

Reset pointer.

The allocated memory is released.

Reimplemented from JLANG::JPointer< JClass_t >.

Reimplemented in JLANG::JSharedPointer< JClass_t, JMemory_t >, JLANG::JSharedPointer< JPHYSICS::JRadiation >, JLANG::JSharedPointer< JWeightEvent >, JLANG::JSharedPointer< JObjectIterator< T > >, JLANG::JSharedPointer< JFIT::JMEstimator >, JLANG::JSharedPointer< JAbstractAutoPointer< JBase_t > >, JLANG::JSharedPointer< match_type >, JLANG::JSharedPointer< JAccessibleObjectIterator< JDAQSummaryslice > >, JLANG::JSharedPointer< JAccessibleObjectIterator< JTypeList< JDAQEvent, JTypelist_t > > >, JLANG::JSharedPointer< JAccessibleObjectIterator< JTail_t > >, JLANG::JSharedPointer< JAccessibleObjectIterator< KM3NETDAQ::JDAQEvent > >, JLANG::JSharedPointer< JLOGGER::JLogger >, JLANG::JSharedPointer< JAccessibleObjectIterator< T > >, JLANG::JSharedPointer< JParserElementInterface >, JLANG::JSharedPointer< const JDETECTOR::JModuleRouter >, JLANG::JSharedPointer< JExceptionHandler >, JLANG::JSharedPointer< JObjectOutput< JHead_t > >, JLANG::JSharedPointer< JAccessibleObjectIterator< JHead_t > >, JLANG::JSharedPointer< JRewindableObjectIterator< JTail_t > >, JLANG::JSharedPointer< JRewindableObjectIterator< JHead_t > >, JLANG::JSharedPointer< JObjectOutput< T > >, JLANG::JSharedPointer< JBase_t >, JLANG::JSharedPointer< JObjectOutput< JTail_t > >, JLANG::JSharedPointer< JPropertiesElementInterface >, JLANG::JSharedPointer< JTRIGGER::JMatch >, JLANG::JSharedPointer< JRewindableObjectIterator< const T > >, JLANG::JSharedPointer< JRewindableObjectIterator< T > >, JLANG::JSharedPointer< JAccessibleObjectOutput< T > >, JLANG::JSharedPointer< JNET::JControlHost >, and JLANG::JSharedPointer< JTOOLS::JMultiMapTransformer >.

Definition at line 42 of file JStorage.hh.

43  {
44  if (this->is_valid()) {
45  this->release();
46  }
47 
49  }

◆ reset() [2/5]

template<class JClass_t, template< class > class JMemory_t = JNew>
virtual void JLANG::JPointer< JClass_t >::reset
inlineinherited

Reset pointer.

Definition at line 84 of file JPointer.hh.

85  {
86  this->__p = NULL;
87  }

◆ reset() [3/5]

template<class JClass_t, template< class > class JMemory_t = JNew>
template<class T >
void JLANG::JPointer< JClass_t >::reset ( class T  )
inlineinherited

Reset pointer.

Parameters
pointerpointer to object

Definition at line 108 of file JPointer.hh.

109  {
110  this->reset(pointer.get());
111  }

◆ reset() [4/5]

template<class JClass_t>
template<class T >
void JLANG::JPointer< JClass_t >::reset ( const JPointer< T > &  pointer)
inlineinherited

Reset pointer.

Parameters
pointerpointer to object

Definition at line 108 of file JPointer.hh.

109  {
110  this->reset(pointer.get());
111  }

◆ reset() [5/5]

template<class JClass_t>
void JLANG::JAbstractPointer< JClass_t >::reset ( JClass_t *  p)
inlineinherited

Reset pointer.

Parameters
ppointer to object

Definition at line 94 of file JAbstractPointer.hh.

95  {
96  if (this->get() != p) {
97 
98  this->reset();
99 
100  if (p != NULL) {
101  this->set(p);
102  }
103  }
104  }

◆ recreate()

template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::recreate ( )
inlineinherited

Recreate object in memory.

A new object is created if no memory is allocated yet, else the previously created object is maintained.

Definition at line 57 of file JStorage.hh.

58  {
59  if (!this->is_valid()) {
60  this->set(memory_type::create());
61  }
62  }

◆ create() [1/2]

template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::create ( )
inlineinherited

Create object in memory.

The memory allocated by a previously created object will be released.

Definition at line 69 of file JStorage.hh.

70  {
71  this->reset(memory_type::create());
72  }

◆ create() [2/2]

template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::create ( const unsigned int  size)
inlineinherited

Create array of objects in memory.

The memory allocated by previously created objects will be released.

Parameters
sizenumber of elements

Definition at line 81 of file JStorage.hh.

82  {
83  this->reset(memory_type::create(size));
84  }

◆ release()

template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::release ( )
inlineprotectedinherited

Release memory.

Definition at line 91 of file JStorage.hh.

92  {
93  memory_type::release(this->get());
94  }

◆ get()

template<class JClass_t>
virtual JClass_t* JLANG::JPointer< JClass_t >::get ( ) const
inlinevirtualinherited

◆ set() [1/2]

template<class JClass_t>
virtual void JLANG::JPointer< JClass_t >::set ( JClass_t *  p)
inlinevirtualinherited

Set pointer.

Parameters
ppointer to object

Implements JLANG::JAbstractPointer< JClass_t >.

Reimplemented in JLANG::JSharedPointer< match_type >, JLANG::JSharedPointer< JWeightEvent >, JLANG::JSharedPointer< JTRIGGER::JMatch >, JLANG::JSharedPointer< JTOOLS::JMultiMapTransformer >, JLANG::JSharedPointer< JRewindableObjectIterator< T > >, JLANG::JSharedPointer< JRewindableObjectIterator< JTail_t > >, JLANG::JSharedPointer< JRewindableObjectIterator< JHead_t > >, JLANG::JSharedPointer< JRewindableObjectIterator< const T > >, JLANG::JSharedPointer< JPropertiesElementInterface >, JLANG::JSharedPointer< JPHYSICS::JRadiation >, JLANG::JSharedPointer< JParserElementInterface >, JLANG::JSharedPointer< JObjectOutput< T > >, JLANG::JSharedPointer< JObjectOutput< JTail_t > >, JLANG::JSharedPointer< JObjectOutput< JHead_t > >, JLANG::JSharedPointer< JObjectIterator< T > >, JLANG::JSharedPointer< JNET::JControlHost >, JLANG::JSharedPointer< JLOGGER::JLogger >, JLANG::JSharedPointer< JFIT::JMEstimator >, JLANG::JSharedPointer< JExceptionHandler >, JLANG::JSharedPointer< JClass_t, JMemory_t >, JLANG::JSharedPointer< JBase_t >, JLANG::JSharedPointer< JAccessibleObjectOutput< T > >, JLANG::JSharedPointer< JAccessibleObjectIterator< T > >, JLANG::JSharedPointer< JAccessibleObjectIterator< KM3NETDAQ::JDAQEvent > >, JLANG::JSharedPointer< JAccessibleObjectIterator< JTypeList< JDAQEvent, JTypelist_t > > >, JLANG::JSharedPointer< JAccessibleObjectIterator< JTail_t > >, JLANG::JSharedPointer< JAccessibleObjectIterator< JHead_t > >, JLANG::JSharedPointer< JAccessibleObjectIterator< JDAQSummaryslice > >, JLANG::JSharedPointer< JAbstractAutoPointer< JBase_t > >, and JLANG::JSharedPointer< const JDETECTOR::JModuleRouter >.

Definition at line 75 of file JPointer.hh.

76  {
77  this->__p = p;
78  }

◆ set() [2/2]

template<class JClass_t>
template<class T >
void JLANG::JPointer< JClass_t >::set ( const JPointer< T > &  pointer)
inlineinherited

Set pointer.

Parameters
pointerpointer to object

Definition at line 96 of file JPointer.hh.

97  {
98  this->set(pointer.get());
99  }

◆ getReference() [1/2]

template<class JClass_t>
JClass_t* const& JLANG::JPointer< JClass_t >::getReference ( ) const
inlineinherited

Get rereference to internal pointer.

Returns
reference to internal pointer

Definition at line 119 of file JPointer.hh.

120  {
121  return __p;
122  }

◆ getReference() [2/2]

template<class JClass_t>
JClass_t* & JLANG::JPointer< JClass_t >::getReference ( )
inlineinherited

Get rereference to internal pointer.

Returns
reference to internal pointer

Definition at line 130 of file JPointer.hh.

131  {
132  return __p;
133  }

◆ equals()

template<class JClass_t>
virtual bool JLANG::JAbstractPointer< JClass_t >::equals ( const JAbstractPointer< JClass_t > &  object) const
inlinevirtualinherited

Equals.

The equality is evaluated by comparison of the internal pointers.

Parameters
objectabstract pointer
Returns
true if equals; else false

Definition at line 50 of file JAbstractPointer.hh.

51  {
52  return this->get() == object.get();
53  }

◆ is_valid()

template<class JClass_t>
bool JLANG::JAbstractPointer< JClass_t >::is_valid ( ) const
inlineinherited

Check validity of pointer.

Returns
true if pointer not null; else false

Definition at line 83 of file JAbstractPointer.hh.

84  {
85  return this->get() != NULL;
86  }

◆ operator->()

template<class JClass_t>
JClass_t* JLANG::JAbstractPointer< JClass_t >::operator-> ( ) const
inlineinherited

Smart pointer operator.

Returns
pointer to object

Definition at line 112 of file JAbstractPointer.hh.

113  {
114  if (!is_valid())
115  throw JNullPointerException("JAbstractPointer::operator->()");
116  else
117  return this->get();
118  }

◆ operator JClass_t *()

template<class JClass_t>
JLANG::JAbstractPointer< JClass_t >::operator JClass_t * ( ) const
inlineinherited

Type conversion operator.

Returns
pointer to object

Definition at line 126 of file JAbstractPointer.hh.

127  {
128  return this->get();
129  }

Member Data Documentation

◆ out

template<class T>
JTreeWriter<T>* JROOT::JTreeWriterObjectOutput< T >::out
protectedinherited

Definition at line 78 of file JTreeWriterObjectOutput.hh.

◆ del

template<class T>
bool JROOT::JTreeWriterObjectOutput< T >::del
protectedinherited

Definition at line 79 of file JTreeWriterObjectOutput.hh.

◆ do_throw

bool JLANG::JThrow< JAccessible >::do_throw
staticprotectedinherited

throw option

Set default throw option to true.

Definition at line 28 of file JThrow.hh.

◆ __p

template<class JClass_t>
JClass_t* JLANG::JPointer< JClass_t >::__p
protectedinherited

pointer to object

Definition at line 136 of file JPointer.hh.


The documentation for this class was generated from the following file:
JLANG::JPointer::set
virtual void set(JClass_t *p)
Set pointer.
Definition: JPointer.hh:75
JROOT::JTreeWriterObjectOutput::del
bool del
Definition: JTreeWriterObjectOutput.hh:79
JLANG::JPointer::get
virtual JClass_t * get() const
Get pointer.
Definition: JPointer.hh:64
JROOT::JRootOutputFile::open
virtual void open(const char *file_name)
Open file.
Definition: JRootFile.hh:177
JLANG::JPointer::__p
JClass_t * __p
pointer to object
Definition: JPointer.hh:136
JROOT::JTreeWriterObjectOutput::SetDirectory
void SetDirectory(TDirectory *dir)
Set directory.
Definition: JTreeWriterObjectOutput.hh:70
JLANG::JNullPointerException
Exception for null pointer operation.
Definition: JException.hh:216
JLANG::JAccessible::is_open
virtual bool is_open() const =0
Check is device is open.
JLANG::JAbstractPointer::reset
virtual void reset()=0
Reset pointer.
JROOT::JRootFile::getFile
TFile * getFile() const
Get file.
Definition: JRootFile.hh:65
JLANG::JPointer::reset
virtual void reset()
Reset pointer.
Definition: JPointer.hh:84
JROOT::JTreeWriterObjectOutput::Reset
void Reset()
Reset TTree.
Definition: JTreeWriterObjectOutput.hh:108
std
Definition: jaanetDictionary.h:36
JLANG::JAbstractPointer::get
virtual JClass_t * get() const =0
Get pointer.
JLANG::JStorage::release
void release()
Release memory.
Definition: JStorage.hh:91
JLANG::JThrow< JAccessible >::do_throw
static bool do_throw
throw option
Definition: JThrow.hh:28
JLANG::JException::what
virtual const char * what() const
Get error message.
Definition: JException.hh:65
JLANG::JStorage::reset
virtual void reset()
Reset pointer.
Definition: JStorage.hh:42
JSUPPORT::JTreeRecorder::open
virtual void open(const char *file_name)
Open file.
Definition: JTreeRecorder.hh:57
JROOT::JTreeWriterObjectOutput::out
JTreeWriter< T > * out
Definition: JTreeWriterObjectOutput.hh:78
JLANG::JAbstractPointer::is_valid
bool is_valid() const
Check validity of pointer.
Definition: JAbstractPointer.hh:83
JLANG::JAbstractPointer::set
virtual void set(JClass_t *p)=0
Set pointer.