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 namespace BALL
00013 {
00033 class BALL_EXPORT DCDFile
00034 : public TrajectoryFile
00035 {
00036 public:
00037
00041
00043 DCDFile();
00044
00046 DCDFile(const String& name, File::OpenMode open_mode = std::ios::in)
00047 throw(Exception::FileNotFound);
00048
00050 virtual ~DCDFile();
00051
00053
00056
00058 virtual void clear();
00059
00061
00064
00066 bool operator == (const DCDFile& file) const;
00067
00069 bool isSwappingBytes() const;
00070
00072 bool hasVelocities() const;
00073
00075
00076
00077
00080 virtual bool open(const String& name, File::OpenMode open_mode = std::ios::in)
00081 throw(Exception::FileNotFound);
00082
00085 bool init();
00086
00090 virtual bool readHeader();
00091
00095 virtual bool writeHeader();
00096
00099 virtual bool seekAndWriteHeader();
00100
00101
00102
00108 virtual bool append(const SnapShot& snapshot);
00109
00114 virtual bool read(SnapShot& snapshot);
00115
00118 virtual bool flushToDisk(const std::vector<SnapShot>& buffer)
00119 throw(File::CannotWrite);
00120
00122
00125
00127 void enableVelocityStorage();
00128
00130 void disableVelocityStorage();
00131
00133
00134 private:
00135 const DCDFile& operator = (const DCDFile& file);
00136
00137 protected:
00138
00139
00140 void writeSize_(const Size& data)
00141 { *this << BinaryFileAdaptor<Size>(data);}
00142
00143
00144 void writeFloat_(const float& data)
00145 { *this << BinaryFileAdaptor<float>(data);}
00146
00147
00148 void writeVector_(const vector<Vector3>& v);
00149
00150
00151 float readFloat_();
00152
00153
00154 Size readSize_();
00155
00156
00157 bool readSize_(Size expected_size, const String& what);
00158
00159
00160 bool readVector_(vector<Vector3>& v);
00161
00162
00163 Size verbosity_;
00164
00165
00166 bool swap_bytes_;
00167
00168
00169 bool has_velocities_;
00170
00171
00172 bool charmm_extra_block_A_;
00173
00174
00175 bool charmm_extra_block_B_;
00176
00177
00178 String CORD_;
00179
00180
00181 Size step_number_of_starting_time_;
00182
00183
00184 Size steps_between_saves_;
00185
00186
00187 double time_step_length_;
00188
00189
00190 Size number_of_comments_;
00191
00192
00193
00194
00195
00196
00197 Position current_snapshot_;
00198
00199 BinaryFileAdaptor<Size> adapt_size_;
00200 BinaryFileAdaptor<float> adapt_float_;
00201 };
00202 }
00203
00204 #endif // BALL_FORMAT_DCDFILE_H