C++ TargetRTS
Loading...
Searching...
No Matches
RTTracer.h
1/*******************************************************************************
2 * Licensed Materials - Property of HCL
3 * (c) Copyright HCL Technologies Ltd. 2025. All Rights Reserved.
4 *******************************************************************************/
5#ifndef __RTTracer_h__
6#define __RTTracer_h__ included
7
8#include <fstream>
9#include <string>
10#include <RTJsonResult.h>
11#include <RTStreamBuffer.h>
12#if RTUseCPP11
13#include <chrono>
14#endif
15
16class RTMessage;
17
18class RTTracer: public RTStreamBuffer {
19public:
23 static RTS_INLINE void flushTrace(void);
24
28 static RTS_INLINE bool isEnabled(void);
29
34 static void setEnabled(bool);
35
39 static bool configure(void);
40
41protected:
42 enum {
43 TIME1 = 0x10, // 0001 0000
44 TIME2 = 0x20, // 0010 0000
45 TIME3 = 0x40, // 0100 0000
46 TIME_ABSOLUTE = 0x80, // 1000 0000
47 PRECISION_MASK = 0x0F, // 0000 1111
48 PRECISION_NANO = 0x09, // 0000 1001
49 PRECISION_MICRO = 0x06, // 0000 0110
50 PRECISION_MILLI = 0x03 // 0000 0011
51 };
52 static bool _enabled;
53 static RTJsonResult jsonConfig;
54#if RTUseCPP11
55 static std::chrono::system_clock::time_point _start;
56 static int _timestamps;
57#endif
58
59 std::string _traceFile;
60 std::ofstream _file;
61
62 RTTracer(void);
63 ~RTTracer(void);
64
65 static std::string initTraceFile(void);
66
67 static RTS_INLINE void traceMS(const RTMessage*, void* traceInfo[] = nullptr);
68
69 void traceMessage(const RTMessage*, void* traceInfo[]);
70 int flush(void) override;
71
72 friend class RTActor;
73 friend class RTMessage;
74};
75
76#define TRACE_TIME1 "time1_send"
77#define TRACE_TIME2 "time2_receive"
78#define TRACE_TIME3 "time3_handle"
79
80#if RTS_INLINES
81#include <RTTracer.inl>
82#endif
83
84#endif
An instance of this class represents a capsule instance.
Definition: RTActor.h:44
Represents the result of parsing a JSON string.
Definition: RTJsonResult.h:30
Represents a message used for communication between capsule instances.
Definition: RTMessage.h:33
Definition: RTStreamBuffer.h:22
Definition: RTTracer.h:18
static void flushTrace(void)
Flush buffered trace messages to file.
Definition: RTTracer.inl:12
static bool isEnabled(void)
Check if tracing is enabled.
Definition: RTTracer.inl:16
static bool configure(void)
Configure RTTracer and tracing preferences.
static void setEnabled(bool)
Enable or disable tracing to file.
int flush(void) override
Flushes the data written to the buffer.