00001
00002
00003
00004
00005
00006
00007 #ifndef BALL_MOLMEC_COMMON_SNAPSHOTMANAGER_H
00008 #define BALL_MOLMEC_COMMON_SNAPSHOTMANAGER_H
00009
00010 #ifndef BALL_MOLMEC_COMMON_SNAPSHOT_H
00011 # include <BALL/MOLMEC/COMMON/snapShot.h>
00012 #endif
00013
00014 #ifndef BALL_DATATYPE_OPTIONS_H
00015 # include <BALL/DATATYPE/options.h>
00016 #endif
00017
00018 #ifndef BALL_SYSTEM_FILE_H
00019 # include <BALL/SYSTEM/file.h>
00020 #endif
00021
00022 namespace BALL
00023 {
00024 class TrajectoryFile;
00025 class System;
00026 class ForceField;
00027
00033 class BALL_EXPORT SnapShotManager
00034 {
00035 public:
00036
00038 struct BALL_EXPORT Option
00039 {
00044 static const char* FLUSH_TO_DISK_FREQUENCY;
00045 };
00046
00048 struct BALL_EXPORT Default
00049 {
00054 static const unsigned int FLUSH_TO_DISK_FREQUENCY;
00055 };
00056
00057
00058 BALL_CREATE(SnapShotManager)
00059
00060
00061
00062
00064 SnapShotManager()
00065 ;
00066
00074 SnapShotManager(System* my_system, const ForceField* my_force_field,
00075 TrajectoryFile* my_snapshot_file)
00076 ;
00077
00086 SnapShotManager
00087 (System* my_system, const ForceField* my_force_field,
00088 const Options& my_options, TrajectoryFile* file)
00089 ;
00090
00092 SnapShotManager(const SnapShotManager& manager)
00093 ;
00094
00096 virtual ~SnapShotManager()
00097 ;
00098
00100
00103
00110 bool setup(System* my_system, const ForceField* my_forcefield,
00111 TrajectoryFile* my_snapshot_file)
00112 ;
00113
00118 virtual bool setup()
00119 ;
00120
00122
00125
00128 const SnapShotManager& operator = (const SnapShotManager& manager)
00129 ;
00130
00132 virtual void clear()
00133 ;
00134
00136
00137
00138
00141 virtual bool isValid() const
00142 ;
00143
00145
00146
00147
00152 void setSystem(System* my_system)
00153 ;
00154
00156 System* getSystem() const
00157 ;
00158
00160 void setForceField(const ForceField* my_ff)
00161 ;
00162
00164 const ForceField* getForceField() const
00165 ;
00166
00168 void setTrajectoryFile(TrajectoryFile* my_file)
00169 ;
00170
00172 TrajectoryFile* getTrajectoryFile() const
00173 ;
00174
00179 void setFlushToDiskFrequency(Size number)
00180 ;
00181
00185 Size getFlushToDiskFrequency() const
00186 ;
00187
00193 virtual void takeSnapShot()
00194 throw(File::CannotWrite);
00195
00202 virtual bool applySnapShot(Size number)
00203 ;
00204
00209 virtual bool applyFirstSnapShot()
00210 ;
00211
00217 virtual bool applyNextSnapShot()
00218 ;
00219
00225 virtual bool applyLastSnapShot()
00226 ;
00227
00229 virtual void flushToDisk()
00230 throw(File::CannotWrite);
00231
00233 Size getNumberOfSnapShotsInBuffer()
00234 { return snapshot_buffer_.size();}
00235
00237 Position getCurrentSnapshotNumber() const
00238 { return current_snapshot_ + 1;}
00239
00242 bool readFromFile()
00243 ;
00244
00246 void clearBuffer()
00247 ;
00248
00250
00251
00252
00254 Options options;
00255
00257
00258
00259
00260 protected:
00261
00262
00263 System* system_ptr_;
00264
00265
00266 const ForceField* force_field_ptr_;
00267
00268
00269 vector<SnapShot> snapshot_buffer_;
00270
00271
00272 TrajectoryFile* trajectory_file_ptr_;
00273
00274
00275
00276
00277 Size flush_to_disk_frequency_;
00278
00279
00280 Size buffer_counter_;
00281
00282
00283 Position current_snapshot_;
00284
00285
00286
00287
00288
00289
00290
00291
00292 double calculateKineticEnergy_();
00293
00294
00295
00296 };
00297
00298 }
00299 #endif // BALL_MOLMEC_COMMON_SNAPSHOTMANAGER_H