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

Sizer.h
1 #pragma once
2
3 #include <cstddef>
4 #include <utility>
5
6 namespace fsdk {
9 struct Sizer {
10
13 Sizer() noexcept {
14 reset();
15 }
16
20 Sizer(const Sizer& other) noexcept {
21 *this = other;
22 }
23
27 void append(size_t bytes) noexcept {
28 m_bytes += bytes;
29 }
30
34 void append(const Sizer& other) noexcept {
35 append(other.m_bytes);
36 }
37
39 void reset() noexcept {
40 m_bytes = 0u;
41 }
42
46 size_t getBytes() const noexcept {
47 return m_bytes;
48 }
49
53 size_t getKBytes() const noexcept {
54 return getBytes() >> 10;
55 }
56
60 size_t getMBytes() const noexcept {
61 return getKBytes() >> 10;
62 }
63
67 size_t getGBytes() const noexcept {
68 return getMBytes() >> 10;
69 }
70
72 operator size_t() const noexcept {
73 return m_bytes;
74 }
75
79 bool isEmpty() const noexcept {
80 return m_bytes == 0u;
81 }
82
86 operator bool() const noexcept {
87 return !isEmpty();
88 }
89
94 Sizer& operator<<(size_t bytes) noexcept {
95 append(bytes);
96 return *this;
97 }
98
103 Sizer& operator<<(const Sizer& other) noexcept {
104 append(other);
105 return *this;
106 }
107
112 Sizer& operator=(const Sizer& other) noexcept {
113 m_bytes = other.m_bytes;
114 return *this;
115 }
116
121 bool operator==(const Sizer& other) const noexcept {
122 return m_bytes == other.m_bytes;
123 }
124
129 bool operator!=(const Sizer& other) const noexcept {
130 return !(*this == other);
131 }
132
136 void swap(Sizer& other) noexcept {
137 std::swap(m_bytes, other.m_bytes);
138 }
139
140 protected:
141 size_t m_bytes;
142 };
143 } // namespace fsdk
fsdk::Sizer::operator!=
bool operator!=(const Sizer &other) const noexcept
Check if two sizers are not equal.
Definition: Sizer.h:129
fsdk::Sizer::swap
void swap(Sizer &other) noexcept
Definition: Sizer.h:136
fsdk::Sizer::append
void append(size_t bytes) noexcept
Append bytes to current byte count.
Definition: Sizer.h:27
fsdk
SDK namespace.
Definition: IAGSEstimator.h:8
fsdk::Sizer::getMBytes
size_t getMBytes() const noexcept
Get current size.
Definition: Sizer.h:60
fsdk::Sizer::Sizer
Sizer(const Sizer &other) noexcept
Initializes sizer with another sizer value.
Definition: Sizer.h:20
fsdk::Sizer::getBytes
size_t getBytes() const noexcept
Get current size.
Definition: Sizer.h:46
fsdk::Sizer::m_bytes
size_t m_bytes
Current measured size in bytes.
Definition: Sizer.h:141
fsdk::Sizer::Sizer
Sizer() noexcept
Initializes sizer with zero.
Definition: Sizer.h:13
fsdk::Sizer::getGBytes
size_t getGBytes() const noexcept
Get current size.
Definition: Sizer.h:67
fsdk::Sizer::operator=
Sizer & operator=(const Sizer &other) noexcept
Assign value of another sizer.
Definition: Sizer.h:112
fsdk::Sizer::operator<<
Sizer & operator<<(const Sizer &other) noexcept
Append other sizer byte count to current byte count.
Definition: Sizer.h:103
fsdk::Sizer::append
void append(const Sizer &other) noexcept
Append other sizer byte count to current byte count.
Definition: Sizer.h:34
fsdk::Sizer::getKBytes
size_t getKBytes() const noexcept
Get current size.
Definition: Sizer.h:53
fsdk::Sizer::isEmpty
bool isEmpty() const noexcept
Check whether size is zero.
Definition: Sizer.h:79
fsdk::Sizer::operator<<
Sizer & operator<<(size_t bytes) noexcept
Append bytes to current byte count.
Definition: Sizer.h:94
fsdk::Sizer::reset
void reset() noexcept
Reset byte count to zero.
Definition: Sizer.h:39
fsdk::Sizer
Helper entity to measure size of dynamic objects in memory.
Definition: Sizer.h:9
fsdk::Sizer::operator==
bool operator==(const Sizer &other) const noexcept
Check if two sizers are equal.
Definition: Sizer.h:121