CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
ReferenceHolder.h
Go to the documentation of this file.
1#ifndef DCHAIN_REFERENCEHOLDER_H
2#define DCHAIN_REFERENCEHOLDER_H
3// -*- C++ -*-
4//
5// Package: DChain
6// Module: ReferenceHolder
7//
8// Description: Smart pointer for classes that inherit from ReferenceCount and who should not be modified
9//
10// Usage:
11// ReferenceHolder() - default constructor
12// ~ReferenceHolder() - destructor
13//
14// This class wraps a pointer to a class inheriting from ReferenceCount
15// and deals with proper handling of the reference counting used to
16// manage the objects lifetime
17//
18// ReferenceHolder<Foo> pFoo = new Foo;
19// pFoo->memberFunctionOfFoo();
20// takeReferenceToFoo( *pFoo);
21// takePointerToFoo( pFoo.pointer() );
22//
23// Author: Chris D. Jones
24// Created: Wed May 14 08:01:51 EDT 2003
25// $Id: ReferenceHolder.h,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $
26//
27// Revision history
28//
29// $Log: ReferenceHolder.h,v $
30// Revision 1.1.1.1 2009/03/03 06:06:56 maqm
31// first import of DecayChain
32//
33// Revision 1.1 2006/01/11 20:28:10 cdj
34// massive class renaming, addition of [] for selection and unit tests
35//
36// Revision 1.1 2003/05/15 19:56:01 cdj
37// revamped memory handling so always use a ReferenceHolder to deal with the reference counting
38//
39//
40
41// system include files
42#include <memory>
43
44// user include files
46
47// forward declarations
48namespace dchain {
49template< class T>
50class ReferenceHolder : public ReferenceHolderBase<const T*, const T&>
51{
52 public:
53 // Constructors and destructor
55 ReferenceHolder(const T* iRef) : ReferenceHolderBase<const T*, const T&>(iRef) {}
56 template<class THolder>
57 explicit ReferenceHolder(THolder iHolder):
58 ReferenceHolderBase<const T*, const T&>( &(*iHolder)) {}
59
60 explicit ReferenceHolder(std::auto_ptr<T> iHolder):
61 ReferenceHolderBase<const T*, const T&>(iHolder.release()) {}
62
63};
64}
65#endif // DCHAIN_REFERENCEHOLDER_H
struct sembuf release
ReferenceHolder(const T *iRef)
ReferenceHolder(THolder iHolder)
ReferenceHolder(std::auto_ptr< T > iHolder)