[ozulis] trying to debug current memory management
[ozulis.git] / src / ozulis / core / ref-counted-object.hh
blobc5ba33109d3cbfc96c156ffd660362acd99bc6d3
1 #ifndef OZULIS_CORE_REF_COUNTED_OBJECT_HH
2 # define OZULIS_CORE_REF_COUNTED_OBJECT_HH
4 # include <stdint.h>
6 namespace ozulis
8 namespace core
10 class RefCountedObject
12 public:
13 inline RefCountedObject();
14 virtual ~RefCountedObject();
16 inline uint32_t refCount() const;
17 void use();
18 void release();
20 template <class T>
21 class Ptr
23 public:
24 typedef T * ptr_t;
26 inline Ptr();
27 template <class V>
28 inline Ptr(const Ptr<V> &);
29 inline Ptr(const Ptr<T> &);
30 inline Ptr(T * ptr);
31 inline ~Ptr();
33 inline T & operator*();
34 inline const T & operator*() const;
36 inline T * operator->();
37 inline const T * operator->() const;
39 inline void operator=(T const * ptr);
40 template <class V>
41 inline void operator=(V * ptr);
42 template <class V>
43 inline void operator=(Ptr<V> const & ptr);
44 inline void operator=(Ptr<T> const & ptr);
46 inline operator T *();
47 inline operator const T *() const;
48 inline operator bool() const;
49 template <class V>
50 inline operator Ptr<V> ();
52 inline T * ptr();
53 inline const T * ptr() const;
55 private:
56 T * ptr_;
59 private:
60 int32_t refCount_;
65 # include "ref-counted-object.hxx"
67 #endif /* !OZULIS_CORE_REF_COUNTED_OBJECT_HH */