ccp4srs  Version 1.0.0
mpfile_.h
Go to the documentation of this file.
1 // $Id: mpfile_.h $
2 // =================================================================
3 //
4 // CCP4 SRS Library: Storage, Retrieval and Search support for
5 // CCP4 ligand data.
6 //
7 // Copyright (C) Eugene Krissinel 2010-2013.
8 //
9 // This library is free software: you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License version 3, modified in accordance with the provisions
12 // of the license to address the requirements of UK law.
13 //
14 // You should have received a copy of the modified GNU Lesser
15 // General Public License along with this library. If not, copies
16 // may be downloaded from http://www.ccp4.ac.uk/ccp4license.php
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Lesser General Public License for more details.
22 //
23 // =================================================================
24 //
25 // 03.02.14 <-- Date of Last Modification.
26 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 // -----------------------------------------------------------------
28 //
29 // **** Module : mpfile_ <interface>
30 // ~~~~~~~~~
31 // **** Classes : ccp4srs::MPFile - multi-part file support
32 // ~~~~~~~~~
33 //
34 // (C) E. Krissinel 2010-2014
35 //
36 // =================================================================
37 //
38 
39 #ifndef MPFILE_H
40 #define MPFILE_H
41 
42 #include "mmdb2/mmdb_io_file.h"
43 
44 namespace ccp4srs {
45 
46  // =========================== MPFile ===========================
47 
48  DefineStructure(MPFilePos);
49 
50  struct MPFilePos {
51  mmdb::byte chunkNo; // file part number (1-254)
52  long offset; // offset in chunk
53  void Copy ( RMPFilePos dbf_pos );
54  void write ( mmdb::io::RFile f );
55  void read ( mmdb::io::RFile f );
56  };
57 
58  DefineClass(MPFile)
59 
60  class MPFile {
61 
62  public :
63  MPFile ();
64  ~MPFile();
65 
66  void assign ( mmdb::cpstr FName, bool UniB=true );
67  bool reset ( bool rdOnly=false );
68  bool rewrite ( long chunk_size=1000000000 );
69  bool append ( long chunk_size=1000000000 );
70 
71  mmdb::pstr FileName () { return fpath; }
72  void getPosition ( RMPFilePos MPFilePos );
73  bool seek ( RMPFilePos MPFilePos );
74  bool MPFileEnd ();
75  bool Success ();
76  void shut ();
77 
78  mmdb::io::PFile getChunkRead ();
79  mmdb::io::PFile getChunkWrite();
80 
81  protected :
82  mmdb::io::PPFile f;
83  mmdb::pstr fpath;
84  long chunkSize;
85  mmdb::byte chunkNo;
86  bool uniBinary,readOnly;
87 
88  mmdb::pstr getChunkPath ();
89  bool getChunk ( int toChunkNo, bool onRead );
90  bool checkChunkEnd ( bool onRead );
91 
92  private :
93  mmdb::pstr chunkPath;
94  int nchunks;
95 
96  };
97 
98 } // namespace ccp4srs
99 
100 #endif // MPFILE_H
void Copy(RMPFilePos dbf_pos)
Definition: mpfile_.cpp:45
DefineClass(Angle)
long offset
Definition: mpfile_.h:52
void write(mmdb::io::RFile f)
Definition: mpfile_.cpp:50
mmdb::byte chunkNo
Definition: mpfile_.h:51
void read(mmdb::io::RFile f)
Definition: mpfile_.cpp:55
Definition: ccp4srs_angle.cpp:42
Definition: mpfile_.h:50
DefineStructure(AtomPair)