Hello PB Group,

I am programming a group of programs in C++ that use PB to
communicate. In my first version of the program I was using a .proto
file that looked similar to the example 1 below. I would then run a
switch statement on a MsgType and create the proper message.

I am now starting to write my second version of the program to include
a plugin module architecture. My program calls for a core program and
then multiple modules that are written against a base module. Well in
my core program I get packets over the network and then parse them
info a PB Message.

I would like a way to have some sort of Base Message that the my core
program would use to parse with the  base message would contain a
packet packet operation code and the data for the actual message
structure. I want to program it so the Core program has no idea what
the actual message structure is. It would pass it to the respective
module based on the operation code who would then  parse the actual
message structure because it knows what that structure should be.

Does anyone have any suggestions how to do this? Any help would be
much appreciated.

Example 1.

enum MsgType {

Message Msg1 {
   required int32 field = 1 ;

Message Msg2 {
   required int32 field = 1 ;

Message Msg3 {
   required int32 field = 1 ;

Message BaseMessage {
   required MsgType type = 1 ;
   optional Msg1 = 2 ;
   optional Msg2 = 3 ;
   optional Msg3 = 4 ;

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to