13 UiVariableTracer<unsigned short> b; |
13 UiVariableTracer<unsigned short> b; |
14 StreamTracer c; |
14 StreamTracer c; |
15 CallbackTracer<double, int> d; |
15 CallbackTracer<double, int> d; |
16 |
16 |
17 void |
17 void |
18 registerAllTraceSources (TraceContainer *container) |
18 RegisterAllTraceSources (TraceContainer *container) |
19 { |
19 { |
20 container->registerCallback ("source-a", &a); |
20 container->RegisterCallback ("source-a", &a); |
21 container->registerUiVariable ("source-b", &b); |
21 container->RegisterUiVariable ("source-b", &b); |
22 container->registerStream ("source-c", &c); |
22 container->RegisterStream ("source-c", &c); |
23 container->registerCallback ("source-d", &d); |
23 container->RegisterCallback ("source-d", &d); |
24 } |
24 } |
25 void |
25 void |
26 generateTraceEvents (void) |
26 GenerateTraceEvents (void) |
27 { |
27 { |
28 // log en empty packet |
28 // log en empty packet |
29 a (Packet ()); |
29 a (Packet ()); |
30 b = 10; |
30 b = 10; |
31 b += 100; |
31 b += 100; |
34 c << "this is a simple test b=" << b << std::endl; |
34 c << "this is a simple test b=" << b << std::endl; |
35 d (3.1415, 3); |
35 d (3.1415, 3); |
36 } |
36 } |
37 |
37 |
38 void |
38 void |
39 variableEvent (uint64_t old, uint64_t cur) |
39 VariableEvent (uint64_t old, uint64_t cur) |
40 {} |
40 {} |
41 |
41 |
42 void |
42 void |
43 callbackEvent (double a, int b) |
43 CallbackEvent (double a, int b) |
44 {} |
44 {} |
45 |
45 |
46 |
46 |
47 int main (int argc, char *argv[]) |
47 int main (int argc, char *argv[]) |
48 { |
48 { |
49 TraceContainer traces; |
49 TraceContainer traces; |
50 registerAllTraceSources (&traces); |
50 RegisterAllTraceSources (&traces); |
51 PcapWriter pcap; |
51 PcapWriter pcap; |
52 pcap.open ("trace-test.log"); |
52 pcap.Open ("trace-test.log"); |
53 pcap.writeHeaderEthernet (); |
53 pcap.WriteHeaderEthernet (); |
54 traces.setCallback ("source-a", |
54 traces.SetCallback ("source-a", |
55 makeCallback (&PcapWriter::writePacket, &pcap)); |
55 MakeCallback (&PcapWriter::WritePacket, &pcap)); |
56 traces.setUiVariableCallback ("source-b", makeCallback (&variableEvent)); |
56 traces.SetUiVariableCallback ("source-b", MakeCallback (&VariableEvent)); |
57 traces.setStream ("source-c", &std::cout); |
57 traces.SetStream ("source-c", &std::cout); |
58 traces.setCallback ("source-d", makeCallback (&callbackEvent)); |
58 traces.SetCallback ("source-d", MakeCallback (&CallbackEvent)); |
59 generateTraceEvents (); |
59 GenerateTraceEvents (); |
60 return 0; |
60 return 0; |
61 } |
61 } |