C++ TargetRTS
All Classes Functions Variables Enumerations Enumerator Pages
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 <iostream>
22#include <sstream>
23
24class RTDataObject;
25class RTMutex;
26struct RTObject_class;
27class RTString;
28struct RTTypedValue;
29
31struct Log
32{
34 class Base : public RTProtocol
35 {
36 private:
37 // this will eventually be a file descriptor.
38 int file;
39
40 public:
41 RTS_INLINE Base( void );
42 RTS_INLINE Base(std::ostream& stream);
43 RTS_INLINE ~Base( void );
44
45 static const RTProtocolDescriptor rt_class;
46
48 RTS_INLINE void cr( void );
49
50 void crtab( int = 1 );
51
52 // The below functions need not be called
53 void open( const char * );
54 void open( void );
55 void close( void );
56
60 void log( const char * str);
61
65 void log( const RTString & str);
66
70 void show( const char * str);
71
75 void show( const RTString & str);
76
77#if OBJECT_ENCODE
78 void log( char );
79#if RTUseFloatingPoint
80 void log( double );
81 void log( float );
82 void log( long double );
83#endif
84 void log( int );
85 void log( long );
86 void log( long long );
87 void log( short );
88 void log( const RTDataObject & );
89
94 void log( const void * data, const RTObject_class * type);
95
100 RTS_INLINE void log( const RTTypedValue & );
101
102 void log( unsigned int );
103 void log( unsigned long );
104 void log( unsigned long long );
105 void log( unsigned short );
106 void log( unsigned char );
107
108 void show( char );
109#if RTUseFloatingPoint
110 void show( double );
111 void show( float );
112 void show( long double );
113#endif
114 void show( int );
115 void show( long );
116 void show( long long );
117 void show( short );
118 void show( const RTDataObject & );
119
124 void show( const void * data, const RTObject_class * type);
125
130 RTS_INLINE void show( const RTTypedValue & );
131
132 void show( unsigned int );
133 void show( unsigned long );
134 void show( unsigned long long );
135 void show( unsigned short );
136 void show( unsigned char );
137#endif
138 void space( void );
139 void tab( void );
140 void clear( void );
141
146 void commit( void );
147
151 Base& operator<<( const RTDataObject & obj );
152
157 Base& operator<<( const RTTypedValue & info );
158
162 Base& operator<<( std::ostream& (*manip)(std::ostream&) );
163
167 template <typename T>
168 Base& operator<<( const T& value )
169 {
170 outputStream << value;
171 return *this;
172 }
173
174
175 private:
176 // unavailable methods
177 Base( const Base & );
178 Base & operator=( const Base & );
179 bool valueParsingUtil( const void * value, const RTObject_class * type );
180 std::ostream& outputStream;
181 };
182
183 static Base out;
184 static Base err;
185
189 static std::ostream& endl( std::ostream& os );
190
194 static std::ostream& lock( std::ostream& os );
195
199 static std::ostream& unlock( std::ostream& os );
200
201};
202
203#if RTS_INLINES
204#include <RTLog.inl>
205#endif
206
207#endif // __RTLog_h__
Represents a log port.
Definition: RTLog.h:35
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:41
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:168
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