SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
A handle class for a trace event filter that accepts multiple clients. More...
#include <rw/trace/RWTraceMultiClientFilter.h>
Public Member Functions | |
RWTraceMultiClientFilter (void) | |
RWTraceMultiClientFilter (RWTraceMultiClientFilterImp *bodyP) | |
RWTraceMultiClientFilter (RWStaticCtor) | |
RWTraceMultiClientFilter (const RWTraceMultiClientFilter &second) | |
~RWTraceMultiClientFilter (void) |
RWTraceMultiClientFilter is a filter that accepts multiple clients to which it forwards trace events.
This example creates two clients; one displays messages on the screen, and the other saves them to a file. This example can be found in examples/trace/MultiClient.cpp
.
#define RW_USER_TRACE_LEVEL 8 #include <rw\trace\trace.h> #include <fstream.h> int main(void) { // Declare function as traceable with the set name "main" // this will also generate an entry/exit event RW_USER_TRACEABLE_FUNCTION("main"); //1 // Create an output file stream. ofstream traceLog("MultiClient.log"); // Create an Ostream client on the file stream. RWTraceOstreamClient logClient(traceLog); // Create an Ostream client on cerr. RWTraceOstreamClient cerrClient(cerr); // Create a multiclient filter that sends messages to // multiple clients. RWTraceMultiClientFilter multiClient; //2 // Connect both clients to the multiClient. This must occur // before the multiClient is connected to the manager to // prevent loss of data. logClient.connect(multiClient); //3 cerrClient.connect(multiClient); // Connect the multiclient to the trace manager. multiClient.connectToManager(); //4 // Generate some trace messages; these trace events // will belong to the sets "rw_user" and "main" RW_USER_TRACE_DEBUG("Debug"); //5 RW_USER_TRACE_TEST("Test"); RW_USER_TRACE_INFO("Info"); RW_USER_TRACE_WARNING("Warning"); RW_USER_TRACE_ERROR("Error"); RW_USER_TRACE_FATAL("Fatal"); return 0; }
//1
Declares the function as traceable, so you can use trace event generation macros in this function.
//2
Instantiates the multi-client filter.
//3
First connects the two clients to the filter.
//4
Then connects the filter to the manager to ensure that no trace messages are lost.
//5
Generates some trace messages.
RWTraceMultiClientFilter::RWTraceMultiClientFilter | ( | void | ) |
Constructs an RWTraceMultiClientFilter (handle) and its body.
RWTraceMultiClientFilter::RWTraceMultiClientFilter | ( | RWTraceMultiClientFilterImp * | bodyP | ) |
Attaches to and increments the reference count on bodyP.
RWTraceMultiClientFilter::RWTraceMultiClientFilter | ( | RWStaticCtor | ) |
Constructs a global static handle instance (that may be used before being constructed).
RWTraceMultiClientFilter::RWTraceMultiClientFilter | ( | const RWTraceMultiClientFilter & | second | ) |
Attaches to and increments the reference count on the body of second.
RWTraceMultiClientFilter::~RWTraceMultiClientFilter | ( | void | ) |
Destructor.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.