Protocol Buffers is an open source project released by Google, which uses a specialized language to define serialization schemas, from which actual serialization code is generated. The official Protocol Buffers compiler can generate code in a number of languages, including C++, C#, Java and Python.
RCF provides native marshaling support for classes generated by the Protocol Buffers compiler. To enable this support, define
RCF_FEATURE_PROTOBUF=1 when building RCF. With
RCF_USE_PROTOBUF=1 defined, classes produced by the Protocol Buffers compiler, can be used directly in RCF interface declarations, and will be serialized and deserialized using the Protocol Buffer runtime.
For more information on building RCF with Protocol Buffer support, see Building RCF.
As an example, consider this .proto file.
Running the Protocol Buffer compiler (in C++ mode) over
Person.proto results in the two files
Person.pb.cc, containing the implementation of the C++ class
You can now include
Person.pb.h in your program, and use the class
Person in an RCF interface. RCF will detect that the
Person class is a Protocol Buffer class, and will use Protocol Buffer functions to serialize and deserialize
Protocol Buffer classes can be used together with native C++ classes, in RCF interfaces:
The serialization and deserialization code generated by Protocol Buffers is highly optimized. However, to make the most of this performance, you may want to cache and reuse Protocol Buffer objects from call to call, rather than creating new ones. Protocol Buffer objects are designed to retain any memory they allocate, and will reuse that memory in subsequent serialization and deserialization operations.
RCF provides server-side object caching, for this purpose. Here is an example of enabling server-side caching of
Past versions of RCF supported the usage of Boost.Serialization , as a drop in replacement for RCF's internal serialization framework.
As of RCF 3.0, however, usage of Boost.Serialization is deprecated.
Support for Boost.Serialization will be removed from the codebase in a future release.