| Face Engine SDK 5.2.0 A face detection, recognition and tracking engine.

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
RefBase.h
1 #pragma once
2
3 namespace fsdk
4 {
14 template<typename T>
15 struct RefBase {
16
19 RefBase() noexcept : m_ptr(nullptr) {}
20
24 explicit RefBase(T* ptr) noexcept : m_ptr(ptr) {}
25
30 operator T* () const noexcept {
31 return get();
32 }
33
37 T& operator * () const noexcept {
38 assert(!isNull());
39 return *get();
40 }
41
45 operator bool () const noexcept {
46 return !isNull();
47 }
48
53 bool operator == (const RefBase& other) const noexcept {
54 return get() == other.get();
55 }
56
61 bool operator != (const RefBase& other) const noexcept {
62 return !(*this == other);
63 }
64
68 bool isNull() const noexcept {
69 return get() == nullptr;
70 }
71
75 bool isExpired() const noexcept {
76 assert(!isNull());
77 return get()->getRefCount() == 0;
78 }
79
83 bool isUnique() const noexcept {
84 assert(!isNull());
85 return get()->getRefCount() == 1;
86 }
87
91 T* get() const noexcept {
92 return m_ptr;
93 }
94
99 void set(T* ptr) noexcept {
100 m_ptr = ptr;
101 }
102
103 protected:
104 T* m_ptr;
105 };
106 }
fsdk::RefBase::operator!=
bool operator!=(const RefBase &other) const noexcept
Check if two refs are not the same.
Definition: RefBase.h:61
fsdk::RefBase::isUnique
bool isUnique() const noexcept
Check if object has only one strong reference.
Definition: RefBase.h:83
fsdk::RefBase::RefBase
RefBase(T *ptr) noexcept
Initializes object pointer with ptr.
Definition: RefBase.h:24
fsdk::RefBase::RefBase
RefBase() noexcept
Initializes object pointer to nullptr.
Definition: RefBase.h:19
fsdk::RefBase
Generic base class of a pointer for reference counted objects.
Definition: RefBase.h:15
fsdk::RefBase::operator*
T & operator*() const noexcept
Dereference operator.
Definition: RefBase.h:37
fsdk::RefBase::m_ptr
T * m_ptr
Raw pointer.
Definition: RefBase.h:104
fsdk::RefBase::isExpired
bool isExpired() const noexcept
Check is object is dead.
Definition: RefBase.h:75
fsdk::RefBase::set
void set(T *ptr) noexcept
Replace object pointer without any checks or reference management.
Definition: RefBase.h:99
fsdk::RefBase::isNull
bool isNull() const noexcept
Check for nullptr.
Definition: RefBase.h:68
fsdk::RefBase::operator==
bool operator==(const RefBase &other) const noexcept
Check if two refs are the same.
Definition: RefBase.h:53