| globjects 1.0.0.000000000000 Strict OpenGL objects wrapper.

ref_ptr.h
Go to the documentation of this file.
1
2 #pragma once
3
4
5 namespace globjects
6 {
7
8
9 class Referenced;
10
31 template<typename T>
32 class ref_ptr
33 {
34 // static_assert(std::is_base_of<Referenced, T>::value, "T is not a subclass of Referenced");
35
36 public:
37 ref_ptr();
38 ref_ptr(T * referenced);
39 ref_ptr(const ref_ptr & reference);
40 ref_ptr(ref_ptr && reference);
41 ~ref_ptr();
42
43 ref_ptr & operator=(T * referenced);
44 ref_ptr & operator=(const ref_ptr & reference);
45
46 T * get() const;
47 T & operator*() const;
48 T * operator->() const;
49
50 operator T *() const;
51
52 bool operator<(const ref_ptr & reference) const;
53 bool operator>(const ref_ptr & reference) const;
54 bool operator==(const ref_ptr & reference) const;
55 bool operator!=(const ref_ptr & reference) const;
56
57 bool operator<(T * pointer) const;
58 bool operator>(T * pointer) const;
59 bool operator==(T * pointer) const;
60 bool operator!=(T * pointer) const;
61
62 protected:
63 void increaseRef();
64 void decreaseRef();
65
66 protected:
67 mutable const Referenced * m_referenced;
68 };
69
70 template<typename T, typename... Args>
71 ref_ptr<T> make_ref(Args&&... args);
72
73
74 } // namespace globjects
75
76
77 #include <globjects/base/ref_ptr.inl>
globjects::ref_ptr::decreaseRef
void decreaseRef()
globjects::ref_ptr
The ref_ptr class provides the interface for a reference pointer.
Definition: LogMessageBuilder.h:20
globjects::ref_ptr::increaseRef
void increaseRef()
globjects::ref_ptr::operator!=
bool operator!=(const ref_ptr &reference) const
globjects
Contains all the classes that wrap OpenGL functionality.
globjects::ref_ptr::operator*
T & operator*() const
globjects::make_ref
ref_ptr< T > make_ref(Args &&... args)
globjects::ref_ptr::operator=
ref_ptr & operator=(T *referenced)
globjects::ref_ptr::operator>
bool operator>(const ref_ptr &reference) const
globjects::ref_ptr::operator==
bool operator==(const ref_ptr &reference) const
globjects::ref_ptr::~ref_ptr
~ref_ptr()
globjects::ref_ptr::m_referenced
const Referenced * m_referenced
Definition: ref_ptr.h:67
globjects::ref_ptr::ref_ptr
ref_ptr()
globjects::ref_ptr::operator->
T * operator->() const
globjects::ref_ptr::operator<
bool operator<(const ref_ptr &reference) const
globjects::Referenced
Superclass for all classes that use reference counting in globjects.
Definition: Referenced.h:22