ATLAS Offline Software
Loading...
Searching...
No Matches
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):
15namespace std {
16 class type_info;
17}
18class TClass;
19
20namespace 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 {
107 }; // enum TypeKind
108
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
virtual ~THolder()
The destructor cleans out the memory used by the managed object.
Definition THolder.cxx:136
::Bool_t isOwner() const
Check whether the holder owns its object.
Definition THolder.cxx:253
void setConst()
Mark the object as const.
Definition THolder.cxx:285
TypeKind m_typeKind
Type of the object held.
Definition THolder.h:131
THolder & operator=(const THolder &rhs)
Assignment operator.
Definition THolder.cxx:151
THolder()
Default constructor.
Definition THolder.cxx:54
void setOwner(::Bool_t state=kTRUE)
Set whether the holder should own its object.
Definition THolder.cxx:258
::Bool_t isConst() const
Check if the object is const.
Definition THolder.cxx:280
const std::type_info * getTypeInfo() const
Definition THolder.cxx:412
void ** getPtr()
Return a typeless pointer to the held object's pointer.
Definition THolder.cxx:226
virtual void set(void *obj)
Replace the managed object.
Definition THolder.cxx:231
void * m_object
Typeless pointer to the object in memory.
Definition THolder.h:123
void deleteObject()
Internal function used to delete the managed object from memory.
Definition THolder.cxx:438
void renew()
Renew the object in memory.
Definition THolder.cxx:421
const ::TClass * getClass() const
Definition THolder.cxx:402
virtual void * getAs(const std::type_info &tid, ::Bool_t silent=kFALSE) const
Return the object as a specific pointer.
Definition THolder.cxx:371
::TClass * m_type
Concrete type of the object being held on to.
Definition THolder.h:125
TypeKind typeKind() const
Return the type of the object held by this one.
Definition THolder.h:110
::Bool_t m_const
Is the held object const?
Definition THolder.h:133
TypeKind
Type of the object held by this one.
Definition THolder.h:103
@ DATAVECTOR
A DataVector container.
Definition THolder.h:105
@ AUXELEMENT
A type inheriting from SG::AuxElement.
Definition THolder.h:106
@ OTHER
Some non-specified type.
Definition THolder.h:104
const std::type_info * m_typeInfo
Concrete type of the object, if it doesn't have a dictionary.
Definition THolder.h:127
void * getImpl(const std::type_info &tid, ::Bool_t silent=kFALSE) const
Internal function to get an object.
Definition THolder.cxx:297
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:395
const void * get() const
Return a typeless const pointer to the held object.
Definition THolder.cxx:216
::Bool_t m_owner
A flag for whether the object owns what it points to.
Definition THolder.h:129
STL namespace.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.