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