NCBI C++ ToolKit
size.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef NCBI_OBJMGR_SPLIT_SIZE__HPP
2 #define NCBI_OBJMGR_SPLIT_SIZE__HPP
3 
4 /* $Id: size.hpp 87845 2019-10-10 16:05:19Z vasilche $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Eugene Vasilchenko
30 *
31 * File Description:
32 * Application for splitting blobs withing ID1 cache
33 *
34 * ===========================================================================
35 */
36 
37 
38 #include <corelib/ncbistd.hpp>
39 
42 
43 class CAsnSizer;
44 
45 class CSize
46 {
47 public:
48  typedef size_t TDataSize;
49  typedef pair<TDataSize, TDataSize> TSizeRatio;
50 
51  CSize(void)
52  {
53  clear();
54  }
55  CSize(const CAsnSizer& sizer);
56  CSize(TDataSize asn_size, TSizeRatio ratio);
57 
58  void clear(void)
59  {
60  m_Count = 0;
61  m_AsnSize = 0;
62  m_ZipSize = 0;
63  }
64 
66  {
67  m_Count += size.m_Count;
68  m_AsnSize += size.m_AsnSize;
69  m_ZipSize += size.m_ZipSize;
70  return *this;
71  }
73  {
74  m_Count -= size.m_Count;
75  m_AsnSize -= size.m_AsnSize;
76  m_ZipSize -= size.m_ZipSize;
77  return *this;
78  }
79  CSize operator+(const CSize& size) const
80  {
81  CSize ret(*this);
82  ret += size;
83  return ret;
84  }
85 
86  size_t GetCount(void) const
87  {
88  return m_Count;
89  }
90  TDataSize GetAsnSize(void) const
91  {
92  return m_AsnSize;
93  }
94  TDataSize GetZipSize(void) const
95  {
96  return m_ZipSize;
97  }
98  double GetRatio(void) const
99  {
100  return (double)m_ZipSize/(double)m_AsnSize;
101  }
103  {
104  return TSizeRatio(m_ZipSize, m_AsnSize);
105  }
106 
108 
110 
111  bool operator>(const CSize& size) const
112  {
113  return m_ZipSize > size.m_ZipSize;
114  }
115 
116  int Compare(const CSize& size) const;
117 
118 private:
119  size_t m_Count;
122 };
123 
124 inline
126 {
127  return size.Print(out);
128 }
129 
132 
133 #endif//NCBI_OBJMGR_SPLIT_SIZE__HPP
Definition: size.hpp:46
DECLARE_OPERATOR_BOOL(m_Count !=0)
CSize operator+(const CSize &size) const
Definition: size.hpp:79
TDataSize m_AsnSize
Definition: size.hpp:120
CNcbiOstream & Print(CNcbiOstream &out) const
Definition: size.cpp:97
void clear(void)
Definition: size.hpp:58
pair< TDataSize, TDataSize > TSizeRatio
Definition: size.hpp:49
size_t m_Count
Definition: size.hpp:119
CSize & operator-=(const CSize &size)
Definition: size.hpp:72
TSizeRatio GetExactRatio(void) const
Definition: size.hpp:102
size_t GetCount(void) const
Definition: size.hpp:86
double GetRatio(void) const
Definition: size.hpp:98
bool operator>(const CSize &size) const
Definition: size.hpp:111
CSize & operator+=(const CSize &size)
Definition: size.hpp:65
CSize(void)
Definition: size.hpp:51
TDataSize GetZipSize(void) const
Definition: size.hpp:94
size_t TDataSize
Definition: size.hpp:48
TDataSize GetAsnSize(void) const
Definition: size.hpp:90
TDataSize m_ZipSize
Definition: size.hpp:121
int Compare(const CSize &size) const
Definition: size.cpp:58
Include a standard set of the NCBI C++ Toolkit most basic headers.
std::ofstream out("events_result.xml")
main entry point for tests
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
const struct ncbi::grid::netcache::search::fields::SIZE size
CNcbiOstream & operator<<(CNcbiOstream &out, const CSize &size)
Definition: size.hpp:125
Modified on Mon Mar 04 05:15:08 2024 by modify_doxy.py rev. 669887