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

Go to the SVN repository for this file.

1 #ifndef ASN_CACHE_SEQ_ID_CHUNK_FILE_HPP__
2 #define ASN_CACHE_SEQ_ID_CHUNK_FILE_HPP__
3 /* $Id: seq_id_chunk_file.hpp 72616 2016-05-18 15:58:33Z gouriano $
4  * ===========================================================================
5  *
6  * PUBLIC DOMAIN NOTICE
7  * National Center for Biotechnology Information
8  *
9  * This software/database is a "United States Government Work" under the
10  * terms of the United States Copyright Act. It was written as part of
11  * the author's official duties as a United States Government employee and
12  * thus cannot be copyrighted. This software/database is freely available
13  * to the public for use. The National Library of Medicine and the U.S.
14  * Government have not placed any restriction on its use or reproduction.
15  *
16  * Although all reasonable efforts have been taken to ensure the accuracy
17  * and reliability of the software and data, the NLM and the U.S.
18  * Government do not and cannot warrant the performance or results that
19  * may be obtained by using this software or data. The NLM and the U.S.
20  * Government disclaim all warranties, express or implied, including
21  * warranties of performance, merchantability or fitness for any particular
22  * purpose.
23  *
24  * Please cite the author in any work or product based on this material.
25  *
26  * ===========================================================================
27  *
28  * Authors: Cheinan Marks
29  *
30  * File Description:
31  * Represent a chunk file for the SeqId info -- a part of the ASN Cache ISAM storage model.
32  * Unlike CChunkFile, the data here is small enough that the file should never get too
33  * large, so there's no need to have more than one chunk file.
34  */
35 
36 #include <string>
37 #include <vector>
38 #include <fstream>
39 
40 #include <corelib/ncbifile.hpp>
41 
42 #include <util/simple_buffer.hpp>
43 
44 #include <serial/objostrasnb.hpp>
45 
47 
49 #include <objects/seq/Bioseq.hpp>
50 
52 
53 class CSeqIdChunkFile : public CFile
54 {
55 public:
56  CSeqIdChunkFile(const std::string & root_path = "")
57  : m_OpenFileRootPath(root_path)
59 
60  void OpenForWrite( const std::string & root_path = "");
61  void OpenForRead( const std::string & root_path = "");
62  void Write( const objects::CBioseq::TId & seq_ids );
63  void Write( const vector<objects::CSeq_id_Handle> & seq_ids );
64  void RawWrite( const char * raw_seq_ids, size_t raw_seq_ids_size );
65  void Read( vector<objects::CSeq_id_Handle>& target, std::streampos offset, size_t seq_ids_size );
66  void RawRead( std::streampos offset, char * raw_seq_ids, size_t raw_seq_ids_size );
67  bool Append( const string & root_path,
68  const CFile & input_seq_id_chunk_file,
69  Uint8 input_offset = 0 );
70  Int8 GetOffset() { return m_FileStream.tellp(); }
71 
72 private:
76 
77  void x_ReserveBufferSpace() { m_Buffer.reserve(10 * 1024); }
78 };
79 
81 #endif // ASN_CACHE_SEQ_ID_CHUNK_FILE_HPP__
82 
CFile –.
Definition: ncbifile.hpp:1604
CSeqIdChunkFile(const std::string &root_path="")
CNcbiFstream m_FileStream
CSimpleBufferT< char > m_Buffer
void RawRead(std::streampos offset, char *raw_seq_ids, size_t raw_seq_ids_size)
bool Append(const string &root_path, const CFile &input_seq_id_chunk_file, Uint8 input_offset=0)
void Write(const vector< objects::CSeq_id_Handle > &seq_ids)
void OpenForWrite(const std::string &root_path="")
void OpenForRead(const std::string &root_path="")
void RawWrite(const char *raw_seq_ids, size_t raw_seq_ids_size)
void Read(vector< objects::CSeq_id_Handle > &target, std::streampos offset, size_t seq_ids_size)
void Write(const objects::CBioseq::TId &seq_ids)
std::string m_OpenFileRootPath
void reserve(size_type new_size)
int offset
Definition: replacements.h:160
string
Definition: cgiapp.hpp:687
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::fstream CNcbiFstream
Portable alias for fstream.
Definition: ncbistre.hpp:538
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
Modified on Sun Jun 16 04:31:52 2024 by modify_doxy.py rev. 669887