At my server, we receive Self Described Messages (as defined 
here<https://developers.google.com/protocol-buffers/docs/techniques#self-description>...
 
which btw wasn't all that easy as there aren't any 'good' examples of this 
in c++ but was definitely manageable). 

At this point I am having no issue creating messages from these 
self-described ones. I can take the FileDescriptorSet, go through each 
FileDescriptorProto<https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.descriptor.pb#FileDescriptorProto>,
 
adding each to a DescriptorPool (using 
BuildFile<https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.descriptor#DescriptorPool.BuildFile>,
 
which also gives me every defined FileDescriptor).

>From here I can create any of the messages which were defined in the 
FileDescriptorSet with a DynamicMessageFactory instanced with the DP and 
calling 
GetPrototype<https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.dynamic_message#DynamicMessageFactory.GetPrototype.details>(which
 is very easy to do as our SelfDescribedMessage required the messages 
full_name() and thus we can call the 
FindMessageTypeByName<https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.descriptor#DescriptorPool.FindMessageTypeByName>method
 of the DP, giving us the properly encoded Message Prototype).

The question is how can I take each already defined Descriptor or message 
and dynamically BUILD a 'master' message that contains all of the defined 
messages as nested messages. This would primarily be used for saving the 
current state of the messages. Currently we're handling this by just 
instancing a type of each message in the server(to keep a central state 
across different programs). But when we want to 'save off' the current 
state, we're forced to stream them to disk as defined 
here<https://developers.google.com/protocol-buffers/docs/techniques#streaming>. 
They're streamed one message at a time (with a size prefix). We'd like to 
have ONE message (one to rule them all) instead of the steady stream of 
separate messages. This can be used for other things once it is worked out 
(network based shared state with optimized and easy serialization) 

Since we already have the cross-linked and defined Descriptors, one would 
think there would be an easy way to build 'new' messages from those already 
defined ones. So far the solution has alluded us. We've tried creating our 
own DescriptorProto and adding new fields of the type from our already 
defined Descriptors but got lost (haven't deep dived into this one yet). 
We've also looked at possibly adding them as extensions (unknown at this 
time how to do so). Do we need to create our own 
DescriptorDatabase<https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.descriptor_database#DescriptorDatabase>(also
 unknown at this time how to do so)?

Any insights? I've tried posting a question at 
stackoverflow<http://stackoverflow.com/questions/11996557/how-to-dynamically-build-a-new-protobuf-from-a-set-of-already-defined-descriptor>but
 haven't had any responses. I apologize if this isn't the correct 
location to ask this question.

Thank You

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/protobuf/-/wap-Qgj0RmgJ.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to