zamotivator

Untitled

Feb 9th, 2012
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. Refactoring of save_index.
  2.  
  3.  
  4. New class savegame::save_index_class with instance save_index_manager:
  5. Methods:
  6. * data() - old save_index::load() - load save_index from disk if doesn't
  7. loaded yet
  8. * data(const std::string& name) - get (or create if not available) summary
  9. from save_index (from data())
  10. * write_save_index() - write current save_index to disk
  11. * rebuild(const std::string& name, const time_t& modified) - re-load summary
  12. from savefile, update summary, write updated index to disk
  13. * rebuild(const std::string& name) - rebuild where modified == file
  14. modification time
  15. * set_modified(const std::string& name) - remember modified time of file
  16. * get(const std::string& name) - check data(name)["mod_time"] - if different
  17. from remembered by "set_modified" - rebuild
  18.  
  19.  
  20. Class savegame::save_info changed
  21. * time_t and std::string members now private. You should use method
  22. for access to it
  23. * summary() method for transparent access to summary
  24. (save_index_manager.get(name()) - see save_index_manager.get description
  25. above)
  26.  
  27.  
  28.  
  29. Class savegame::manager removed. All statis function moved to savegame
  30. namespace.
  31.  
  32.  
  33.  
  34. Function "savegame::extract_summary_data_from_save" removed, because it
  35. word-by-word equalient to "extract_summary_from_config". I just call "rebuild"
  36. for save_info in "finish_save_game". My purpose was avoid copy-paste.
  37.  
  38. Other changes:
  39. * I removed summaries from src/dialogs.cpp. Now you can transparent access by
  40. save_info::summary()
  41. * I removed all copy-paste like (use summary() instead of this):
  42. --------------------------------------------------
  43. std::string dummy;
  44. const config &summary = *summaries_[index_];
  45. if (summary["label"].empty())
  46. {
  47. try {
  48. savegame::manager::load_summary((*info_)[index_].name, *summaries_[index_],
  49. &dummy);
  50. } catch(game::load_game_failed&) {
  51. (*summaries_[index_])["corrupt"] = true;
  52. }
  53. }
  54. --------------------------------------------------
  55. * added class filename_filter - predicate for erase (used in get_saves_list)
  56. * added class create_save_info - builder for save_info. In general you can't
  57. create save_info right now (and this is unecessary). If you need this in
  58. feature - just move declaration of class create_save_info to header.
Advertisement
Add Comment
Please, Sign In to add comment