NeoPZ
TPZSandlerExtendedTranslator.cpp
Go to the documentation of this file.
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 
7 /*
8  * File: TPZSandlerExtendedTranslator.cpp
9  * Author: thiago
10  *
11  * Created on 12 de Março de 2018, 15:39
12  */
13 
15 #include "TPZChunkInTranslation.h"
16 
18 }
19 
21 }
22 
23 void TPZSandlerExtendedTranslator::UpdateStream(TPZChunkInTranslation& chunk, const std::map<std::string, uint64_t>& toVersion) {
24  auto old_version = chunk.mOldVersion["NeoPZ"];
25  auto new_version = toVersion.at("NeoPZ");
26  switch (old_version) {
27  case 1:
28  if (new_version <= 2){
29  UpdateAttributesV1(chunk, toVersion);
30  break;
31  } else {
32  DebugStop();
33  }
34  case 2:
35  if (new_version == 2){
36  UpdateAttributesV2(chunk, toVersion);
37  } else {
38  UpdateFromV2(chunk, toVersion);
39  }
40  break;
41  default:
42  UpdateAttributes(chunk, toVersion);
43  break;
44  }
45 }
46 
47 void TPZSandlerExtendedTranslator::UpdateAttributesV1(TPZChunkInTranslation& chunk, const std::map<std::string, uint64_t>& toVersion) {
48  STATE ftol;
49  chunk.mOldStream.Read(&ftol);
50  chunk.mNewStream.Write(&ftol);
51  STATE fA;
52  chunk.mOldStream.Read(&fA);
53  chunk.mNewStream.Write(&fA);
54  STATE fB;
55  chunk.mOldStream.Read(&fB);
56  chunk.mNewStream.Write(&fB);
57  STATE fC;
58  chunk.mOldStream.Read(&fC);
59  chunk.mNewStream.Write(&fC);
60  STATE fD;
61  chunk.mOldStream.Read(&fD);
62  chunk.mNewStream.Write(&fD);
63  STATE fW;
64  chunk.mOldStream.Read(&fW);
65  chunk.mNewStream.Write(&fW);
66  STATE fK;
67  chunk.mOldStream.Read(&fK);
68  chunk.mNewStream.Write(&fK);
69  STATE fR;
70  chunk.mOldStream.Read(&fR);
71  chunk.mNewStream.Write(&fR);
72  STATE fG;
73  chunk.mOldStream.Read(&fG);
74  chunk.mNewStream.Write(&fG);
75  STATE fPhi;
76  chunk.mOldStream.Read(&fPhi);
77  chunk.mNewStream.Write(&fPhi);
78  STATE fN;
79  chunk.mOldStream.Read(&fN);
80  chunk.mNewStream.Write(&fN);
81  STATE fPsi;
82  chunk.mOldStream.Read(&fPsi);
83  chunk.mNewStream.Write(&fPsi);
84  STATE fE;
85  chunk.mOldStream.Read(&fE);
86  chunk.mNewStream.Write(&fE);
87  STATE fnu;
88  chunk.mOldStream.Read(&fnu);
89  chunk.mNewStream.Write(&fnu);
91 }
92 
93 void TPZSandlerExtendedTranslator::UpdateFromV2(TPZChunkInTranslation& chunk, const std::map<std::string, uint64_t>& toVersion){
94  STATE ftol;
95  chunk.mOldStream.Read(&ftol);
96  chunk.mNewStream.Write(&ftol);
97  STATE fA;
98  chunk.mOldStream.Read(&fA);
99  chunk.mNewStream.Write(&fA);
100  STATE fB;
101  chunk.mOldStream.Read(&fB);
102  chunk.mNewStream.Write(&fB);
103  STATE fC;
104  chunk.mOldStream.Read(&fC);
105  chunk.mNewStream.Write(&fC);
106  STATE fD;
107  chunk.mOldStream.Read(&fD);
108  chunk.mNewStream.Write(&fD);
109  STATE fW;
110  chunk.mOldStream.Read(&fW);
111  chunk.mNewStream.Write(&fW);
112  STATE fK;
113  chunk.mOldStream.Read(&fK);
114  chunk.mNewStream.Write(&fK);
115  STATE fR;
116  chunk.mOldStream.Read(&fR);
117  chunk.mNewStream.Write(&fR);
118  STATE fG;
119  chunk.mOldStream.Read(&fG);
120  chunk.mNewStream.Write(&fG);
121  STATE fPhi;
122  chunk.mOldStream.Read(&fPhi);
123  chunk.mNewStream.Write(&fPhi);
124  STATE fN;
125  chunk.mOldStream.Read(&fN);
126  chunk.mNewStream.Write(&fN);
127  STATE fPsi;
128  chunk.mOldStream.Read(&fPsi);
129  chunk.mNewStream.Write(&fPsi);
130  STATE fE;
131  chunk.mOldStream.Read(&fE);
132  chunk.mNewStream.Write(&fE);
133  STATE fnu;
134  chunk.mOldStream.Read(&fnu);
135  chunk.mNewStream.Write(&fnu);
136  STATE fkappa_0 = 0;
137  chunk.mNewStream.Write(&fkappa_0);
138  tpzElasticResponseTranslator.UpdateStream(chunk, toVersion);
139 }
140 
141 void TPZSandlerExtendedTranslator::UpdateAttributesV2(TPZChunkInTranslation& chunk, const std::map<std::string, uint64_t>& toVersion){
142  UpdateAttributesV1(chunk, toVersion);
143 }
144 
145 void TPZSandlerExtendedTranslator::UpdateAttributes(TPZChunkInTranslation& chunk, const std::map<std::string, uint64_t>& toVersion){
146 
147  STATE ftol;
148  chunk.mOldStream.Read(&ftol);
149  chunk.mNewStream.Write(&ftol);
150  STATE fA;
151  chunk.mOldStream.Read(&fA);
152  chunk.mNewStream.Write(&fA);
153  STATE fB;
154  chunk.mOldStream.Read(&fB);
155  chunk.mNewStream.Write(&fB);
156  STATE fC;
157  chunk.mOldStream.Read(&fC);
158  chunk.mNewStream.Write(&fC);
159  STATE fD;
160  chunk.mOldStream.Read(&fD);
161  chunk.mNewStream.Write(&fD);
162  STATE fW;
163  chunk.mOldStream.Read(&fW);
164  chunk.mNewStream.Write(&fW);
165  STATE fK;
166  chunk.mOldStream.Read(&fK);
167  chunk.mNewStream.Write(&fK);
168  STATE fR;
169  chunk.mOldStream.Read(&fR);
170  chunk.mNewStream.Write(&fR);
171  STATE fG;
172  chunk.mOldStream.Read(&fG);
173  chunk.mNewStream.Write(&fG);
174  STATE fPhi;
175  chunk.mOldStream.Read(&fPhi);
176  chunk.mNewStream.Write(&fPhi);
177  STATE fN;
178  chunk.mOldStream.Read(&fN);
179  chunk.mNewStream.Write(&fN);
180  STATE fPsi;
181  chunk.mOldStream.Read(&fPsi);
182  chunk.mNewStream.Write(&fPsi);
183  STATE fE;
184  chunk.mOldStream.Read(&fE);
185  chunk.mNewStream.Write(&fE);
186  STATE fnu;
187  chunk.mOldStream.Read(&fnu);
188  chunk.mNewStream.Write(&fnu);
189  STATE fkappa_0;
190  chunk.mOldStream.Read(&fkappa_0);
191  chunk.mNewStream.Write(&fkappa_0);
192  tpzElasticResponseTranslator.UpdateStream(chunk, toVersion);
193 }
194 
196 }
virtual void Read(int *p, int howMany=1)
virtual void Write(const int *p, int howMany=1)
void UpdateAttributesV2(TPZChunkInTranslation &chunk, const std::map< std::string, uint64_t > &toVersion)
void UpdateFromV2(TPZChunkInTranslation &chunk, const std::map< std::string, uint64_t > &toVersion)
std::map< std::string, uint64_t > mOldVersion
void UpdateAttributesV1(TPZChunkInTranslation &chunk, const std::map< std::string, uint64_t > &toVersion)
virtual void UpdateStream(TPZChunkInTranslation &chunk, const std::map< std::string, uint64_t > &toVersion)
TPZContBufferedStream mOldStream
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
TPZElasticResponseTranslator tpzElasticResponseTranslator
void UpdateStream(TPZChunkInTranslation &chunk, const std::map< std::string, uint64_t > &toVersion)
virtual void UpdateAttributes(TPZChunkInTranslation &chunk, const std::map< std::string, uint64_t > &toVersion)
TPZContBufferedStream mNewStream