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

Go to the SVN repository for this file.

1 #ifndef NCBI_OBJMGR_SPLIT_ASN_SIZER__HPP
2 #define NCBI_OBJMGR_SPLIT_ASN_SIZER__HPP
3 
4 /* $Id: asn_sizer.hpp 33815 2007-05-04 17:18:18Z kazimird $
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 #include <corelib/ncbiobj.hpp>
40 
41 #include <serial/serial.hpp>
42 #include <serial/objostr.hpp>
43 
44 #include <vector>
45 
47 
48 class CObjectOStream;
49 
51 
52 struct SSplitterParams;
53 
54 class CAsnSizer
55 {
56 public:
57  CAsnSizer(void);
58  ~CAsnSizer(void);
59 
61  void CloseDataStream(void);
62 
63  size_t GetAsnSize(void) const
64  {
65  return m_AsnData.size();
66  }
67  const char* GetAsnData(void) const
68  {
69  return &m_AsnData.front();
70  }
71  size_t GetCompressedSize(void) const
72  {
73  return m_CompressedData.size();
74  }
75  const char* GetCompressedData(void) const
76  {
77  return &m_CompressedData.front();
78  }
79  size_t GetCompressedSize(const SSplitterParams& params);
80 
81  template<class C>
82  void Set(const C& obj)
83  {
84  OpenDataStream() << obj;
86  }
87  template<class C>
88  void Set(const C& obj, const SSplitterParams& params)
89  {
90  Set(obj);
91  GetCompressedSize(params);
92  }
93 
94  template<class C>
95  size_t GetAsnSize(const C& obj)
96  {
97  Set(obj);
98  return GetAsnSize();
99  }
100 
101  template<class C>
102  size_t GetCompressedSize(const C& obj, const SSplitterParams& params)
103  {
104  Set(obj, params);
105  return GetCompressedSize();
106  }
107 
108  // stream utility
109  vector<char> m_AsnData;
110  vector<char> m_CompressedData;
113 };
114 
115 
118 
119 #endif//NCBI_OBJMGR_SPLIT_ASN_SIZER__HPP
AutoPtr –.
Definition: ncbimisc.hpp:401
size_t GetAsnSize(void) const
Definition: asn_sizer.hpp:63
const char * GetAsnData(void) const
Definition: asn_sizer.hpp:67
AutoPtr< CObjectOStream > m_OStream
Definition: asn_sizer.hpp:112
void Set(const C &obj)
Definition: asn_sizer.hpp:82
vector< char > m_AsnData
Definition: asn_sizer.hpp:109
~CAsnSizer(void)
Definition: asn_sizer.cpp:50
size_t GetAsnSize(const C &obj)
Definition: asn_sizer.hpp:95
size_t GetCompressedSize(void) const
Definition: asn_sizer.hpp:71
void CloseDataStream(void)
Definition: asn_sizer.cpp:66
vector< char > m_CompressedData
Definition: asn_sizer.hpp:110
CAsnSizer(void)
Definition: asn_sizer.cpp:45
AutoPtr< CNcbiOstrstream > m_MStream
Definition: asn_sizer.hpp:111
const char * GetCompressedData(void) const
Definition: asn_sizer.hpp:75
size_t GetCompressedSize(const C &obj, const SSplitterParams &params)
Definition: asn_sizer.hpp:102
CObjectOStream & OpenDataStream(void)
Definition: asn_sizer.cpp:55
void Set(const C &obj, const SSplitterParams &params)
Definition: asn_sizer.hpp:88
CObjectOStream –.
Definition: objostr.hpp:83
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define C(s)
Definition: common.h:231
#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
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Modified on Sun Apr 21 03:44:10 2024 by modify_doxy.py rev. 669887