BALL 1.5.0
TRRFile.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_TRRFILE_H
6#define BALL_FORMAT_TRRFILE_H
7
8#ifndef BALL_FORMAT_TRAJECTORYFILE_H
10#endif
11
12#ifndef BALL_SYSTEM_BINARYFILEADAPTOR_H
14#endif
15
16namespace BALL
17{
29 : public TrajectoryFile
30 {
31
32 public:
33 static const double to_angstrom;
34 static const double to_nanometer;
35
39
47 {
48 public:
49
66
74
80
86
91
96
101
107
113
117
121
126
130
134 float lambda;
135
137 : MAGIC(1993),
138 VERSION(13),
139 title_string_length(24),
140 title_string("Created by BALL::TRRFile"),
141 ir_size(0),
142 e_size(0),
143 vir_size(0),
144 pres_size(0),
145 top_size(0),
146 sym_size(0),
147 velocity_data_size(0),
148 force_data_size(0),
149 timestep_index(0),
150 nre(0),
151 timestep_time(0.002),
152 lambda(0)
153 {
154 }
155 };
156
158
162
165
167 TRRFile(const String& name, File::OpenMode open_mode = std::ios::in);
168
170 virtual ~TRRFile();
172
176
178 virtual void clear();
180
184
186 bool operator == (const TRRFile& file) const;
188
190
191
193 virtual bool init();
194
199 virtual bool readHeader();
200
206 virtual bool writeNextHeader(const TRRHeader& header);
207
212 virtual bool readNextHeader(TRRHeader& header);
213
218 virtual bool append(const SnapShot& snapshot);
219
224 virtual bool read(SnapShot& snapshot);
225
229 virtual bool skipFrame();
230
235
238
242 virtual bool flushToDisk(const std::vector<SnapShot>& buffer);
244
245
248
250 bool hasVelocities() const;
251
253 void setVelocityStorage(bool storage);
254
256 bool hasForces() const;
257
259 void setForceStorage(bool storage);
260
263
266
268 float getTimestep() const;
269
271 void setTimestep(float timestep);
272
275
278
281
283 void setBoundingBox(const Vector3& x, const Vector3& y, const Vector3& z);
284
286
287 private:
288 const TRRFile& operator = (const TRRFile& file);
289
290 protected:
291
292 // the current step's header
294
295 // the precision of the file in bytes per value
297
298 // a flag deciding if the file contains velocities
300
301 // a flag deciding if the file contains forces
303
304 // the index of the current timestep / snapshot
306
307 // the length of the timestep
309
310 // three vectors containing the base vectors of the box in
311 // nanometers
312 Vector3 box1_, box2_, box3_;
313
318
320 };
321} // namespace BALL
322
323#endif // BALL_FORMAT_TRRFILE_H
Definition: constants.h:13
BALL_EXPORT bool operator==(const String &s1, const String &s2)
std::istream & operator>>(std::istream &is, TRegularData1D< ValueType > &grid)
Input operator.
double precision
Definition: classTest.h:30
Size old_file_size_
Definition: TRRFile.h:319
static const double to_angstrom
Definition: TRRFile.h:33
TRRFile(const String &name, File::OpenMode open_mode=std::ios::in)
Construct and open a file.
void setVelocityStorage(bool storage)
virtual bool skipFrame()
float getTimestep() const
void setTimestep(float timestep)
BinaryFileAdaptor< Size > adapt_size_
Definition: TRRFile.h:314
Vector3 box1_
Definition: TRRFile.h:312
void setForceStorage(bool storage)
Size precision_
Definition: TRRFile.h:296
virtual bool flushToDisk(const std::vector< SnapShot > &buffer)
void setBoundingBox(const Vector3 &x, const Vector3 &y, const Vector3 &z)
bool has_forces_
Definition: TRRFile.h:302
virtual bool writeNextHeader(const TRRHeader &header)
virtual bool read(SnapShot &snapshot)
float timestep_
Definition: TRRFile.h:308
bool has_velocities_
Definition: TRRFile.h:299
TRRHeader header_
Definition: TRRFile.h:293
virtual bool readHeader()
Size timestep_index_
Definition: TRRFile.h:305
BinaryFileAdaptor< char > adapt_char_
Definition: TRRFile.h:315
Vector3 getBoundingBoxX() const
virtual void clear()
Clear method.
BinaryFileAdaptor< float > adapt_float_
Definition: TRRFile.h:316
Size getPrecision() const
bool hasForces() const
bool hasVelocities() const
virtual bool append(const SnapShot &snapshot)
TRRFile()
Default constructor.
virtual ~TRRFile()
Destructor.
static const double to_nanometer
Definition: TRRFile.h:34
virtual bool readNextHeader(TRRHeader &header)
Vector3 getBoundingBoxZ() const
virtual bool init()
Initialize the file for usage.
Vector3 getBoundingBoxY() const
bool setPrecision(const Size precision)
BinaryFileAdaptor< double > adapt_double_
Definition: TRRFile.h:317
virtual Size getNumberOfSnapShots()
Size title_string_length
The length of the title string.
Definition: TRRFile.h:55
String title_string
The title string.
Definition: TRRFile.h:57
Size MAGIC
Magic number for the TRR format. This must be equal to 1993.
Definition: TRRFile.h:51
Size VERSION
The version number of the TRR format.
Definition: TRRFile.h:53
std::ios::openmode OpenMode
Definition: file.h:165
#define BALL_EXPORT
Definition: COMMON/global.h:50