Re: Re: [protobuf] Re: Dynamically determine the type of a message

2010-02-11 Thread alexrichardson

...

I think union types are the best choice for a small number of possible  
messages. However, if you really need to support *any* type of message,  
you could consider adding a header message of a known type that  
includes the fully-qualified message name as returned by  
message-GetDescriptor()-full_name(), or some other unique message  
type indicator.



Good luck,



Evan
--



Evan Jones


Union types in combination with 'extensions' seems like the right solution  
for this problem in almost all cases, whether the number of message types  
is large or small.


Using a separate header message adds lots of complications as you then need  
to write additional code to instantiate the 'payload' message type etc... I  
was using a header message a while back, and migrated to union types with  
great success. Granted, I do still have a fairly small number of message  
types, but I am not aware of any issues which would arise from scaling to a  
very large set of messages. Are there known issues which arise from a union  
type with a large number of extensions?


Alex

--
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 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



Re: [protobuf] Re: Dynamically determine the type of a message

2010-02-11 Thread Evan Jones

On Feb 11, 2010, at 15:44 , alexrichard...@gmail.com wrote:
Are there known issues which arise from a union type with a large  
number of extensions?


The problem that concerns me is that I need to have unique extension  
ids. This seems difficult when using Protocol Buffers as an RPC  
system, unless I'm thinking about this in the wrong way? I haven't  
actually thought about this very hard.


Evan

--
Evan Jones
http://evanjones.ca/

--
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 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.