BALL  1.4.1
DCDFile.h
Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
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     // should append() also write the header? what is more intuitive?
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     // a flag indicating that we have to swap bytes when reading data
00170     bool swap_bytes_;
00171 
00172     // a floag indicating that this DCD file contains atom velocities
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     /*_ We had a problem with read(Snapshot), as it
00197         still returned true at the end of file. No idea
00198         why the stream was still good! To fix this,
00199         I added this member to count the current read snapshot.
00200     */
00201     Position current_snapshot_;
00202 
00203     BinaryFileAdaptor<Size>  adapt_size_;
00204     BinaryFileAdaptor<float> adapt_float_;
00205   };
00206 } // namespace BALL
00207 
00208 #endif // BALL_FORMAT_DCDFILE_H 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines