GeoModel - GeoModelCore
RCBase.h
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
19 #ifndef GEOMODELKERNEL_RCBASE_H
20 #define GEOMODELKERNEL_RCBASE_H
21 
22 #include <atomic>
23 
24 class RCBase
25 {
26  public:
27  RCBase();
28 
29  // Increase the reference count
30  void ref () const;
31 
32  // Decreases the reference count. When the reference count
33  // falls to zero, the object deletes itself.
34  void unref () const;
35 
36  // Return the reference count.
37  unsigned int refCount () const;
38 
39  protected:
40  virtual ~RCBase();
41 
42  private:
43  RCBase(const RCBase &right);
44  RCBase & operator=(const RCBase &right);
45 
46  // The reference count
47  mutable std::atomic<unsigned> m_count;
48 
49 };
50 
51 #endif
This is a base class for objects whose memory is managed through reference counting. Reference-counted objects can only be created using operator new, the cannot be created on the stack.
Definition: RCBase.h:24