using namespace CosNotifyComm;
A CORBA StructuredEvent is used as a communication channel between services. It is sent by a SvcProtPushSupplier? and received by a SvcProtPushConsumer.
CosNotifyComm.idl defines a StructuredEvent as consisting of a Header, some filterable data and an arbitrary CORBA object (any) for the content.
struct StructuredEvent { EventHeader header; FilterableEventBody filterable_data; any remainder_of_body; };
remainder_of_body
.
StructuredEvent sevnt; sevnt.header.fixed_header.event_type.domain_name = CORBA::string_dup( "DWARF" ); sevnt.header.fixed_header.event_type.type_name = CORBA::string_dup( "PoseData" ); sevnt.header.variable_header.length( 0 ); sevnt.filterable_data.length( 0 ); sevnt.remainder_of_body <<= myCurrentPose; // a variable of type PoseData
Now the StructuredEvent is ready to be sent. Don't forget to check if you have a consumer.
notifyConsumer->push_structured_event(sevnt); // see SvcProtPushSupplier
Usually you receive your event in the push_structured_event
method of a SvcProtPushConsumer. You then test if the event claims to be what you expect and store it in a local variable of that type.
if(!strcmp(event.header.fixed_header.event_type.type_name, "PoseData")) { PoseData *posDat; event.remainder_of_body >>= posDat; }If the event does not contain what it claims to contain you obviously have a problem.
Q: Can one of these lines throw an exception that should be caught? -- MartinBauer - 17 Jul 2003