Line data Source code
1 : /*! 2 : * \file esys/repo/progress/transfercounters.cpp 3 : * \brief 4 : * 5 : * \cond 6 : * __legal_b__ 7 : * 8 : * Copyright (c) 2026 Michel Gillet 9 : * Distributed under the MIT License. 10 : * (See accompanying file LICENSE.txt or 11 : * copy at https://opensource.org/licenses/MIT) 12 : * 13 : * __legal_e__ 14 : * \endcond 15 : * 16 : */ 17 : 18 : #include "esys/repo/esysrepo_prec.h" 19 : #include "esys/repo/progress/transfercounters.h" 20 : 21 : namespace esys::repo::progress 22 : { 23 : 24 2564 : TransferCounters::TransferCounters() = default; 25 : 26 3731 : TransferCounters::~TransferCounters() = default; 27 : 28 1158 : void TransferCounters::set_total_objects(int total_objects) 29 : { 30 1158 : m_total_objects = total_objects; 31 1158 : } 32 : 33 1664 : int TransferCounters::get_total_objects() const 34 : { 35 1664 : return m_total_objects; 36 : } 37 : 38 1159 : void TransferCounters::set_received_objects(int received_objects) 39 : { 40 1159 : m_received_objects = received_objects; 41 1159 : } 42 : 43 641 : int TransferCounters::get_received_objects() const 44 : { 45 641 : return m_received_objects; 46 : } 47 : 48 1156 : void TransferCounters::set_indexed_objects(int indexed_objects) 49 : { 50 1156 : m_indexed_objects = indexed_objects; 51 1156 : } 52 : 53 0 : int TransferCounters::get_indexed_objects() const 54 : { 55 0 : return m_indexed_objects; 56 : } 57 : 58 1156 : void TransferCounters::set_total_deltas(int total_deltas) 59 : { 60 1156 : m_total_deltas = total_deltas; 61 1156 : } 62 : 63 466 : int TransferCounters::get_total_deltas() const 64 : { 65 466 : return m_total_deltas; 66 : } 67 : 68 1156 : void TransferCounters::set_indexed_deltas(int indexed_deltas) 69 : { 70 1156 : m_indexed_deltas = indexed_deltas; 71 1156 : } 72 : 73 131 : int TransferCounters::get_indexed_deltas() const 74 : { 75 131 : return m_indexed_deltas; 76 : } 77 : 78 1 : void TransferCounters::set_total_checkout_steps(int total_checkout_steps) 79 : { 80 1 : m_total_checkout_steps = total_checkout_steps; 81 1 : } 82 : 83 388 : int TransferCounters::get_total_checkout_steps() const 84 : { 85 388 : return m_total_checkout_steps; 86 : } 87 : 88 1 : void TransferCounters::set_checkout_steps(int checkout_steps) 89 : { 90 1 : m_checkout_steps = checkout_steps; 91 1 : } 92 : 93 1 : int TransferCounters::get_checkout_steps() const 94 : { 95 1 : return m_checkout_steps; 96 : } 97 : 98 1156 : void TransferCounters::set_received_bytes(std::int64_t received_bytes) 99 : { 100 1156 : m_received_bytes = received_bytes; 101 1156 : } 102 : 103 1 : std::int64_t TransferCounters::get_received_bytes() const 104 : { 105 1 : return m_received_bytes; 106 : } 107 : 108 2 : void TransferCounters::mark_complete() 109 : { 110 6 : const auto snap = [](int ¤t, int &total) { 111 6 : if (total <= 0) 112 : { 113 5 : total = 1; 114 5 : current = 1; 115 5 : return; 116 : } 117 1 : if (current < total) current = total; 118 : }; 119 : 120 2 : snap(m_received_objects, m_total_objects); 121 2 : if (m_indexed_objects < m_total_objects) m_indexed_objects = m_total_objects; 122 2 : snap(m_indexed_deltas, m_total_deltas); 123 2 : snap(m_checkout_steps, m_total_checkout_steps); 124 2 : } 125 : 126 2 : bool TransferCounters::operator==(const TransferCounters &other) const 127 : { 128 2 : return (m_total_objects == other.m_total_objects) && (m_received_objects == other.m_received_objects) 129 1 : && (m_indexed_objects == other.m_indexed_objects) && (m_total_deltas == other.m_total_deltas) 130 : && (m_indexed_deltas == other.m_indexed_deltas) 131 1 : && (m_total_checkout_steps == other.m_total_checkout_steps) 132 3 : && (m_checkout_steps == other.m_checkout_steps) && (m_received_bytes == other.m_received_bytes); 133 : } 134 : 135 1 : bool TransferCounters::operator!=(const TransferCounters &other) const 136 : { 137 1 : return !operator==(other); 138 : } 139 : 140 : } // namespace esys::repo::progress