C++ TargetRTS
Loading...
Searching...
No Matches
RTLog.h
1/*
2 * Licensed Materials - Property of HCL and/or IBM
3 * Copyright HCL Technologies Ltd. 2016, 2021. All Rights Reserved.
4 * Copyright IBM Corporation 1999, 2016. All Rights Reserved.
5 *
6 * U.S. Government Users Restricted Rights - Use, duplication or
7 * disclosure restricted by GSA ADP Schedule.
8 */
9
10#ifndef __RTLog_h__
11#define __RTLog_h__ included
12
13#ifdef PRAGMA
14#pragma interface
15#endif
16
17#ifndef __RTProtocol_h__
18#include <RTProtocol.h>
19#endif
20
21#include <iosfwd>
22
23class RTDataObject;
24class RTMutex;
25struct RTObject_class;
26class RTString;
27struct RTTypedValue;
28class RTLogStream;
29
31struct Log
32{
33#if RTS_LOGSTREAM
34 typedef ::RTLogStream Stream;
35#endif
37 class Base : public RTProtocol
38 {
39 private:
40 // this will eventually be a file descriptor.
41 int file;
42
43 public:
44 Base( void );
45 Base(std::ostream& stream);
46 RTS_INLINE ~Base( void );
47
48 static const RTProtocolDescriptor rt_class;
49
51 RTS_INLINE void cr( void );
52
53 void crtab( int = 1 );
54
55 // The below functions need not be called
56 void open( const char * );
57 void open( void );
58 void close( void );
59
63 void log( const char * str);
64
68 void log( const RTString & str);
69
73 void show( const char * str);
74
78 void show( const RTString & str);
79
80#if OBJECT_ENCODE
81 void log( char );
82 void log( wchar_t );
83#if RTUseFloatingPoint
84 void log( double );
85 void log( float );
86 void log( long double );
87#endif
88 void log( int );
89 void log( long );
90 void log( long long );
91 void log( short );
92 void log( const RTDataObject & );
93
98 void log( const void * data, const RTObject_class * type);
99
104 RTS_INLINE void log( const RTTypedValue & );
105
106 void log( unsigned int );
107 void log( unsigned long );
108 void log( unsigned long long );
109 void log( unsigned short );
110 void log( unsigned char );
111
112 void show( char );
113 void show( wchar_t );
114#if RTUseFloatingPoint
115 void show( double );
116 void show( float );
117 void show( long double );
118#endif
119 void show( int );
120 void show( long );
121 void show( long long );
122 void show( short );
123 void show( const RTDataObject & );
124
129 void show( const void * data, const RTObject_class * type);
130
135 RTS_INLINE void show( const RTTypedValue & );
136
137 void show( unsigned int );
138 void show( unsigned long );
139 void show( unsigned long long );
140 void show( unsigned short );
141 void show( unsigned char );
142#endif
143 void space( void );
144 void tab( void );
145 void clear( void );
146
151 void commit( void );
152
156 Base& operator<<( const RTDataObject & obj );
157
162 Base& operator<<( const RTTypedValue & info );
163
167 Base& operator<<( std::ostream& (*manip)(std::ostream&) );
168
172 template <typename T>
173 Base& operator<<( const T& value )
174 {
175 outputStream << value;
176 return *this;
177 }
178
179
180 private:
181 // unavailable methods
182 Base( const Base & );
183 Base & operator=( const Base & );
184 bool valueParsingUtil( const void * value, const RTObject_class * type );
185 std::ostream& outputStream;
186 };
187
188 static Base out;
189 static Base err;
190
194 static std::ostream& endl( std::ostream& os );
195
199 static std::ostream& lock( std::ostream& os );
200
204 static std::ostream& unlock( std::ostream& os );
205
206};
207
208#if RTS_INLINES
209#include <RTLog.inl>
210#endif
211
212#endif // __RTLog_h__
Represents a log port.
Definition: RTLog.h:38
Base & operator<<(const RTTypedValue &info)
Print an object to the log.
Base & operator<<(std::ostream &(*manip)(std::ostream &))
Used to call endl.
void log(const void *data, const RTObject_class *type)
Print the default ASCII encoding of an object to the log, followed by a carriage return.
void log(const char *str)
Print a string to the log, followed by a carriage return.
void commit(void)
Flush all buffered characters to the log.
void cr(void)
Print a carriage return to the log.
Definition: RTLog.inl:29
void show(const RTString &str)
Print a string to the log.
void log(const RTString &str)
Print a string to the log, followed by a carriage return.
Base & operator<<(const RTDataObject &obj)
Print an object to the log.
void show(const void *data, const RTObject_class *type)
Print the default ASCII encoding of an object to the log.
void show(const char *str)
Print a string to the log.
Base & operator<<(const T &value)
Template function to print the value of variable to the log.
Definition: RTLog.h:173
Provides a common interface to certain data type implementations (e.g.
Definition: RTDataObject.h:33
Represents a general capsule port typed by a protocol which determines the set of events that can be ...
Definition: RTProtocol.h:50
A C-style string wrapped in a data object.
Definition: RTString.h:24
Represents the predefined "Log" protocol.
Definition: RTLog.h:32
static std::ostream & lock(std::ostream &os)
Lock the Log::out or Log::err log statement.
static std::ostream & endl(std::ostream &os)
Insert the new line and flush the buffer.
static std::ostream & unlock(std::ostream &os)
Unlock the Log::out or Log::err log statement.
A type descriptor providing information about a type.
Definition: RTObject_class.h:64
Definition: RTProtocolDescriptor.h:40
Encapsulates a data object and its type descriptor.
Definition: RTTypedValue.h:29