Can you just have the OParameter message contain optional fields of type
string and int64, where only one of the two is ever set?  Then don't have
specific types corresponding to OStringParameter and OLongParameter.

On Tue, Aug 4, 2009 at 5:07 PM, Tai <maitai.tru...@gmail.com> wrote:

>
> Hi,
>
> I have an (abstract) class:
> - OParameter with a member String key
>
> Now there are also two subclasses of OParameter:
> - OStringParameter with a member String value
> - OLongParameter with a member long value
>
> By using Protocol Buffers I define the proto files:
> - OParameterMessage.proto
> - OStringParameterMessage.proto
> - OLongParameterMessage.proto
>
> The files are independent from each other (no extension is used). As
> far as I understand this is how Protocol Buffers should be used. All
> classes (OParameter, OStringParameter and OLongParameter) then
> implements the writeObject() and readObject() and each class just uses
> their Protocol message and sets their members. Like:
> - Class OStringParameter.writeObject() builds a message and sets only
> its member (value)
> - The superclass OParameter.writeObject() builds a message and sets
> only its member (key)
>
> The same goes for the readObject().
>
> Okay. So far so good. But now I have a class called OListParameter and
> its member (value) is a list of OParameter containing instances of
> both types: OStringParameter and OLongParameter.
>
> How do I describe this in a proto file?
>
> Thanks Tai
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
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