File indexing completed on 2026-08-06 09:38:30
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef ThePEG_ReferenceCounted_H
0010 #define ThePEG_ReferenceCounted_H
0011
0012
0013
0014 #include "RCPtr.fh"
0015 #include "ThePEG/Persistency/PersistentIStream.fh"
0016
0017 namespace ThePEG {
0018 namespace Pointer {
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 class ReferenceCounted {
0031
0032
0033 friend class RCPtrBase;
0034 friend class ThePEG::PersistentIStream;
0035
0036 public:
0037
0038
0039
0040
0041 typedef unsigned int CounterType;
0042
0043 protected:
0044
0045
0046
0047
0048
0049
0050 ReferenceCounted()
0051 : uniqueId(++objectCounter),
0052 theReferenceCounter(CounterType(1)) {}
0053
0054
0055
0056
0057 ReferenceCounted(const ReferenceCounted &)
0058 : uniqueId(++objectCounter),
0059 theReferenceCounter(CounterType(1)) {}
0060
0061
0062
0063
0064 ReferenceCounted & operator=(const ReferenceCounted &)
0065 {
0066 return *this;
0067 }
0068
0069
0070
0071 public:
0072
0073
0074
0075
0076 CounterType referenceCount() const
0077 {
0078 return theReferenceCounter;
0079 }
0080
0081 private:
0082
0083
0084
0085
0086 void incrementReferenceCount() const
0087 {
0088 ++theReferenceCounter;
0089 }
0090
0091
0092
0093
0094 bool decrementReferenceCount() const
0095 {
0096 return !--theReferenceCounter;
0097 }
0098
0099 public:
0100
0101
0102
0103
0104 const unsigned long uniqueId;
0105
0106 private:
0107
0108
0109
0110
0111
0112 static unsigned long objectCounter;
0113
0114
0115
0116
0117 mutable CounterType theReferenceCounter;
0118
0119 };
0120
0121
0122 }
0123 }
0124
0125 #endif
0126