Face Engine SDK  5.25.0
A face detection, recognition and tracking engine.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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
bool operator!=(const Sizer &other) const noexcept
Check if two sizers are not equal.
Definition: Sizer.h:129
void swap(Sizer &other) noexcept
Definition: Sizer.h:136
void append(size_t bytes) noexcept
Append bytes to current byte count.
Definition: Sizer.h:27
size_t getMBytes() const noexcept
Get current size.
Definition: Sizer.h:60
Sizer(const Sizer &other) noexcept
Initializes sizer with another sizer value.
Definition: Sizer.h:20
size_t getBytes() const noexcept
Get current size.
Definition: Sizer.h:46
size_t m_bytes
Current measured size in bytes.
Definition: Sizer.h:141
Sizer() noexcept
Initializes sizer with zero.
Definition: Sizer.h:13
size_t getGBytes() const noexcept
Get current size.
Definition: Sizer.h:67
Sizer & operator=(const Sizer &other) noexcept
Assign value of another sizer.
Definition: Sizer.h:112
Sizer & operator<<(const Sizer &other) noexcept
Append other sizer byte count to current byte count.
Definition: Sizer.h:103
void append(const Sizer &other) noexcept
Append other sizer byte count to current byte count.
Definition: Sizer.h:34
size_t getKBytes() const noexcept
Get current size.
Definition: Sizer.h:53
bool isEmpty() const noexcept
Check whether size is zero.
Definition: Sizer.h:79
Sizer & operator<<(size_t bytes) noexcept
Append bytes to current byte count.
Definition: Sizer.h:94
void reset() noexcept
Reset byte count to zero.
Definition: Sizer.h:39
Helper entity to measure size of dynamic objects in memory.
Definition: Sizer.h:9
bool operator==(const Sizer &other) const noexcept
Check if two sizers are equal.
Definition: Sizer.h:121