Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

snapshot_class.h

By: iwishiknew on Jun 22nd, 2013  |  syntax: C++  |  size: 1.45 KB  |  views: 59  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #ifndef SNAPSHOT_CLASS_H_INCLUDED
  2. #define SNAPSHOT_CLASS_H_INCLUDED
  3. #include <map>
  4. #include <string>
  5. #include "t_extra.h"
  6. #include <memory>
  7. using namespace std;
  8.  
  9. typedef unsigned long long ID_T;
  10. typedef unsigned long long ULL;
  11.  
  12.  
  13.  
  14. /**
  15.  * File structure:
  16.  *
  17.  * 0  ID
  18.  * 1  Date
  19.  *
  20.  * 2  [list of paths...]
  21.  */
  22.  
  23.  
  24. #define SNAPSHOT_FILE_EXTENSION ".snap"
  25. #define SNAPSHOT_FOLDER "Snapshots"
  26.  
  27.  
  28. struct basic_snap_data{
  29.     string date = "";
  30.     string path = "";
  31.     ID_T id = 0;
  32. };
  33.  
  34. /* prototype declared here for use in other .cpp files...*/
  35. map<unsigned int, basic_snap_data> get_snapshot_info();
  36.  
  37.  
  38. /* The snapshot_class will take a filename as an argument.
  39.  If not given one, it will create a new snapshot.*/
  40. class snapshot_class{
  41.    
  42. public:
  43.    
  44.    
  45.     //constructors/destructors
  46.     snapshot_class(const string&);
  47.     snapshot_class(const char*);
  48.     snapshot_class();
  49.     snapshot_class(const char&); //for memory management purposes...
  50.     ~snapshot_class();
  51.    
  52.    
  53.     //public functions
  54.     ID_T gid();
  55.     string gdate();
  56.     map<unsigned int, string> gsnap();
  57.     void del();
  58.     void clear();
  59.    
  60. private:
  61.    
  62.     //variables
  63.     string filename = string();
  64.     string date = chrono_date().asc_time;
  65.     ID_T id = 0;
  66.     shared_ptr<map<unsigned int, string>> snapshot;
  67.    
  68.    
  69.     //functions
  70.     void constructor_tasks(const string&);
  71.     void load_snapshot(const string&);
  72.    
  73. };
  74.  
  75. #endif
clone this paste RAW Paste Data