cgv
Loading...
Searching...
No Matches
ref_counted.h
1#pragma once
2
3namespace cgv {
4 namespace data {
5
6class ref_ptr_tag;
7
11{
12private:
14 mutable int ref_count;
15protected:
16 friend class ref_ptr_tag;
18 inline ref_counted() : ref_count(0) {}
20 inline void set_ref_count(int c) const { ref_count = c; }
21public:
23 inline int get_ref_count() const { return ref_count; }
24};
25
26 }
27}
if you derive your class from this class, a ref_ptr will do reference counting in the inhereted ref_c...
Definition ref_counted.h:11
ref_counted()
constructor initializes the count to 0
Definition ref_counted.h:18
int get_ref_count() const
read access to current count
Definition ref_counted.h:23
void set_ref_count(int c) const
write access is also const to allow ref counted pointers to const instances
Definition ref_counted.h:20
struct used to make ref pointers to ref_counted friends of ref_counted
Definition ref_ptr.h:23
the cgv namespace
Definition print.h:11