System Interface CATIStreamMsg

Usage: you can freely reimplement this interface.


interface CATIStreamMsg

Interface to stream and unstream backbone messages.
Role: This interface must be implemented by backbone messages to enable their streaming and unstreaming.

If your message contains simple data types, use the methods of the interface implemented by the component.


Method Index


o FreeStreamData(void*,uint32)
Frees the backbone message streaming buffer.
o SetMessageSpecifications()
Sets backbone message class name and options.
o StreamData(void**,uint32*)
Streams a backbone message.
o UnstreamData(void*,uint32)
Unstreams a backbone message.

Methods


o FreeStreamData
public virtual FreeStreamData( Buffer,
iLength)
Frees the backbone message streaming buffer.
Role: Any backbone message sent uses a buffer allocated by the method. This buffer must be freed as soon as the message is sent. If your message contains simple data types, you can use the interface to free them.
Example:
This example implements FreeStreamData to free the buffer containing a streamed backbone message.
 HRESULT FreeStreamData(void *Buffer, uint32 iLength)
 {
   ...
   CATIBBStreamer * pICATIBBStreamer = NULL ;
   HRESULT rc = QueryInterface(IID_CATIBBStreamer,(void**)&pICATIBBStreamer);
   if ( SUCCEEDED(rc) )
   {
     pICATIBBStreamer->ResetStreamData();  // free simple data types at once

     pICATIBBStreamer->Release();
     pICATIBBStreamer = NULL ;
   }
   ... // free other data 
 }
 
Parameters:
iBuffer
The buffer to be freed. It was created by the
method
iLength
The iBuffer length expressed in bytes
o SetMessageSpecifications
public virtual SetMessageSpecifications()
Sets backbone message class name and options.
Role: Use the interface to set options and class message name. The class name of the message is mandatory, but for specifiers, if you precise anything your message is without answer and received by all destinator application ( )
Example:
This example implements SetMessageSpecifications
 HRESULT SetMessageSpecifications()
 {
   ...
   CATICommMsg * pICATICommMsg = NULL;
   HRESULT rc = QueryInterface(IID_CATICommMsg,(void**)&pICATICommMsg);
  
   if ( SUCCEEDED(rc) )
   {
     // To set the message class name (mandatory)
     // MessageClassName is the name of the component. 
     pICATICommMsg->SetMessageClass(MessageClassName);

     // To set options (if necessary)
     pICATICommMsg->SetMessageSpecifiers(..|..|..);

     pICATICommMsg->Release();
     pICATICommMsg = NULL;
   }
 }
 
o StreamData
public virtual StreamData( oBuffer,
oLength)
Streams a backbone message.
Role: To send a message to the backbone bus, the message must be first streamed. If the message contains simple data types, you can use the interface to stream them. Once the message is sent, use to free the buffer containing the streamed message.
Example:
This example implements StreamData to stream a backbone message.
 HRESULT StreamData( void **oBuffer, uint32 *oLength)
 {
   ...
   CATIBBStreamer * pICATIBBStreamer = NULL ;
   HRESULT rc = QueryInterface(IID_CATIBBStreamer,(void**)&pICATIBBStreamer);
   // stream simple data types
   if ( SUCCEEDED(rc) )
   {
     // Begin by this instruction 
     pICATIBBStreamer->BeginStream();

     // Stream each message data according to its type
     // ----------------------------------------------
     pICATIBBStreamer->StreamFloat(..); 
     pICATIBBStreamer->StreamInt(..); 

     // End by these 3 instructions 
     int Length; 
     *oBuffer = pICATIBBStreamer->EndStream(&Length);
     *oLength = Length ;

     pICATIBBStreamer->Release();
     pICATIBBStreamer = NULL;
     }
	 ... // stream other data and update oLength
  }
  
Parameters:
oBuffer
This buffer, to be allocated, contains all the streamed data
oLength
The length of oBuffer expressed in bytes
o UnstreamData
public virtual UnstreamData( iBuffer,
iLength)
Unstreams a backbone message.
Role: A message sent to the backbone bus is streamed. This method allows you to unstream it. If the message contains simple data types, you can use the interface to unstream them.
Example:
This example implements UnstreamData to unstream a received backbone message.
 HRESULT UnstreamData(void *iBuffer, uint32 iLength)
 {
   ...
   CATIBBStreamer * pICATIBBStreamer = NULL;
   HRESULT rc = QueryInterface(IID_CATIBBStreamer,(void**)&pICATIBBStreamer);
   // unstream simple data types
   if ( SUCCEEDED(rc) )
   {
     // Begin by this instruction 
     pICATIBBStreamer->BeginUnstream(iBuffer, iLength);

	 // Unstream message data (in the same order as when streaming)
     // according to its type 
	 // -----------------------------------------------------------
     pICATIBBStreamer->UnstreamFloat(..); 
     pICATIBBStreamer->UnstreamInt(..); 
	 ...
     // --------------------------
     // End by this instruction 
     pICATIBBStreamer->EndUnstream();

     pICATIBBStreamer->Release();
     pICATIBBStreamer = NULL;
   }
   ...  // unstream other data
 }
 
Parameters:
iBuffer
The buffer containing the raw data to unstream
iLength
The length of iBuffer expressed in bytes

This object is included in the file: CATIStreamMsg.h
If needed, your Imakefile.mk should include the module: CATSysCommunication

Copyright © 1999-2015, Dassault Systèmes. All rights reserved.