BALL  1.4.1
snapShotManager.h
Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: snapShotManager.h,v 1.19.20.1 2007/05/10 10:51:04 amoll Exp $
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 Size FLUSH_TO_DISK_FREQUENCY;
00055   };
00056 
00057 
00058   BALL_CREATE(SnapShotManager)
00059 
00060   
00061 
00062 
00064   SnapShotManager();
00065 
00072   SnapShotManager(System* my_system, TrajectoryFile* my_snapshot_file = 0);
00073 
00081   SnapShotManager(System* my_system, const ForceField* my_force_field, TrajectoryFile* my_snapshot_file);
00082 
00091   SnapShotManager (System* my_system, const ForceField* my_force_field,
00092                   const Options& my_options, TrajectoryFile* file);
00093 
00095   SnapShotManager(const SnapShotManager& manager);
00096 
00098   virtual ~SnapShotManager();
00099 
00101 
00104 
00111   bool setup(System* my_system, const ForceField* my_forcefield, TrajectoryFile* my_snapshot_file);
00112 
00119   bool setup(System* my_system, TrajectoryFile* my_snapshot_file);
00120 
00125   virtual bool setup();
00126 
00128 
00131 
00134   const SnapShotManager& operator = (const SnapShotManager& manager);
00135 
00137   virtual void clear();
00138 
00140 
00141 
00142 
00145   virtual bool isValid() const;
00146 
00148 
00149 
00150 
00155   void setSystem(System* my_system);
00156 
00158   System* getSystem() const;
00159 
00161   void setForceField(const ForceField* my_ff);
00162 
00164   const ForceField* getForceField() const;
00165 
00167   void setTrajectoryFile(TrajectoryFile* my_file);
00168 
00170   TrajectoryFile* getTrajectoryFile() const;
00171 
00176   void setFlushToDiskFrequency(Size number);
00177 
00181   Size getFlushToDiskFrequency() const;
00182 
00189   virtual void takeSnapShot() throw(File::CannotWrite);
00190 
00197   virtual bool applySnapShot(Size number);
00198 
00203   virtual bool applyFirstSnapShot();
00204 
00210   virtual bool applyNextSnapShot();
00211 
00217   virtual bool applyLastSnapShot();
00218 
00221   virtual void flushToDisk() throw(File::CannotWrite);
00222 
00224   Size getNumberOfSnapShotsInBuffer() { return snapshot_buffer_.size(); }
00225 
00227   Position getCurrentSnapshotNumber() const { return current_snapshot_ + 1; }
00228 
00231   bool readFromFile();
00232 
00234   void clearBuffer();
00235 
00237 
00238 
00239 
00241   Options options;
00242 
00244   //_ @name Protected Attributes
00245   //_@{
00246 
00247   protected:
00248 
00249   //_ The system to which the SnapshotManager is bound
00250   System* system_ptr_;
00251 
00252   //_ The force field of the current system
00253   const ForceField* force_field_ptr_;
00254 
00255   //_ A vector containing those snapshot objects currently in memory
00256   vector<SnapShot> snapshot_buffer_;
00257 
00258   //_ The trajectory file where the data is saved in
00259   TrajectoryFile* trajectory_file_ptr_;
00260 
00261   /*_ The frequency of saving snapshots in memory to disk.
00262       After flush_to_disk_frequency_ iterations, a save is done. 
00263   */
00264   Size flush_to_disk_frequency_;
00265 
00266   //_ Number of taken SnapShot sine last flushToDisk
00267   Size buffer_counter_;
00268 
00269   //_ Number of the current SnapShot (used with buffer_)
00270   Position current_snapshot_;
00271 
00272   //_@}
00273   /*_ @name Protected methods
00274   */
00275   //_@{
00276 
00277   /*_ Calculate the kinetic energy 
00278   */
00279   double calculateKineticEnergy_();
00280 
00281   //_@}
00282 
00283 }; // end of class SnapshotManager 
00284 
00285 } // namespace
00286 #endif //  BALL_MOLMEC_COMMON_SNAPSHOTMANAGER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines