UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
u3d_migr_io.hpp
1 /* u3d_migr_io.hpp */
2 /* $Id: u3d_migr_io.hpp,v 1.1 2008/05/13 12:19:18 sad Exp $ */
3 
4 #ifndef __u3d_migr_io_hpp
5 #define __u3d_migr_io_hpp
6 
7 #include "u3d_migr_defines.hpp"
8 
9 
10 #include <ios>
11 #include <vector>
12 
13 
14 /* ========== GLOBAL PROCEDURES =========== */
15 
17 bool saveCube(bool is_SP, int num, MigrCell *grid, int size, int prog_id, bool local=false);
18 
20 bool loadCube(bool is_SP, int num, MigrCell *&grid, int &size, int prog_id, bool local=false);
21 
23 char* getTmpFilePath(const char* name, int prog_id, bool local=false);
24 
25 
27 char* getTmpFilePathLocal(const char* name, int prog_id);
28 
29 
31 void deleteTmpFiles(int spN, int recN, int prog_id);
32 
33 
35 void deleteTmpFilesLocal(int recN, int prog_id);
36 
37 
38 
39 /* ========== DEBUG =========== */
40 bool saveC(bool is_SP, int num, MigrCell *grid, int size, int prog_id);
41 bool loadC(bool is_SP, int num, MigrCell *&grid, int &size, int prog_id);
42 bool getTmpFileName(const char* name, int prog_id, char *&result_name);
43 /* ========== DEBUG =========== */
44 
45 
46 
50 public:
51 
52  class IPFile {
53  public:
54  IPFile(const char* name, bool createFile) throw (std::ios_base::failure);
55  void write(IPCell* ipcells, int size);
56  void reduce(int size); // server
57  void read(long pos, int size, IPCell** ipcells); //client
58  long size() { return fsize - curpos; };
59  long tellpos() { return curpos; };
60  void deletefile();
61  // compare() returns true if files are equal
62  bool compare(const IPFile& other, FILE* result_file); // result_file must be already opened for appending text file
63  private:
64  std::string fname;
65  long fsize;
66  long curpos;
67  };
68 
69 
70  IPDataStorage(int sp_num, int mpid, bool haveToCreateFiles);
71 
72  int size() { return m_sp_num; };
73 
74  const std::vector<int>& getBadSPs() { return errspnums; };
75  const std::vector<std::string>& getErrmessages() { return errmessages; };
76 
77 
78  IPFile& operator[](int n) { return ipfiles[n]; };
79 
80  // Returns true if equal
81  bool compare(const IPDataStorage& other, const char* result_file);
82 
83  // Recalculates size of all files
84  void recalculateSize();
85 
86  // Recalculates size of file with number n
87  void recalculateSize(int n);
88 
89  // Only for server side!
90  void clear();
91 
92 
93  ~IPDataStorage();
94 
95 private:
96  const int m_sp_num;
97  const int m_pid;
98 
99  IPFile* ipfiles;
100 
101  std::vector<std::string> errmessages;
102  std::vector<int> errspnums;
103 };
104 
105 
106 
107 
108 
109 
110 /* ------------ DEBUG ---------------- */
111 
113 void saveIPCube(MigrDataCube migr_cube, ushort i_max, ushort j_max, ushort k_max, int prog_id, int sp_num);
114 
115 
116 #endif
Definition: u3d_migr_io.hpp:49
Definition: u3d_migr_io.hpp:52
migration-cell structure
Definition: u3d_migr_defines.hpp:47
incident-point-cell structure
Definition: u3d_migr_defines.hpp:63
migration-cell structure
Definition: u3d_migr_defines.hpp:31