TipcMsgFile user class for message file I/O operations
The TipcMsgFile class provides a C++ binding to the SmartSockets TipcMsgFile API functions using a virtual I/O stream model. It allows you to create, read, write, append to and close SmartSockets message files using C++ stream I/O syntax.
None
Syntax:
|
|
Remarks:
|
Destroy a TipcMsgFile object. The destructor calls the C API function TipcMsgFileDestroy.
|
C API:
|
TipcMsgFileDestroy
|
Syntax:
|
|
Remarks:
|
Write the internal T_IPC_MSG field of a TipcMsg object to a message file.
|
C API:
|
TipcMsgFileWrite
|
This example code fragment creates a file stream from the file data.msg
, reads all the messages in the file using the extraction operator, and prints them out:
#include <rtworks/cxxipc.hxx> int main() { TipcMsgFile msg_file("data.msg", T_IPC_MSG_FILE_CREATE_READ); if (!msg_file) {// error
} TipcMsg msg_read; while (1) { msg_file >> msg_read; if (!msg_file) { break; } TutOut("Read a message.\n"); msg_read.Print(TutOut); }// Note: file stream automatically destroyed
}
If the file data.msg
contains this information:
The output is similar to this:
Read a message. type = numeric_data sender = <_file> dest = <thermal> max = 2048 size = 75 current = 0 read_only = false priority = 0 delivery_mode = best_effort ref_count = 1 seq_num = 0 resend_mode = false user_prop = 0 data (num_fields = 4): str "voltage" real8 33.4534 str "switch_pos" real8 -8843.8
TIBCO SmartSockets™ cxxipc Class Library Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |