PetaVision  Alpha
CheckpointEntryDataStore.hpp
1 /*
2  * CheckpointEntryDataStore.hpp
3  *
4  * Created on Oct 13, 2016
5  * Author: Pete Schultz
6  */
7 
8 #ifndef CHECKPOINTENTRYDATASTORE_HPP_
9 #define CHECKPOINTENTRYDATASTORE_HPP_
10 
11 #include "checkpointing/CheckpointEntryPvp.hpp"
12 #include "columns/DataStore.hpp"
13 #include <string>
14 
15 namespace PV {
16 
18  public:
20  std::string const &name,
21  MPIBlock const *mpiBlock,
22  DataStore *dataStore,
23  PVLayerLoc const *layerLoc)
24  : CheckpointEntryPvp<float>(name, mpiBlock, layerLoc, true), mDataStore(dataStore) {}
26  std::string const &objName,
27  std::string const &dataName,
28  MPIBlock const *mpiBlock,
29  DataStore *dataStore,
30  PVLayerLoc const *layerLoc)
31  : CheckpointEntryPvp<float>(objName, dataName, mpiBlock, layerLoc, true),
32  mDataStore(dataStore) {}
33 
34  virtual void read(std::string const &checkpointDirectory, double *simTimePtr) const override;
35 
36  protected:
37  virtual int getNumFrames() const override;
38  virtual float *calcBatchElementStart(int batchElement) const override;
39  virtual int calcMPIBatchIndex(int frame) const override;
40  virtual void applyTimestamps(std::vector<double> const &timestamps) const override {
41  setLastUpdateTimes(timestamps);
42  }
43 
44  DataStore *getDataStore() const { return mDataStore; }
45 
46  private:
47  void setLastUpdateTimes(std::vector<double> const &timestamps) const;
48 
49  private:
50  DataStore *mDataStore = nullptr;
51 };
52 
53 } // end namespace PV
54 
55 #endif // CHECKPOINTENTRYDATASTORE_HPP_