00001
00002
00003
00004
00005 #ifndef BALL_FORMAT_DCDFILE_H
00006 #define BALL_FORMAT_DCDFILE_H
00007
00008 #ifndef BALL_FORMAT_TRAJECTORYFILE_H
00009 # include <BALL/FORMAT/trajectoryFile.h>
00010 #endif
00011
00012 #ifndef BALL_SYSTEM_BINARYFILEADAPTOR_H
00013 # include <BALL/SYSTEM/binaryFileAdaptor.h>
00014 #endif
00015
00016 namespace BALL
00017 {
00037 class BALL_EXPORT DCDFile
00038 : public TrajectoryFile
00039 {
00040 public:
00041
00045
00047 DCDFile();
00048
00052 DCDFile(const String& name, File::OpenMode open_mode = std::ios::in);
00053
00055 virtual ~DCDFile();
00056
00058
00061
00063 virtual void clear();
00064
00066
00069
00071 bool operator == (const DCDFile& file) const;
00072
00074 bool isSwappingBytes() const;
00075
00077 bool hasVelocities() const;
00078
00080
00081
00082
00086 virtual bool open(const String& name, File::OpenMode open_mode = std::ios::in);
00087
00090 bool init();
00091
00095 virtual bool readHeader();
00096
00100 virtual bool writeHeader();
00101
00104 virtual bool seekAndWriteHeader();
00105
00106
00107
00113 virtual bool append(const SnapShot& snapshot);
00114
00119 virtual bool read(SnapShot& snapshot);
00120
00123 virtual bool flushToDisk(const std::vector<SnapShot>& buffer);
00124
00126
00129
00131 void enableVelocityStorage();
00132
00134 void disableVelocityStorage();
00135
00137
00138 private:
00139 const DCDFile& operator = (const DCDFile& file);
00140
00141 protected:
00142
00143
00144 void writeSize_(const Size& data)
00145 { *this << BinaryFileAdaptor<Size>(data);}
00146
00147
00148 void writeFloat_(const float& data)
00149 { *this << BinaryFileAdaptor<float>(data);}
00150
00151
00152 void writeVector_(const vector<Vector3>& v);
00153
00154
00155 float readFloat_();
00156
00157
00158 Size readSize_();
00159
00160
00161 bool readSize_(Size expected_size, const String& what);
00162
00163
00164 bool readVector_(vector<Vector3>& v);
00165
00166
00167 Size verbosity_;
00168
00169
00170 bool swap_bytes_;
00171
00172
00173 bool has_velocities_;
00174
00175
00176 bool charmm_extra_block_A_;
00177
00178
00179 bool charmm_extra_block_B_;
00180
00181
00182 String CORD_;
00183
00184
00185 Size step_number_of_starting_time_;
00186
00187
00188 Size steps_between_saves_;
00189
00190
00191 double time_step_length_;
00192
00193
00194 Size number_of_comments_;
00195
00196
00197
00198
00199
00200
00201 Position current_snapshot_;
00202
00203 BinaryFileAdaptor<Size> adapt_size_;
00204 BinaryFileAdaptor<float> adapt_float_;
00205 };
00206 }
00207
00208 #endif // BALL_FORMAT_DCDFILE_H