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

Sizer.h
1 #pragma once
2
3 #include <utility>
4 #include <cstddef>
5
6 namespace fsdk
7 {
10 struct Sizer {
11
14 Sizer() noexcept {
15 reset();
16 }
17
21 Sizer(const Sizer& other) noexcept {
22 *this = other;
23 }
24
28 void append(size_t bytes) noexcept {
29 m_bytes += bytes;
30 }
31
35 void append(const Sizer& other) noexcept {
36 append(other.m_bytes);
37 }
38
40 void reset() noexcept {
41 m_bytes = 0u;
42 }
43
47 size_t getBytes() const noexcept {
48 return m_bytes;
49 }
50
54 size_t getKBytes() const noexcept {
55 return getBytes() >> 10;
56 }
57
61 size_t getMBytes() const noexcept {
62 return getKBytes() >> 10;
63 }
64
68 size_t getGBytes() const noexcept {
69 return getMBytes() >> 10;
70 }
71
73 operator size_t () const noexcept {
74 return m_bytes;
75 }
76
80 bool isEmpty() const noexcept {
81 return m_bytes == 0u;
82 }
83
87 operator bool () const noexcept {
88 return !isEmpty();
89 }
90
95 Sizer& operator << (size_t bytes) noexcept {
96 append(bytes);
97 return *this;
98 }
99
104 Sizer& operator << (const Sizer& other) noexcept {
105 append(other);
106 return *this;
107 }
108
113 Sizer& operator = (const Sizer& other) noexcept {
114 m_bytes = other.m_bytes;
115 return *this;
116 }
117
122 bool operator == (const Sizer& other) const noexcept {
123 return m_bytes == other.m_bytes;
124 }
125
130 bool operator != (const Sizer& other) const noexcept {
131 return !(*this == other);
132 }
133
137 void swap(Sizer& other) noexcept {
138 std::swap(m_bytes, other.m_bytes);
139 }
140
141 protected:
142 size_t m_bytes;
143 };
144 }
145
fsdk::Sizer::swap
void swap(Sizer &other) noexcept
Definition: Sizer.h:137
fsdk::Sizer::getGBytes
size_t getGBytes() const noexcept
Get current size.
Definition: Sizer.h:68
fsdk::Sizer::Sizer
Sizer(const Sizer &other) noexcept
Initializes sizer with another sizer value.
Definition: Sizer.h:21
fsdk::Sizer::reset
void reset() noexcept
Reset byte count to zero.
Definition: Sizer.h:40
fsdk::Sizer::operator==
bool operator==(const Sizer &other) const noexcept
Check if two sizers are equal.
Definition: Sizer.h:122
fsdk::Sizer::append
void append(const Sizer &other) noexcept
Append other sizer byte count to current byte count.
Definition: Sizer.h:35
fsdk::Sizer::Sizer
Sizer() noexcept
Initializes sizer with zero.
Definition: Sizer.h:14
fsdk
SDK namespace.
Definition: IAGSEstimator.h:8
fsdk::Sizer::getMBytes
size_t getMBytes() const noexcept
Get current size.
Definition: Sizer.h:61
fsdk::Sizer::operator<<
Sizer & operator<<(size_t bytes) noexcept
Append bytes to current byte count.
Definition: Sizer.h:95
fsdk::Sizer::m_bytes
size_t m_bytes
Current measured size in bytes.
Definition: Sizer.h:142
fsdk::Sizer::operator!=
bool operator!=(const Sizer &other) const noexcept
Check if two sizers are not equal.
Definition: Sizer.h:130
fsdk::Sizer::append
void append(size_t bytes) noexcept
Append bytes to current byte count.
Definition: Sizer.h:28
fsdk::Sizer::getKBytes
size_t getKBytes() const noexcept
Get current size.
Definition: Sizer.h:54
fsdk::Sizer::isEmpty
bool isEmpty() const noexcept
Check whether size is zero.
Definition: Sizer.h:80
fsdk::Sizer::getBytes
size_t getBytes() const noexcept
Get current size.
Definition: Sizer.h:47
fsdk::Sizer::operator=
Sizer & operator=(const Sizer &other) noexcept
Assign value of another sizer.
Definition: Sizer.h:113
fsdk::Sizer
Helper entity to measure size of dynamic objects in memory.
Definition: Sizer.h:10