AliPhysics  ad6828d (ad6828d)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalManagedObject Class Reference

Smart pointer implementation for objects inheriting from TObject. More...

#include <AliEmcalTrackSelection.h>

Inheritance diagram for AliEmcalManagedObject:

Public Member Functions

 AliEmcalManagedObject ()
 Dummy constructor. More...
 
 AliEmcalManagedObject (TObject *object, bool owner=true)
 Default constructor, creates new managed object. More...
 
 AliEmcalManagedObject (const AliEmcalManagedObject &ref)
 Copy constructor. More...
 
AliEmcalManagedObjectoperator= (const AliEmcalManagedObject &ref)
 
virtual ~AliEmcalManagedObject ()
 
 operator bool () const
 Check whether a managed object is set. More...
 
bool IsOwner () const
 Checks whether the object is set. More...
 
void SetOwner (bool owner=true)
 Specifying ownership over object. More...
 
void SetObject (TObject *managedObject, bool owner=true)
 Set new managed object with ownership. More...
 
TObjectGetObject ()
 Providing access to managed object. More...
 

Protected Member Functions

void Cleanup ()
 

Private Attributes

Bool_t fOwner
 Switch defining ownership over object. More...
 
TObjectfManagedObject
 Pointer to object handled by the smart pointer. More...
 

Detailed Description

Smart pointer implementation for objects inheriting from TObject.

Author
Markus Fasel marku.nosp@m.s.fa.nosp@m.sel@c.nosp@m.ern..nosp@m.ch, Oak Ridge National Laboratory
Since
March 2dn, 2017

Simple smart pointer implementation inheriting from TObject which defines ownership in an object-by-object approach. The pointer will handle deletes only in case it is owner over the object.

Attention: This is a simplified version of a smart pointer, different pointers do not know from each other, which might lead into troubles once the object is copied. Can be done in a much more elegant way using c++11 shared_ptr.

Definition at line 31 of file AliEmcalTrackSelection.h.

Constructor & Destructor Documentation

AliEmcalManagedObject::AliEmcalManagedObject ( )

Dummy constructor.

Definition at line 176 of file AliEmcalTrackSelection.cxx.

AliEmcalManagedObject::AliEmcalManagedObject ( TObject object,
bool  owner = true 
)

Default constructor, creates new managed object.

Parameters
[in]objectManaged object
[in]ownerFlag for ownership

Definition at line 184 of file AliEmcalTrackSelection.cxx.

AliEmcalManagedObject::AliEmcalManagedObject ( const AliEmcalManagedObject ref)

Copy constructor.

By default the new smart pointer will not own the object of the reference smart pointer.

Parameters
[in]refReference for the copy

Definition at line 191 of file AliEmcalTrackSelection.cxx.

virtual AliEmcalManagedObject::~AliEmcalManagedObject ( )
inlinevirtual

Destructor, will delete the managed object in case it is the owner

Definition at line 66 of file AliEmcalTrackSelection.h.

Member Function Documentation

void AliEmcalManagedObject::Cleanup ( )
protected

Cleanup managed object (remove if pointer is owner)

Definition at line 209 of file AliEmcalTrackSelection.cxx.

Referenced by operator=(), SetObject(), and ~AliEmcalManagedObject().

TObject* AliEmcalManagedObject::GetObject ( )
inline

Providing access to managed object.

Returns
Object managed by the smart pointer

Definition at line 103 of file AliEmcalTrackSelection.h.

Referenced by AliEmcalTrackSelection::GetTrackCuts(), and AliEmcalTrackSelectionESD::SaveQAObjects().

bool AliEmcalManagedObject::IsOwner ( ) const
inline

Checks whether the object is set.

Returns
True if pointer is owner of the object

Definition at line 78 of file AliEmcalTrackSelection.h.

AliEmcalManagedObject::operator bool ( ) const
inline

Check whether a managed object is set.

Returns
True if object is set, false otherwise

Definition at line 72 of file AliEmcalTrackSelection.h.

AliEmcalManagedObject & AliEmcalManagedObject::operator= ( const AliEmcalManagedObject ref)

Assignment operator By default the new smart pointer will not own the object of the reference smart pointer.

Parameters
[in]refReference for assignment
Returns
Pointer after assingment

Definition at line 198 of file AliEmcalTrackSelection.cxx.

void AliEmcalManagedObject::SetObject ( TObject managedObject,
bool  owner = true 
)
inline

Set new managed object with ownership.

In case the pointer managed already an object it will cleanup the object if necessary

Parameters
[in]managedObjectNew object managed by this smart pointer
[in]owenrOwnership status of the new object

Definition at line 93 of file AliEmcalTrackSelection.h.

void AliEmcalManagedObject::SetOwner ( bool  owner = true)
inline

Specifying ownership over object.

Parameters
[in]ownerOwnership (if true then object takes over ownership)

Definition at line 84 of file AliEmcalTrackSelection.h.

Referenced by AliEmcalTrackSelectionESD::SaveQAObjects().

Member Data Documentation

TObject* AliEmcalManagedObject::fManagedObject
private

Pointer to object handled by the smart pointer.

Definition at line 114 of file AliEmcalTrackSelection.h.

Referenced by Cleanup(), GetObject(), operator bool(), operator=(), and SetObject().

Bool_t AliEmcalManagedObject::fOwner
private

Switch defining ownership over object.

Definition at line 113 of file AliEmcalTrackSelection.h.

Referenced by Cleanup(), IsOwner(), operator=(), SetObject(), and SetOwner().


The documentation for this class was generated from the following files: