Commit 58a91031e7e2f6ae6a1e30772a06f3aca159b13d
1 parent
ba57ff5c
Exists in
master
and in
1 other branch
Implementing "set" methods on IPC object.
Showing
2 changed files
with
158 additions
and
4 deletions
Show diff stats
client/src/session/remote/attribute.cc
... | ... | @@ -110,6 +110,41 @@ |
110 | 110 | return (attr.getInt32() != 0); |
111 | 111 | }; |
112 | 112 | |
113 | + if(worker->set) { | |
114 | + | |
115 | + set.asInt32 = [](const Attribute & attr, const void *worker, const int32_t value) { | |
116 | + | |
117 | + const struct Worker * w = (const struct Worker *) worker; | |
118 | + int32_t rc; | |
119 | + | |
120 | + IPC::Request(*w->session,true,w->methods->name) | |
121 | + .push(value) | |
122 | + .call() | |
123 | + .pop(rc); | |
124 | + | |
125 | + if(rc) { | |
126 | + throw std::system_error((int) rc, std::system_category()); | |
127 | + } | |
128 | + | |
129 | + }; | |
130 | + | |
131 | + set.asUint32 = [](const Attribute & attr, const void *worker, const uint32_t value) { | |
132 | + | |
133 | + const struct Worker * w = (const struct Worker *) worker; | |
134 | + int32_t rc; | |
135 | + | |
136 | + IPC::Request(*w->session,true,w->methods->name) | |
137 | + .push(value) | |
138 | + .call() | |
139 | + .pop(rc); | |
140 | + | |
141 | + if(rc) { | |
142 | + throw std::system_error((int) rc, std::system_category()); | |
143 | + } | |
144 | + | |
145 | + }; | |
146 | + | |
147 | + } | |
113 | 148 | |
114 | 149 | } |
115 | 150 | |
... | ... | @@ -145,6 +180,40 @@ |
145 | 180 | return value; |
146 | 181 | }; |
147 | 182 | |
183 | + if(worker->set) { | |
184 | + | |
185 | + set.asInt32 = [](const Attribute & attr, const void *worker, const int32_t value) { | |
186 | + | |
187 | + const struct Worker * w = (const struct Worker *) worker; | |
188 | + int32_t rc; | |
189 | + | |
190 | + IPC::Request(*w->session,true,w->methods->name) | |
191 | + .push(value) | |
192 | + .call() | |
193 | + .pop(rc); | |
194 | + | |
195 | + if(rc) { | |
196 | + throw std::system_error((int) rc, std::system_category()); | |
197 | + } | |
198 | + | |
199 | + }; | |
200 | + | |
201 | + set.asBoolean = [](const Attribute & attr, const void *worker, const bool value) { | |
202 | + | |
203 | + const struct Worker * w = (const struct Worker *) worker; | |
204 | + int32_t rc; | |
205 | + | |
206 | + IPC::Request(*w->session,true,w->methods->name) | |
207 | + .push(value) | |
208 | + .call() | |
209 | + .pop(rc); | |
210 | + | |
211 | + if(rc) { | |
212 | + throw std::system_error((int) rc, std::system_category()); | |
213 | + } | |
214 | + | |
215 | + }; | |
216 | + } | |
148 | 217 | |
149 | 218 | } |
150 | 219 | |
... | ... | @@ -181,6 +250,41 @@ |
181 | 250 | return (attr.getUint32() != 0); |
182 | 251 | }; |
183 | 252 | |
253 | + if(worker->set) { | |
254 | + | |
255 | + set.asInt32 = [](const Attribute & attr, const void *worker, const int32_t value) { | |
256 | + | |
257 | + const struct Worker * w = (const struct Worker *) worker; | |
258 | + int32_t rc; | |
259 | + | |
260 | + IPC::Request(*w->session,true,w->methods->name) | |
261 | + .push(value) | |
262 | + .call() | |
263 | + .pop(rc); | |
264 | + | |
265 | + if(rc) { | |
266 | + throw std::system_error((int) rc, std::system_category()); | |
267 | + } | |
268 | + | |
269 | + }; | |
270 | + | |
271 | + set.asUint32 = [](const Attribute & attr, const void *worker, const uint32_t value) { | |
272 | + | |
273 | + const struct Worker * w = (const struct Worker *) worker; | |
274 | + int32_t rc; | |
275 | + | |
276 | + IPC::Request(*w->session,true,w->methods->name) | |
277 | + .push(value) | |
278 | + .call() | |
279 | + .pop(rc); | |
280 | + | |
281 | + if(rc) { | |
282 | + throw std::system_error((int) rc, std::system_category()); | |
283 | + } | |
284 | + | |
285 | + }; | |
286 | + | |
287 | + } | |
184 | 288 | } |
185 | 289 | }; |
186 | 290 | |
... | ... | @@ -191,7 +295,6 @@ |
191 | 295 | |
192 | 296 | get.asString = [](const Attribute & attr, const void *worker) { |
193 | 297 | |
194 | - | |
195 | 298 | const struct Worker * w = (const struct Worker *) worker; |
196 | 299 | string value; |
197 | 300 | |
... | ... | @@ -216,6 +319,57 @@ |
216 | 319 | |
217 | 320 | }; |
218 | 321 | |
322 | + if(worker->set) { | |
323 | + | |
324 | + set.asString = [](const Attribute & attr, const void *worker, const char *value) { | |
325 | + | |
326 | + const struct Worker * w = (const struct Worker *) worker; | |
327 | + int32_t rc; | |
328 | + | |
329 | + IPC::Request(*w->session,true,w->methods->name) | |
330 | + .push(value) | |
331 | + .call() | |
332 | + .pop(rc); | |
333 | + | |
334 | + if(rc) { | |
335 | + throw std::system_error((int) rc, std::system_category()); | |
336 | + } | |
337 | + | |
338 | + }; | |
339 | + | |
340 | + set.asInt32 = [](const Attribute & attr, const void *worker, const int32_t value) { | |
341 | + | |
342 | + const struct Worker * w = (const struct Worker *) worker; | |
343 | + int32_t rc; | |
344 | + | |
345 | + IPC::Request(*w->session,true,w->methods->name) | |
346 | + .push(std::to_string(value).c_str()) | |
347 | + .call() | |
348 | + .pop(rc); | |
349 | + | |
350 | + if(rc) { | |
351 | + throw std::system_error((int) rc, std::system_category()); | |
352 | + } | |
353 | + | |
354 | + }; | |
355 | + | |
356 | + set.asUint32 = [](const Attribute & attr, const void *worker, const uint32_t value) { | |
357 | + | |
358 | + const struct Worker * w = (const struct Worker *) worker; | |
359 | + int32_t rc; | |
360 | + | |
361 | + IPC::Request(*w->session,true,w->methods->name) | |
362 | + .push(std::to_string(value).c_str()) | |
363 | + .call() | |
364 | + .pop(rc); | |
365 | + | |
366 | + if(rc) { | |
367 | + throw std::system_error((int) rc, std::system_category()); | |
368 | + } | |
369 | + | |
370 | + }; | |
371 | + | |
372 | + } | |
219 | 373 | |
220 | 374 | } |
221 | 375 | }; | ... | ... |
client/src/testprogram/testprogram.cc
... | ... | @@ -197,13 +197,13 @@ |
197 | 197 | //testAttributes(session); |
198 | 198 | |
199 | 199 | { |
200 | - TN3270::Host host{"",nullptr,10}; | |
200 | + TN3270::Host host{":a",nullptr,10}; | |
201 | 201 | |
202 | 202 | cout << "pre: " << host["url"] << endl; |
203 | 203 | |
204 | - host["url"] = "http://www.google.com.br"; | |
204 | + // host["url"] = "http://www.google.com.br"; | |
205 | 205 | |
206 | - cout << "post: " << host["url"] << endl; | |
206 | + // cout << "post: " << host["url"] << endl; | |
207 | 207 | } |
208 | 208 | |
209 | 209 | ... | ... |