Face Engine SDK  5.25.0
A face detection, recognition and tracking engine.
include/fsdk/Types/RefBase.h
00001 #pragma once
00002 
00003 #include <cstddef>
00004 
00005 namespace fsdk {
00015     template <typename T>
00016     struct RefBase {
00017 
00020         RefBase() noexcept = default;
00021 
00025         explicit RefBase(T* ptr) noexcept
00026             : m_ptr(ptr) {
00027         }
00028 
00033         operator T*() const noexcept {
00034             return get();
00035         }
00036 
00040         T& operator*() const noexcept {
00041             assert(!isNull());
00042             return *get();
00043         }
00044 
00048         operator bool() const noexcept {
00049             return !isNull();
00050         }
00051 
00056         bool operator==(const RefBase& other) const noexcept {
00057             return get() == other.get();
00058         }
00059 
00064         bool operator!=(const RefBase& other) const noexcept {
00065             return !(*this == other);
00066         }
00067 
00071         bool isNull() const noexcept {
00072             return get() == nullptr;
00073         }
00074 
00078         bool isExpired() const noexcept {
00079             assert(!isNull());
00080             return get()->getRefCount() == 0;
00081         }
00082 
00086         bool isUnique() const noexcept {
00087             assert(!isNull());
00088             return get()->getRefCount() == 1;
00089         }
00090 
00094         T* get() const noexcept {
00095             return m_ptr;
00096         }
00097 
00102         void set(T* ptr) noexcept {
00103             m_ptr = ptr;
00104         }
00105 
00106     protected:
00107         T* m_ptr{nullptr}; 
00108     };
00109 } // namespace fsdk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines