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