Hi,

I want to implement a hierarchy of events using protobuf.
Specifically, I have a main Event message type. These Events currently
can be either be a StatusEvent or a DetectionEvent. Here's the proto
definitions I came up with:

// A general event, can be thought as base Event class for other event
types.
message Event {
  required int64 task_id = 1;
  required string module_name = 2;      // module that sent the event

  extensions 100 to 199;
}

// Extend the base Event with additional types of events.
extend Event {
  optional StatusEvent status_event = 100;
  optional DetectionEvent detection_event = 101;
}

// A bounding box detected in a frame representing a region of
interest.
message DetectionEvent {
  optional int64 frame = 1;     // frame number (starting at 1) where
  optional int64 time = 2;
  optional string label = 3;
}

// Change of status in current module.
message StatusEvent {
  enum EventType {
    MODULE_START = 1;
    MODULE_END = 2;
    MODULE_FATAL = 3;
  }
  required EventType type = 1;

  // Optional key-value pairs for data to be passed on.
  message Data {
    required string key = 1;
    required string value = 2;
  }
  repeated Data data = 2;
}

This compiles with protoc. My problem is, after I create an Event, e,
I don't know how to add an extension event. I though the way to go was

        myevents::Event e;
        e.set_task_id( taskID );
        e.set_module_name( moduleName );

        // Create a status event
        myevents::StatusEvent* se = e.AddExtension( myevents::status_event );
        se->set_type( myevents::StatusEvent::MODULE_START );
        myevents::StatusEvent::Data *data = se->add_data();
        data->set_key( "frame_width" );
        data->set_value( 100 );

When I do this, I get the following compilation error on my protobuf
header file:

‘Add’ is not a member of
‘google::protobuf::internal::MessageTypeTraits<myevents::StatusEvent>’

so clearly this is not the way to go. What is the correct way to do
this? Any help would be much appreciated.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to