ATLAS Offline Software
THolder.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 //
3 // Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4 //
5 #ifndef XAODROOTACCESS_TOOLS_THOLDER_H
6 #define XAODROOTACCESS_TOOLS_THOLDER_H
7 
8 // STL include(s):
9 #include <map>
10 
11 // ROOT include(s):
12 #include <Rtypes.h>
13 
14 // Forward declaration(s):
15 namespace std {
16  class type_info;
17 }
18 class TClass;
19 
20 namespace xAOD {
21 
35  class THolder {
36 
37  public:
39  THolder();
41  THolder( void* object, ::TClass* type, ::Bool_t owner = kTRUE );
43  THolder( void* object, const std::type_info& type,
44  ::Bool_t owner = kTRUE );
45 
47  THolder( const void* object, ::TClass* type, ::Bool_t owner = kTRUE );
49  THolder( const void* object, const std::type_info& type,
50  ::Bool_t owner = kTRUE );
51 
53  THolder( const THolder& parent );
55  THolder( THolder&& parent );
57  virtual ~THolder();
58 
60  THolder& operator=( const THolder& rhs );
62  THolder& operator=( THolder&& rhs );
63 
65  const void* get() const;
67  void* get();
68 
70  void** getPtr();
71 
73  virtual void set( void* obj );
74 
76  ::Bool_t isOwner() const;
78  void setOwner( ::Bool_t state = kTRUE );
79 
81  ::Bool_t isConst() const;
83  void setConst();
84 
86  virtual void* getAs( const std::type_info& tid,
87  ::Bool_t silent = kFALSE ) const;
89  virtual const void* getAsConst( const std::type_info& tid,
90  ::Bool_t silent = kFALSE ) const;
91 
94  const ::TClass* getClass() const;
95  ::TClass* getClass();
96  const std::type_info* getTypeInfo() const;
98 
100  void renew();
101 
103  enum TypeKind {
106  AUXELEMENT
107  }; // enum TypeKind
108 
110  TypeKind typeKind() const {
111  return m_typeKind;
112  }
113 
114  protected:
116  void deleteObject();
117 
119  void* getImpl( const std::type_info& tid,
120  ::Bool_t silent = kFALSE ) const;
121 
123  void* m_object;
125  ::TClass* m_type;
127  const std::type_info* m_typeInfo;
129  ::Bool_t m_owner;
133  ::Bool_t m_const;
134 
135  }; // class THolder
136 
137 } // namespace xAOD
138 
139 #endif // XAODROOTACCESS_TOOLS_THOLDER_H
xAOD::THolder::OTHER
@ OTHER
Some non-specified type.
Definition: THolder.h:104
xAOD::THolder::isConst
::Bool_t isConst() const
Check if the object is const.
Definition: THolder.cxx:279
xAOD::THolder::operator=
THolder & operator=(const THolder &rhs)
Assignment operator.
Definition: THolder.cxx:150
xAOD::THolder::AUXELEMENT
@ AUXELEMENT
A type inheriting from SG::AuxElement.
Definition: THolder.h:106
xAOD::THolder::m_owner
::Bool_t m_owner
A flag for whether the object owns what it points to.
Definition: THolder.h:129
xAOD::THolder::setConst
void setConst()
Mark the object as const.
Definition: THolder.cxx:284
xAOD::THolder::setOwner
void setOwner(::Bool_t state=kTRUE)
Set whether the holder should own its object.
Definition: THolder.cxx:257
xAOD::THolder::DATAVECTOR
@ DATAVECTOR
A DataVector container.
Definition: THolder.h:105
xAOD::THolder::getAs
virtual void * getAs(const std::type_info &tid, ::Bool_t silent=kFALSE) const
Return the object as a specific pointer.
Definition: THolder.cxx:370
xAOD::THolder
This class takes care of holding EDM objects in memory.
Definition: THolder.h:35
xAOD::THolder::TypeKind
TypeKind
Type of the object held by this one.
Definition: THolder.h:103
xAOD::THolder::getPtr
void ** getPtr()
Return a typeless pointer to the held object's pointer.
Definition: THolder.cxx:225
xAOD::THolder::get
const void * get() const
Return a typeless const pointer to the held object.
Definition: THolder.cxx:215
xAOD::THolder::isOwner
::Bool_t isOwner() const
Check whether the holder owns its object.
Definition: THolder.cxx:252
xAOD::THolder::getImpl
void * getImpl(const std::type_info &tid, ::Bool_t silent=kFALSE) const
Internal function to get an object.
Definition: THolder.cxx:296
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::THolder::deleteObject
void deleteObject()
Internal function used to delete the managed object from memory.
Definition: THolder.cxx:437
xAOD::THolder::getClass
const ::TClass * getClass() const
Definition: THolder.cxx:401
xAOD::THolder::typeKind
TypeKind typeKind() const
Return the type of the object held by this one.
Definition: THolder.h:110
xAOD::THolder::m_typeKind
TypeKind m_typeKind
Type of the object held.
Definition: THolder.h:131
xAOD::THolder::m_const
::Bool_t m_const
Is the held object const?
Definition: THolder.h:133
xAOD::THolder::set
virtual void set(void *obj)
Replace the managed object.
Definition: THolder.cxx:230
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::THolder::m_object
void * m_object
Typeless pointer to the object in memory.
Definition: THolder.h:123
xAOD::THolder::m_type
::TClass * m_type
Concrete type of the object being held on to.
Definition: THolder.h:125
xAOD::THolder::THolder
THolder()
Default constructor.
Definition: THolder.cxx:54
xAOD::THolder::renew
void renew()
Renew the object in memory.
Definition: THolder.cxx:420
python.trfDecorators.silent
def silent(func)
Redirect stdout/err to /dev/null Useful wrapper to get rid of ROOT verbosity...
Definition: trfDecorators.py:24
xAOD::THolder::getTypeInfo
const std::type_info * getTypeInfo() const
Definition: THolder.cxx:411
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::THolder::getAsConst
virtual const void * getAsConst(const std::type_info &tid, ::Bool_t silent=kFALSE) const
Return the object as a specific, constant pointer.
Definition: THolder.cxx:394
xAOD::THolder::m_typeInfo
const std::type_info * m_typeInfo
Concrete type of the object, if it doesn't have a dictionary.
Definition: THolder.h:127
xAOD::THolder::~THolder
virtual ~THolder()
The destructor cleans out the memory used by the managed object.
Definition: THolder.cxx:135
python.PyAthena.obj
obj
Definition: PyAthena.py:132