globjects  1.0.0.ae1b474792ef
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>
bool operator>(const ref_ptr &reference) const
The ref_ptr class provides the interface for a reference pointer.
Definition: LogMessageBuilder.h:20
Contains all the classes that wrap OpenGL functionality.
ref_ptr & operator=(T *referenced)
const Referenced * m_referenced
Definition: ref_ptr.h:67
bool operator==(const ref_ptr &reference) const
T * operator->() const
bool operator!=(const ref_ptr &reference) const
T & operator*() const
ref_ptr< T > make_ref(Args &&...args)
Superclass for all classes that use reference counting in globjects.
Definition: Referenced.h:22
bool operator<(const ref_ptr &reference) const