guessserializer.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ///////////////////////////////////////////////////////////////////////////////////////
  2. /// \file guessserializer.h
  3. /// \brief Classes which handle (de)serializing LPJ-GUESS state
  4. ///
  5. /// $Date: 2018-02-02 18:01:35 +0100 (ven, 02 fév 2018) $
  6. ///
  7. ///////////////////////////////////////////////////////////////////////////////////////
  8. #ifndef LPJ_GUESS_GUESS_SERIALIZER_H
  9. #define LPJ_GUESS_GUESS_SERIALIZER_H
  10. #include <vector>
  11. class Gridcell;
  12. /// Takes care of saving LPJ-GUESS state to disk
  13. class GuessSerializer {
  14. public:
  15. /// Constructor, creates state file and meta data
  16. /** \param directory Where to create the files
  17. * \param my_rank Unique integer identifying this process in a multi
  18. * process job.
  19. * \param num_processes The number of processes involved in the job
  20. */
  21. GuessSerializer(const char* directory, int my_rank, int num_processes);
  22. /// Finalizes and closes the state file
  23. virtual ~GuessSerializer();
  24. /// Adds the state for a gridcell to the state file
  25. void serialize_gridcell(const Gridcell& gridcell);
  26. private:
  27. // Implementation hidden in cpp file
  28. struct Impl;
  29. Impl* pimpl;
  30. };
  31. /// Takes care of reading in LPJ-GUESS state from disk
  32. class GuessDeserializer {
  33. public:
  34. /// Constructor, does some basic checking of the meta data
  35. GuessDeserializer(const char* directory);
  36. /// Closes opened files etc.
  37. virtual ~GuessDeserializer();
  38. /// Reads in a single grid cell from the state file
  39. void deserialize_gridcell(Gridcell& gridcell);
  40. /// Reads in multiple grid cells from the state file
  41. /** If many grid cells should be deserialized at once, this one is better
  42. * than many calls to deserialize_gridcell since this one will avoid
  43. * unnecessary file seeks.
  44. */
  45. void deserialize_gridcells(const std::vector<Gridcell*>& gridcells);
  46. private:
  47. // Implementation hidden in cpp file
  48. struct Impl;
  49. Impl* pimpl;
  50. };
  51. #endif // LPJ_GUESS_GUESS_SERIALIZER_H