BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DCDFile.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_FORMAT_DCDFILE_H
6 #define BALL_FORMAT_DCDFILE_H
7 
8 #ifndef BALL_FORMAT_TRAJECTORYFILE_H
10 #endif
11 
12 #ifndef BALL_SYSTEM_BINARYFILEADAPTOR_H
14 #endif
15 
16 namespace BALL
17 {
38  : public TrajectoryFile
39  {
40  public:
41 
45 
47  DCDFile();
48 
52  DCDFile(const String& name, File::OpenMode open_mode = std::ios::in);
53 
55  virtual ~DCDFile();
56 
58 
61 
63  virtual void clear();
64 
66 
69 
71  bool operator == (const DCDFile& file) const;
72 
74  bool isSwappingBytes() const;
75 
77  bool hasVelocities() const;
78 
80 
81 
82 
86  virtual bool open(const String& name, File::OpenMode open_mode = std::ios::in);
87 
90  bool init();
91 
95  virtual bool readHeader();
96 
100  virtual bool writeHeader();
101 
104  virtual bool seekAndWriteHeader();
105 
106  // ?????:
107  // should append() also write the header? what is more intuitive?
113  virtual bool append(const SnapShot& snapshot);
114 
119  virtual bool read(SnapShot& snapshot);
120 
123  virtual bool flushToDisk(const std::vector<SnapShot>& buffer);
124 
126 
129 
131  void enableVelocityStorage();
132 
134  void disableVelocityStorage();
135 
137 
138  private:
139  const DCDFile& operator = (const DCDFile& file);
140 
141  protected:
142 
143  //_
144  void writeSize_(const Size& data)
145  { *this << BinaryFileAdaptor<Size>(data);}
146 
147  //_
148  void writeFloat_(const float& data)
149  { *this << BinaryFileAdaptor<float>(data);}
150 
151  //_
152  void writeVector_(const vector<Vector3>& v);
153 
154  //_
155  float readFloat_();
156 
157  //_
158  Size readSize_();
159 
160  //_
161  bool readSize_(Size expected_size, const String& what);
162 
163  //_
164  bool readVector_(vector<Vector3>& v);
165 
166  //_
168 
169  // a flag indicating that we have to swap bytes when reading data
171 
172  // a floag indicating that this DCD file contains atom velocities
174 
175  //_
177 
178  //_
180 
181  //_
183 
184  //_
186 
187  //_
189 
190  //_
192 
193  //_
195 
196  /*_ We had a problem with read(Snapshot), as it
197  still returned true at the end of file. No idea
198  why the stream was still good! To fix this,
199  I added this member to count the current read snapshot.
200  */
202 
205  };
206 } // namespace BALL
207 
208 #endif // BALL_FORMAT_DCDFILE_H