OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TVirtualProtocol.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  * Copyright 2006-2017 The Apache Software Foundation.
20  * https://github.com/apache/thrift
21  */
22 #include <boost/uuid/uuid.hpp>
23 
24 #ifndef _SANDESH_PROTOCOL_TVIRTUALPROTOCOL_H_
25 #define _SANDESH_PROTOCOL_TVIRTUALPROTOCOL_H_ 1
26 
27 #include <map>
28 #include <string>
29 #include <sandesh/protocol/TProtocol.h>
30 
31 namespace contrail { namespace sandesh { namespace protocol {
32 
44 class TProtocolDefaults : public TProtocol {
45  public:
46  int32_t readMessageBegin(std::string& name,
47  TMessageType& messageType,
48  int32_t& seqid) {
49  (void) name;
50  (void) messageType;
51  (void) seqid;
52  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
53  assert(false);
54  return -1;
55  }
56 
57  int32_t readMessageEnd() {
58  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
59  assert(false);
60  return -1;
61  }
62 
63  int32_t readStructBegin(std::string& name) {
64  (void) name;
65  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
66  assert(false);
67  return -1;
68  }
69 
70  int32_t readStructEnd() {
71  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
72  assert(false);
73  return -1;
74  }
75 
76  int32_t readSandeshBegin(std::string& name) {
77  (void) name;
78  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
79  assert(false);
80  return -1;
81  }
82 
83  int32_t readSandeshEnd() {
84  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
85  assert(false);
86  return -1;
87  }
88 
90  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
91  assert(false);
92  return -1;
93  }
94 
96  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
97  assert(false);
98  return -1;
99  }
100 
101  int32_t readFieldBegin(std::string& name,
102  TType& fieldType,
103  int16_t& fieldId) {
104  (void) name;
105  (void) fieldType;
106  (void) fieldId;
107  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
108  assert(false);
109  return -1;
110  }
111 
112  int32_t readFieldEnd() {
113  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
114  assert(false);
115  return -1;
116  }
117 
118  int32_t readMapBegin(TType& keyType, TType& valType, uint32_t& size) {
119  (void) keyType;
120  (void) valType;
121  (void) size;
122  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
123  assert(false);
124  return -1;
125  }
126 
127  int32_t readMapEnd() {
128  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
129  assert(false);
130  return -1;
131  }
132 
133  int32_t readListBegin(TType& elemType, uint32_t& size) {
134  (void) elemType;
135  (void) size;
136  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
137  assert(false);
138  return -1;
139  }
140 
141  int32_t readListEnd() {
142  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
143  assert(false);
144  return -1;
145  }
146 
147  int32_t readSetBegin(TType& elemType, uint32_t& size) {
148  (void) elemType;
149  (void) size;
150  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
151  assert(false);
152  return -1;
153  }
154 
155  int32_t readSetEnd() {
156  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
157  assert(false);
158  return -1;
159  }
160 
161  int32_t readBool(bool& value) {
162  (void) value;
163  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
164  assert(false);
165  return -1;
166  }
167 
168  int32_t readBool(std::vector<bool>::reference value) {
169  (void) value;
170  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
171  assert(false);
172  return -1;
173  }
174 
175  int32_t readByte(int8_t& byte) {
176  (void) byte;
177  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
178  assert(false);
179  return -1;
180  }
181 
182  int32_t readI16(int16_t& i16) {
183  (void) i16;
184  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
185  assert(false);
186  return -1;
187  }
188 
189  int32_t readI32(int32_t& i32) {
190  (void) i32;
191  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
192  assert(false);
193  return -1;
194  }
195 
196  int32_t readI64(int64_t& i64) {
197  (void) i64;
198  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
199  assert(false);
200  return -1;
201  }
202 
203  int32_t readU16(uint16_t& u16) {
204  (void) u16;
205  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
206  assert(false);
207  return -1;
208  }
209 
210  int32_t readU32(uint32_t& u32) {
211  (void) u32;
212  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
213  assert(false);
214  return -1;
215  }
216 
217  int32_t readU64(uint64_t& u64) {
218  (void) u64;
219  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
220  assert(false);
221  return -1;
222  }
223 
224  int32_t readIPV4(uint32_t& ip4) {
225  (void) ip4;
226  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
227  assert(false);
228  return -1;
229  }
230 
231  int32_t readIPADDR(boost::asio::ip::address& ipaddress) {
232  (void) ipaddress;
233  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
234  assert(false);
235  return -1;
236  }
237 
238  int32_t readDouble(double& dub) {
239  (void) dub;
240  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
241  assert(false);
242  return -1;
243  }
244 
245  int32_t readString(std::string& str) {
246  (void) str;
247  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
248  assert(false);
249  return -1;
250  }
251 
252  int32_t readBinary(std::string& str) {
253  (void) str;
254  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
255  assert(false);
256  return -1;
257  }
258 
259  int32_t readXML(std::string& str) {
260  (void) str;
261  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
262  assert(false);
263  return -1;
264  }
265 
267  (void) uuid;
268  LOG(ERROR, __func__ << ": This protocol does not support reading (yet).");
269  assert(false);
270  return -1;
271  }
272 
273  int32_t writeMessageBegin(const std::string& name,
274  const TMessageType messageType,
275  const int32_t seqid) {
276  (void) name;
277  (void) messageType;
278  (void) seqid;
279  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
280  assert(false);
281  return -1;
282  }
283 
284  int32_t writeMessageEnd() {
285  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
286  assert(false);
287  return -1;
288  }
289 
290  int32_t writeStructBegin(const char* name) {
291  (void) name;
292  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
293  assert(false);
294  return -1;
295  }
296 
297  int32_t writeStructEnd() {
298  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
299  assert(false);
300  return -1;
301  }
302 
303  int32_t writeSandeshBegin(const char* name) {
304  (void) name;
305  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
306  assert(false);
307  return -1;
308  }
309 
310  int32_t writeSandeshEnd() {
311  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
312  assert(false);
313  return -1;
314  }
315 
317  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
318  assert(false);
319  return -1;
320  }
321 
323  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
324  assert(false);
325  return -1;
326  }
327 
328  int32_t writeFieldBegin(const char* name,
329  const TType fieldType,
330  const int16_t fieldId,
331  const std::map<std::string, std::string> *const amap = NULL) {
332  (void) name;
333  (void) fieldType;
334  (void) fieldId;
335  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
336  assert(false);
337  return -1;
338  }
339 
340  int32_t writeFieldEnd() {
341  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
342  assert(false);
343  return -1;
344  }
345 
346  int32_t writeFieldStop() {
347  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
348  assert(false);
349  return -1;
350  }
351 
352  int32_t writeMapBegin(const TType keyType,
353  const TType valType,
354  const uint32_t size) {
355  (void) keyType;
356  (void) valType;
357  (void) size;
358  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
359  assert(false);
360  return -1;
361  }
362 
363  int32_t writeMapEnd() {
364  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
365  assert(false);
366  return -1;
367  }
368 
369  int32_t writeListBegin(const TType elemType, const uint32_t size) {
370  (void) elemType;
371  (void) size;
372  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
373  assert(false);
374  return -1;
375  }
376 
377  int32_t writeListEnd() {
378  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
379  assert(false);
380  return -1;
381  }
382 
383  int32_t writeSetBegin(const TType elemType, const uint32_t size) {
384  (void) elemType;
385  (void) size;
386  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
387  assert(false);
388  return -1;
389  }
390 
391  int32_t writeSetEnd() {
392  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
393  assert(false);
394  return -1;
395  }
396 
397  int32_t writeBool(const bool value) {
398  (void) value;
399  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
400  assert(false);
401  return -1;
402  }
403 
404  int32_t writeByte(const int8_t byte) {
405  (void) byte;
406  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
407  assert(false);
408  return -1;
409  }
410 
411  int32_t writeI16(const int16_t i16) {
412  (void) i16;
413  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
414  assert(false);
415  return -1;
416  }
417 
418  int32_t writeI32(const int32_t i32) {
419  (void) i32;
420  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
421  assert(false);
422  return -1;
423  }
424 
425  int32_t writeI64(const int64_t i64) {
426  (void) i64;
427  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
428  assert(false);
429  return -1;
430  }
431 
432  int32_t writeU16(const uint16_t i16) {
433  (void) i16;
434  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
435  assert(false);
436  return -1;
437  }
438 
439  int32_t writeU32(const uint32_t i32) {
440  (void) i32;
441  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
442  assert(false);
443  return -1;
444  }
445 
446  int32_t writeU64(const uint64_t i64) {
447  (void) i64;
448  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
449  assert(false);
450  return -1;
451  }
452 
453  int32_t writeIPV4(const uint32_t ip4) {
454  (void) ip4;
455  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
456  assert(false);
457  return -1;
458  }
459 
460  int32_t writeIPADDR(const boost::asio::ip::address& ipaddress) {
461  (void) ipaddress;
462  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
463  assert(false);
464  return -1;
465  }
466 
467  int32_t writeDouble(const double dub) {
468  (void) dub;
469  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
470  assert(false);
471  return -1;
472  }
473 
474  int32_t writeString(const std::string& str) {
475  (void) str;
476  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
477  assert(false);
478  return -1;
479  }
480 
481  int32_t writeBinary(const std::string& str) {
482  (void) str;
483  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
484  assert(false);
485  return -1;
486  }
487 
488  int32_t writeXML(const std::string& str) {
489  (void) str;
490  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
491  assert(false);
492  return -1;
493  }
494 
496  (void) uuid;
497  LOG(ERROR, __func__ << ": This protocol does not support writing (yet).");
498  assert(false);
499  return -1;
500  }
501 
502  int32_t skip(TType type) {
504  }
505 
506  protected:
507  TProtocolDefaults(boost::shared_ptr<TTransport> ptrans)
508  : TProtocol(ptrans)
509  {}
510 };
511 
516 template <class Protocol_, class Super_=TProtocolDefaults>
517 class TVirtualProtocol : public Super_ {
518  public:
523  virtual int32_t writeMessageBegin_virt(const std::string& name,
524  const TMessageType messageType,
525  const int32_t seqid) {
526  return static_cast<Protocol_*>(this)->writeMessageBegin(name, messageType,
527  seqid);
528  }
529 
530  virtual int32_t writeMessageEnd_virt() {
531  return static_cast<Protocol_*>(this)->writeMessageEnd();
532  }
533 
534 
535  virtual int32_t writeStructBegin_virt(const char* name) {
536  return static_cast<Protocol_*>(this)->writeStructBegin(name);
537  }
538 
539  virtual int32_t writeStructEnd_virt() {
540  return static_cast<Protocol_*>(this)->writeStructEnd();
541  }
542 
543  virtual int32_t writeSandeshBegin_virt(const char* name) {
544  return static_cast<Protocol_*>(this)->writeSandeshBegin(name);
545  }
546 
547  virtual int32_t writeSandeshEnd_virt() {
548  return static_cast<Protocol_*>(this)->writeSandeshEnd();
549  }
550 
552  return static_cast<Protocol_*>(this)->writeContainerElementBegin();
553  }
554 
555  virtual int32_t writeContainerElementEnd_virt() {
556  return static_cast<Protocol_*>(this)->writeContainerElementEnd();
557  }
558 
559  virtual int32_t writeFieldBegin_virt(const char* name,
560  const TType fieldType,
561  const int16_t fieldId,
562  const std::map<std::string, std::string> *const amap = NULL) {
563  return static_cast<Protocol_*>(this)->writeFieldBegin(name, fieldType,
564  fieldId, amap);
565  }
566 
567  virtual int32_t writeFieldEnd_virt() {
568  return static_cast<Protocol_*>(this)->writeFieldEnd();
569  }
570 
571  virtual int32_t writeFieldStop_virt() {
572  return static_cast<Protocol_*>(this)->writeFieldStop();
573  }
574 
575  virtual int32_t writeMapBegin_virt(const TType keyType,
576  const TType valType,
577  const uint32_t size) {
578  return static_cast<Protocol_*>(this)->writeMapBegin(keyType, valType, size);
579  }
580 
581  virtual int32_t writeMapEnd_virt() {
582  return static_cast<Protocol_*>(this)->writeMapEnd();
583  }
584 
585  virtual int32_t writeListBegin_virt(const TType elemType,
586  const uint32_t size) {
587  return static_cast<Protocol_*>(this)->writeListBegin(elemType, size);
588  }
589 
590  virtual int32_t writeListEnd_virt() {
591  return static_cast<Protocol_*>(this)->writeListEnd();
592  }
593 
594  virtual int32_t writeSetBegin_virt(const TType elemType,
595  const uint32_t size) {
596  return static_cast<Protocol_*>(this)->writeSetBegin(elemType, size);
597  }
598 
599  virtual int32_t writeSetEnd_virt() {
600  return static_cast<Protocol_*>(this)->writeSetEnd();
601  }
602 
603  virtual int32_t writeBool_virt(const bool value) {
604  return static_cast<Protocol_*>(this)->writeBool(value);
605  }
606 
607  virtual int32_t writeByte_virt(const int8_t byte) {
608  return static_cast<Protocol_*>(this)->writeByte(byte);
609  }
610 
611  virtual int32_t writeI16_virt(const int16_t i16) {
612  return static_cast<Protocol_*>(this)->writeI16(i16);
613  }
614 
615  virtual int32_t writeI32_virt(const int32_t i32) {
616  return static_cast<Protocol_*>(this)->writeI32(i32);
617  }
618 
619  virtual int32_t writeI64_virt(const int64_t i64) {
620  return static_cast<Protocol_*>(this)->writeI64(i64);
621  }
622 
623  virtual int32_t writeU16_virt(const uint16_t u16) {
624  return static_cast<Protocol_*>(this)->writeU16(u16);
625  }
626 
627  virtual int32_t writeU32_virt(const uint32_t u32) {
628  return static_cast<Protocol_*>(this)->writeU32(u32);
629  }
630 
631  virtual int32_t writeU64_virt(const uint64_t u64) {
632  return static_cast<Protocol_*>(this)->writeU64(u64);
633  }
634 
635  virtual int32_t writeIPV4_virt(const uint32_t ip4) {
636  return static_cast<Protocol_*>(this)->writeIPV4(ip4);
637  }
638 
639  virtual int32_t writeIPADDR_virt(const boost::asio::ip::address& ipaddress) {
640  return static_cast<Protocol_*>(this)->writeIPADDR(ipaddress);
641  }
642 
643  virtual int32_t writeDouble_virt(const double dub) {
644  return static_cast<Protocol_*>(this)->writeDouble(dub);
645  }
646 
647  virtual int32_t writeString_virt(const std::string& str) {
648  return static_cast<Protocol_*>(this)->writeString(str);
649  }
650 
651  virtual int32_t writeBinary_virt(const std::string& str) {
652  return static_cast<Protocol_*>(this)->writeBinary(str);
653  }
654 
655  virtual int32_t writeXML_virt(const std::string& str) {
656  return static_cast<Protocol_*>(this)->writeXML(str);
657  }
658 
659  virtual int32_t writeUUID_virt(const boost::uuids::uuid& uuid) {
660  return static_cast<Protocol_*>(this)->writeUUID(uuid);
661  }
662 
667  virtual int32_t readMessageBegin_virt(std::string& name,
668  TMessageType& messageType,
669  int32_t& seqid) {
670  return static_cast<Protocol_*>(this)->readMessageBegin(name, messageType,
671  seqid);
672  }
673 
674  virtual int32_t readMessageEnd_virt() {
675  return static_cast<Protocol_*>(this)->readMessageEnd();
676  }
677 
678  virtual int32_t readStructBegin_virt(std::string& name) {
679  return static_cast<Protocol_*>(this)->readStructBegin(name);
680  }
681 
682  virtual int32_t readStructEnd_virt() {
683  return static_cast<Protocol_*>(this)->readStructEnd();
684  }
685 
686  virtual int32_t readSandeshBegin_virt(std::string& name) {
687  return static_cast<Protocol_*>(this)->readSandeshBegin(name);
688  }
689 
690  virtual int32_t readSandeshEnd_virt() {
691  return static_cast<Protocol_*>(this)->readSandeshEnd();
692  }
693 
694  virtual int32_t readContainerElementBegin_virt() {
695  return static_cast<Protocol_*>(this)->readContainerElementBegin();
696  }
697 
698  virtual int32_t readContainerElementEnd_virt() {
699  return static_cast<Protocol_*>(this)->readContainerElementEnd();
700  }
701 
702  virtual int32_t readFieldBegin_virt(std::string& name,
703  TType& fieldType,
704  int16_t& fieldId) {
705  return static_cast<Protocol_*>(this)->readFieldBegin(name, fieldType,
706  fieldId);
707  }
708 
709  virtual int32_t readFieldEnd_virt() {
710  return static_cast<Protocol_*>(this)->readFieldEnd();
711  }
712 
713  virtual int32_t readMapBegin_virt(TType& keyType,
714  TType& valType,
715  uint32_t& size) {
716  return static_cast<Protocol_*>(this)->readMapBegin(keyType, valType, size);
717  }
718 
719  virtual int32_t readMapEnd_virt() {
720  return static_cast<Protocol_*>(this)->readMapEnd();
721  }
722 
723  virtual int32_t readListBegin_virt(TType& elemType,
724  uint32_t& size) {
725  return static_cast<Protocol_*>(this)->readListBegin(elemType, size);
726  }
727 
728  virtual int32_t readListEnd_virt() {
729  return static_cast<Protocol_*>(this)->readListEnd();
730  }
731 
732  virtual int32_t readSetBegin_virt(TType& elemType,
733  uint32_t& size) {
734  return static_cast<Protocol_*>(this)->readSetBegin(elemType, size);
735  }
736 
737  virtual int32_t readSetEnd_virt() {
738  return static_cast<Protocol_*>(this)->readSetEnd();
739  }
740 
741  virtual int32_t readBool_virt(bool& value) {
742  return static_cast<Protocol_*>(this)->readBool(value);
743  }
744 
745  virtual int32_t readBool_virt(std::vector<bool>::reference value) {
746  return static_cast<Protocol_*>(this)->readBool(value);
747  }
748 
749  virtual int32_t readByte_virt(int8_t& byte) {
750  return static_cast<Protocol_*>(this)->readByte(byte);
751  }
752 
753  virtual int32_t readI16_virt(int16_t& i16) {
754  return static_cast<Protocol_*>(this)->readI16(i16);
755  }
756 
757  virtual int32_t readI32_virt(int32_t& i32) {
758  return static_cast<Protocol_*>(this)->readI32(i32);
759  }
760 
761  virtual int32_t readI64_virt(int64_t& i64) {
762  return static_cast<Protocol_*>(this)->readI64(i64);
763  }
764 
765  virtual int32_t readU16_virt(uint16_t& u16) {
766  return static_cast<Protocol_*>(this)->readU16(u16);
767  }
768 
769  virtual int32_t readU32_virt(uint32_t& u32) {
770  return static_cast<Protocol_*>(this)->readU32(u32);
771  }
772 
773  virtual int32_t readU64_virt(uint64_t& u64) {
774  return static_cast<Protocol_*>(this)->readU64(u64);
775  }
776 
777  virtual int32_t readIPV4_virt(uint32_t& ip4) {
778  return static_cast<Protocol_*>(this)->readIPV4(ip4);
779  }
780 
781  virtual int32_t readIPADDR_virt(boost::asio::ip::address& ipaddress) {
782  return static_cast<Protocol_*>(this)->readIPADDR(ipaddress);
783  }
784 
785  virtual int32_t readDouble_virt(double& dub) {
786  return static_cast<Protocol_*>(this)->readDouble(dub);
787  }
788 
789  virtual int32_t readString_virt(std::string& str) {
790  return static_cast<Protocol_*>(this)->readString(str);
791  }
792 
793  virtual int32_t readBinary_virt(std::string& str) {
794  return static_cast<Protocol_*>(this)->readBinary(str);
795  }
796 
797  virtual int32_t readXML_virt(std::string& str) {
798  return static_cast<Protocol_*>(this)->readXML(str);
799  }
800 
802  return static_cast<Protocol_*>(this)->readUUID(uuid);
803  }
804 
805  virtual int32_t skip_virt(TType type) {
806  return static_cast<Protocol_*>(this)->skip(type);
807  }
808 
809  /*
810  * Provide a default skip() implementation that uses non-virtual read
811  * methods.
812  *
813  * Note: subclasses that use TVirtualProtocol to derive from another protocol
814  * implementation (i.e., not TProtocolDefaults) should beware that this may
815  * override any non-default skip() implementation provided by the parent
816  * transport class. They may need to explicitly redefine skip() to call the
817  * correct parent implementation, if desired.
818  */
819  int32_t skip(TType type) {
820  Protocol_* const prot = static_cast<Protocol_*>(this);
822  }
823 
824  /*
825  * Provide a default readBool() implementation for use with
826  * std::vector<bool>, that behaves the same as reading into a normal bool.
827  *
828  * Subclasses can override this if desired, but there normally shouldn't
829  * be a need to.
830  */
831  int32_t readBool(std::vector<bool>::reference value) {
832  bool b = false;
833  uint32_t ret = static_cast<Protocol_*>(this)->readBool(b);
834  value = b;
835  return ret;
836  }
837  using Super_::readBool; // so we don't hide readBool(bool&)
838 
839  protected:
840  protected:
841  TVirtualProtocol(boost::shared_ptr<TTransport> ptrans)
842  : Super_(ptrans)
843  {}
844 };
845 
846 }}} // contrail::sandesh::protocol
847 
848 #endif // #define _SANDESH_PROTOCOL_TVIRTUALPROTOCOL_H_ 1
virtual int32_t readU32_virt(uint32_t &u32)
virtual int32_t writeString_virt(const std::string &str)
virtual int32_t writeMessageBegin_virt(const std::string &name, const TMessageType messageType, const int32_t seqid)
int32_t writeSetBegin(const TType elemType, const uint32_t size)
TProtocolDefaults(boost::shared_ptr< TTransport > ptrans)
virtual int32_t readBool_virt(std::vector< bool >::reference value)
virtual int32_t writeI32_virt(const int32_t i32)
virtual int32_t readMapBegin_virt(TType &keyType, TType &valType, uint32_t &size)
int32_t readMapBegin(TType &keyType, TType &valType, uint32_t &size)
virtual int32_t readU16_virt(uint16_t &u16)
int32_t writeXML(const std::string &str)
virtual int32_t writeBool_virt(const bool value)
int32_t readIPADDR(boost::asio::ip::address &ipaddress)
int32_t readFieldBegin(std::string &name, TType &fieldType, int16_t &fieldId)
int32_t readUUID(boost::uuids::uuid &uuid)
virtual int32_t readU64_virt(uint64_t &u64)
virtual int32_t writeFieldBegin_virt(const char *name, const TType fieldType, const int16_t fieldId, const std::map< std::string, std::string > *const amap=NULL)
virtual int32_t readByte_virt(int8_t &byte)
virtual int32_t writeI64_virt(const int64_t i64)
int32_t readListBegin(TType &elemType, uint32_t &size)
virtual int32_t readBinary_virt(std::string &str)
virtual int32_t readXML_virt(std::string &str)
int32_t writeString(const std::string &str)
virtual int32_t writeI16_virt(const int16_t i16)
virtual int32_t writeSetBegin_virt(const TType elemType, const uint32_t size)
virtual int32_t readMessageBegin_virt(std::string &name, TMessageType &messageType, int32_t &seqid)
boost::uuids::uuid uuid
virtual int32_t readI64_virt(int64_t &i64)
virtual int32_t readString_virt(std::string &str)
virtual int32_t readI32_virt(int32_t &i32)
int32_t readBool(std::vector< bool >::reference value)
virtual int32_t writeStructBegin_virt(const char *name)
virtual int32_t readIPV4_virt(uint32_t &ip4)
int32_t writeMessageBegin(const std::string &name, const TMessageType messageType, const int32_t seqid)
virtual int32_t writeByte_virt(const int8_t byte)
int32_t writeMapBegin(const TType keyType, const TType valType, const uint32_t size)
virtual int32_t readIPADDR_virt(boost::asio::ip::address &ipaddress)
int32_t writeUUID(const boost::uuids::uuid &uuid)
virtual int32_t writeXML_virt(const std::string &str)
uint8_t type
Definition: load_balance.h:109
virtual int32_t readSandeshBegin_virt(std::string &name)
int32_t writeBinary(const std::string &str)
int32_t readSetBegin(TType &elemType, uint32_t &size)
virtual int32_t writeSandeshBegin_virt(const char *name)
virtual int32_t readDouble_virt(double &dub)
virtual int32_t readListBegin_virt(TType &elemType, uint32_t &size)
virtual int32_t writeBinary_virt(const std::string &str)
virtual int32_t readStructBegin_virt(std::string &name)
int32_t readBool(std::vector< bool >::reference value)
virtual int32_t writeMapBegin_virt(const TType keyType, const TType valType, const uint32_t size)
virtual int32_t writeIPADDR_virt(const boost::asio::ip::address &ipaddress)
virtual int32_t readI16_virt(int16_t &i16)
virtual int32_t readFieldBegin_virt(std::string &name, TType &fieldType, int16_t &fieldId)
virtual int32_t writeU16_virt(const uint16_t u16)
virtual int32_t writeUUID_virt(const boost::uuids::uuid &uuid)
virtual int32_t writeU32_virt(const uint32_t u32)
virtual int32_t writeIPV4_virt(const uint32_t ip4)
#define LOG(_Level, _Msg)
Definition: logging.h:33
virtual int32_t writeListBegin_virt(const TType elemType, const uint32_t size)
TVirtualProtocol(boost::shared_ptr< TTransport > ptrans)
virtual int32_t readSetBegin_virt(TType &elemType, uint32_t &size)
int32_t writeIPADDR(const boost::asio::ip::address &ipaddress)
int32_t writeFieldBegin(const char *name, const TType fieldType, const int16_t fieldId, const std::map< std::string, std::string > *const amap=NULL)
int32_t readMessageBegin(std::string &name, TMessageType &messageType, int32_t &seqid)
virtual int32_t writeDouble_virt(const double dub)
virtual int32_t readUUID_virt(boost::uuids::uuid &uuid)
int32_t skip(Protocol_ &prot, TType type)
Definition: TProtocol.h:187
virtual int32_t writeU64_virt(const uint64_t u64)
int32_t writeListBegin(const TType elemType, const uint32_t size)