source: trunk/Include/Classes/System/Diagnostics/base.ab@ 353

Last change on this file since 353 was 246, checked in by dai, 18 years ago

Objectクラス、Stringクラスの定義をSystem名前空間に入れると共に、コンパイラ側で両者のクラスをSystem名前空間に依存しない特殊型として扱うようにした。
System.Diagnostics名前空間を導入した。
Namespaceステートメントのコード補間機能に対応。

File size: 6.0 KB
Line 
1Namespace System
2 Namespace Diagnostics
3
4 Class _System_TraceBase
5 indentLevel As Long
6 indentSize As Long
7
8
9 ' リスナ管理
10 listeners As TraceListenerCollection
11
12 Public
13
14 ' コンストラクタ
15 Sub _System_TraceBase()
16 listeners = New TraceListenerCollection
17 listeners.Add( New DefaultTraceListener() )
18
19 indentLevel = 0
20 indentSize = 4
21 End Sub
22
23 '----------------------------------------------------------------
24 ' パブリック メソッド
25 '----------------------------------------------------------------
26
27 ' アサート(コールスタックを表示)
28 Sub Assert( condition As Boolean )
29 If condition = False then
30 'TODO: コールスタックを表示
31 End If
32 End Sub
33
34 ' アサート(メッセージ文字列を表示)
35 Sub Assert( condition As Boolean, message As String )
36 If condition = False then
37 ' TODO: メッセージボックス形式での表示に対応
38 WriteLine( message )
39 End If
40 End Sub
41
42 ' アサート(メッセージ文字列と詳細文字列を表示)
43 Sub Assert( condition As Boolean, message As String, detailMessage As String )
44 If condition = False then
45 ' TODO: メッセージボックス形式での表示に対応
46 WriteLine( message )
47 End If
48 End Sub
49
50
51 ' インデントレベルを上げる
52 Sub Indent()
53 IndentLevel = indentLevel + 1
54 End Sub
55
56 ' インデントレベルを下げる
57 Sub Unindent()
58 If indentLevel <= 0 Then
59 indentLevel = 0
60 Return
61 End If
62 IndentLevel = indentLevel - 1
63 End Sub
64
65 ' 文字列を出力
66 Sub Write( value As Object )
67 Dim i As Long
68 For i = 0 To ELM( listeners.Count )
69 Dim listener = listeners[i]
70 listener.Write( value )
71 Next
72 End Sub
73 Sub Write( message As String )
74 Dim i As Long
75 For i = 0 To ELM( listeners.Count )
76 Dim listener = listeners[i]
77 listener.Write( message )
78 Next
79 End Sub
80 Sub Write( value As Object, category As String )
81 Dim i As Long
82 For i = 0 To ELM( listeners.Count )
83 Dim listener = listeners[i]
84 listener.Write( value, category )
85 Next
86 End Sub
87 Sub Write( message As String, category As String )
88 Dim i As Long
89 For i = 0 To ELM( listeners.Count )
90 Dim listener = listeners[i]
91 listener.Write( message, category )
92 Next
93 End Sub
94
95 ' 一行の文字列を出力
96 Sub WriteLine( value As Object )
97 Dim i As Long
98 For i = 0 To ELM( listeners.Count )
99 Dim listener = listeners[i]
100 listener.WriteLine( value )
101 Next
102 End Sub
103 Sub WriteLine( message As String )
104 Dim i As Long
105 For i = 0 To ELM( listeners.Count )
106 Dim listener = listeners[i]
107 listener.WriteLine( message )
108 Next
109 End Sub
110 Sub WriteLine( value As Object, category As String )
111 Dim i As Long
112 For i = 0 To ELM( listeners.Count )
113 Dim listener = listeners[i]
114 listener.WriteLine( value, category )
115 Next
116 End Sub
117 Sub WriteLine( message As String, category As String )
118 Dim i As Long
119 For i = 0 To ELM( listeners.Count )
120 Dim listener = listeners[i]
121 listener.WriteLine( message, category )
122 Next
123 End Sub
124
125 ' 条件をもとに文字列を出力
126 Sub WriteIf( condition As Boolean, value As Object )
127 Dim i As Long
128 For i = 0 To ELM( listeners.Count )
129 Dim listener = listeners[i]
130 listener.WriteIf( condition, value )
131 Next
132 End Sub
133 Sub WriteIf( condition As Boolean, message As String )
134 Dim i As Long
135 For i = 0 To ELM( listeners.Count )
136 Dim listener = listeners[i]
137 listener.WriteIf( condition, message )
138 Next
139 End Sub
140 Sub WriteIf( condition As Boolean, value As Object, category As String )
141 Dim i As Long
142 For i = 0 To ELM( listeners.Count )
143 Dim listener = listeners[i]
144 listener.WriteIf( condition, value, category )
145 Next
146 End Sub
147 Sub WriteIf( condition As Boolean, message As String, category As String )
148 Dim i As Long
149 For i = 0 To ELM( listeners.Count )
150 Dim listener = listeners[i]
151 listener.WriteIf( condition, message, category )
152 Next
153 End Sub
154
155 ' 条件をもとに一行の文字列を出力
156 Sub WriteLineIf( condition As Boolean, value As Object )
157 Dim i As Long
158 For i = 0 To ELM( listeners.Count )
159 Dim listener = listeners[i]
160 listener.WriteLineIf( condition, value )
161 Next
162 End Sub
163 Sub WriteLineIf( condition As Boolean, message As String )
164 Dim i As Long
165 For i = 0 To ELM( listeners.Count )
166 Dim listener = listeners[i]
167 listener.WriteLineIf( condition, message )
168 Next
169 End Sub
170 Sub WriteLineIf( condition As Boolean, value As Object, category As String )
171 Dim i As Long
172 For i = 0 To ELM( listeners.Count )
173 Dim listener = listeners[i]
174 listener.WriteLineIf( condition, value, category )
175 Next
176 End Sub
177 Sub WriteLineIf( condition As Boolean, message As String, category As String )
178 Dim i As Long
179 For i = 0 To ELM( listeners.Count )
180 Dim listener = listeners[i]
181 listener.WriteLineIf( condition, message, category )
182 Next
183 End Sub
184
185
186 '----------------------------------------------------------------
187 ' パブリック プロパティ
188 '----------------------------------------------------------------
189
190 ' IndentLevelプロパティ
191 Function IndentLevel() As Long
192 Return indentLevel
193 End Function
194 Sub IndentLevel( indentLevel As Long )
195 This.indentLevel = indentLevel
196
197 Dim i As Long
198 For i = 0 To ELM( listeners.Count )
199 Dim listener = listeners[i]
200 listener.IndentLevel = indentLevel
201 Next
202 End Sub
203
204 ' IndentSizeプロパティ
205 Function IndentSize() As Long
206 Return indentSize
207 End Function
208 Sub IndentSize( size As Long )
209 indentSize = size
210
211 Dim i As Long
212 For i = 0 To ELM( listeners.Count )
213 Dim listener = listeners[i]
214 listener.IndentSize = indentSize
215 Next
216 End Sub
217
218 ' Listenersプロパティ
219 Function Listeners() As TraceListenerCollection
220 Return listeners
221 End Function
222
223 End Class
224
225 End Namespace
226End Namespace
Note: See TracBrowser for help on using the repository browser.