Pteros  2.0
Molecular modeling library for human beings!
xtc_file.h
1 /*
2  * This file is a part of
3  *
4  * ============================================
5  * ### Pteros molecular modeling library ###
6  * ============================================
7  *
8  * https://github.com/yesint/pteros
9  *
10  * (C) 2009-2021, Semen Yesylevskyy
11  *
12  * All works, which use Pteros, should cite the following papers:
13  *
14  * 1. Semen O. Yesylevskyy, "Pteros 2.0: Evolution of the fast parallel
15  * molecular analysis library for C++ and python",
16  * Journal of Computational Chemistry, 2015, 36(19), 1480–1488.
17  * doi: 10.1002/jcc.23943.
18  *
19  * 2. Semen O. Yesylevskyy, "Pteros: Fast and easy to use open-source C++
20  * library for molecular analysis",
21  * Journal of Computational Chemistry, 2012, 33(19), 1632–1636.
22  * doi: 10.1002/jcc.22989.
23  *
24  * This is free software distributed under Artistic License:
25  * http://www.opensource.org/licenses/artistic-license-2.0.php
26  *
27 */
28 
29 
30 #pragma once
31 
32 #include "pteros/core/file_handler.h"
33 
34 #include "xdrfile.h"
35 #include "xdrfile_xtc.h"
36 
37 namespace pteros {
38 
39 
40 class XtcFile: public FileHandlerRandomAccess {
41 public:
42  XtcFile(std::string& fname): FileHandlerRandomAccess(fname), handle(nullptr), content(FileContent().traj(true).rand(true)) {}
43  virtual void open(char open_mode);
44  virtual ~XtcFile();
45 
46  virtual FileContent get_content_type() const {
47  return content;
48  }
49 
50 protected:
51 
52  virtual void do_write(const Selection &sel, const FileContent& what) override;
53  virtual bool do_read(System *sys, Frame *frame, const FileContent& what) override ;
54 
55  virtual void seek_frame(int fr) override;
56  virtual void seek_time(float t) override;
57  virtual void tell_current_frame_and_time(int& step, float& t) override;
58  virtual void tell_last_frame_and_time(int& step, float& t) override;
59 
60 private:
61  // for xdrfile
62  XDRFILE* handle;
63  matrix box;
64  int step;
65  int steps_per_frame;
66  int64_t num_frames;
67  float dt, max_t;
68  FileContent content;
69 };
70 
71 }
72 
73 
74 
75 
76 
pteros::FileHandler::open
static FileHandler_ptr open(std::string fname, char open_mode)
Recognize file extension, open file for reading or writing and return a file handler.
Definition: file_handler.cpp:131