ThePEG  1.8.0
ReferenceCounted.h
1 // -*- C++ -*-
2 //
3 // ReferenceCounted.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_ReferenceCounted_H
10 #define ThePEG_ReferenceCounted_H
11 // This is the declaration of the ReferenceCounted class.
12 
13 
14 #include "RCPtr.fh"
15 #include "ThePEG/Persistency/PersistentIStream.fh"
16 
17 namespace ThePEG {
18 namespace Pointer {
19 
31 
33  friend class RCPtrBase;
34  friend class ThePEG::PersistentIStream;
35 
36 public:
37 
41  typedef unsigned int CounterType;
42 
43 protected:
44 
51  : uniqueId(++objectCounter),
53 
58  : uniqueId(++objectCounter),
60 
65  {
66  return *this;
67  }
68 
70 
71 public:
72 
77  {
78  return theReferenceCounter;
79  }
80 
81 private:
82 
87  {
89  }
90 
95  {
96  return !--theReferenceCounter;
97  }
98 
99 public:
100 
104  const unsigned long uniqueId;
105 
106 private:
107 
112  static unsigned long objectCounter;
113 
118 
119 };
120 
121 
122 }
123 }
124 
125 #endif /* ThePEG_ReferenceCounted_H */
126