JunkBox_Win_Lib 1.5.3
Loading...
Searching...
No Matches
CLogWndDoc Class Reference

#include <LogWndDoc.h>

Inheritance diagram for CLogWndDoc:
Collaboration diagram for CLogWndDoc:

Public Member Functions

virtual BOOL OnNewDocument ()
 
virtual void Serialize (CArchive &ar)
 
virtual void lprintBuffer (Buffer buf, int input=LOG_RB_MESG)
 
virtual void lprintString (char *str, int input=LOG_RB_MESG)
 
virtual void lprintFormat (char *fmt,...)
 
virtual void lfprintFormat (int input, char *fmt,...)
 
virtual void printBuffer (Buffer buf, int input=LOG_RB_MESG)
 
virtual void printString (char *str, int input=LOG_RB_MESG)
 
virtual void printFormat (char *fmt,...)
 
virtual void fprintFormat (int input, char *fmt,...)
 
virtual void lock (void)
 
virtual void unlock (void)
 
virtual ~CLogWndDoc ()
 
virtual void AssertValid () const
 
virtual void Dump (CDumpContext &dc) const
 
void free (void)
 
void clear (void)
 
int writeLogFile (void)
 
CString easyGetSaveFileName (LPCTSTR title, HWND hWnd)
 
void DeleteContents (void)
 
CLogWndView * GetView (void)
 

Public Attributes

CLogWndFrame * pFrame
 
CLogWndView * pView
 
CString Title
 
BOOL binHexMode
 
CString save_fname
 
CLogRingBuffer * ringBuffer
 
CCriticalSection criticalKey
 

Protected Member Functions

 CLogWndDoc ()
 
 CLogWndDoc (int bufsz, BOOL binhex=TRUE)
 

Detailed Description

Definition at line 24 of file LogWndDoc.h.

Constructor & Destructor Documentation

◆ CLogWndDoc() [1/2]

CLogWndDoc ( )
protected

Definition at line 29 of file LogWndDoc.cpp.

30{
31 //DEBUG_INFO("CONSTRUCTOR: CLogWndDoc\n");
32
33 pFrame = NULL;
34 pView = NULL;
35 Title = _T("");
36 save_fname = _T("");
37 binHexMode = TRUE;
38// m_locked = FALSE;
39
40 ringBuffer = new CLogRingBuffer(MAXLOGBUFFERLINE);
41}
#define MAXLOGBUFFERLINE
Definition LogWndDoc.h:11
CLogRingBuffer * ringBuffer
Definition LogWndDoc.h:72
CLogWndView * pView
Definition LogWndDoc.h:37
CLogWndFrame * pFrame
Definition LogWndDoc.h:36
CString save_fname
Definition LogWndDoc.h:71

References MAXLOGBUFFERLINE.

◆ CLogWndDoc() [2/2]

CLogWndDoc ( int bufsz,
BOOL binhex = TRUE )
protected

Definition at line 44 of file LogWndDoc.cpp.

45{
46 //DEBUG_INFO("CONSTRUCTOR: CLogWndDoc 2\n");
47
48 pFrame = NULL;
49 pView = NULL;
50 Title = _T("");
51 save_fname = _T("");
52 binHexMode = binhex;
53
54 if (bufsz<=0) bufsz = MAXLOGBUFFERLINE;
55 ringBuffer = new CLogRingBuffer(bufsz);
56}

References CLogWndDoc::binHexMode, MAXLOGBUFFERLINE, CLogWndDoc::pFrame, CLogWndDoc::pView, CLogWndDoc::ringBuffer, CLogWndDoc::save_fname, and CLogWndDoc::Title.

◆ ~CLogWndDoc()

~CLogWndDoc ( )
virtual

Definition at line 59 of file LogWndDoc.cpp.

60{
61 DEBUG_INFO("DESTRUCTOR: CLogWndDoc: START\n");
62
63 while(m_locked) ::Sleep(10);
64 if (pView!=NULL) pView->unlock();
65
67
68 DEBUG_INFO("DESTRUCTOR: CLogWndDoc: END\n");
69}
void free(void)
Definition LogWndDoc.cpp:72
void unlock(void)
Definition LogWndView.h:36

References CLogWndDoc::free(), CLogWndDoc::pView, and CLogWndView::unlock().

Here is the call graph for this function:

Member Function Documentation

◆ AssertValid()

void AssertValid ( ) const
virtual

Definition at line 111 of file LogWndDoc.cpp.

112{
113 CDocument::AssertValid();
114}

◆ clear()

void clear ( void )

Definition at line 148 of file LogWndDoc.cpp.

149{
150 save_fname = _T("");
151
152 CSingleLock lock(&criticalKey);
153 lock.Lock();
154 while (!lock.IsLocked()) {
155 Sleep(100);
156 lock.Lock();
157 }
158
159 ringBuffer->clear();
160 lock.Unlock();
161
162 return;
163}
CCriticalSection criticalKey
Definition LogWndDoc.h:73
virtual void lock(void)
Definition LogWndDoc.h:56

References CLogWndDoc::criticalKey, CLogWndDoc::lock(), CLogWndDoc::ringBuffer, and CLogWndDoc::save_fname.

Referenced by CLogWndView::clearViewDoc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteContents()

void DeleteContents ( void )

Definition at line 128 of file LogWndDoc.cpp.

129{
130 //CLogWndDoc::clear();
131 //DEBUG_WARN("CLogWndDoc::DeleteContents: IN\n");
132 CDocument::DeleteContents();
133}

◆ Dump()

void Dump ( CDumpContext & dc) const
virtual

Definition at line 117 of file LogWndDoc.cpp.

118{
119 CDocument::Dump(dc);
120}

◆ easyGetSaveFileName()

CString easyGetSaveFileName ( LPCTSTR title,
HWND hWnd )

Definition at line 203 of file LogWndDoc.cpp.

204{
205 OPENFILENAME ofn;
206 TCHAR fn[LNAME];
207 CString str = _T("");
208
209 memset(fn, 0, LNAME);
210 memset(&ofn, 0, sizeof(OPENFILENAME));
211
212 ofn.lStructSize = sizeof(OPENFILENAME);
213 ofn.hwndOwner = hWnd;
214 ofn.Flags = 0;
215 ofn.lpstrFile = fn;
216 //ofn.nMaxFile = LNAME;
217 ofn.nMaxFile = sizeof(fn) / sizeof(fn[0]);
218 ofn.lpstrTitle = title;
219
220 BOOL ret = GetSaveFileName(&ofn);
221 if (ret) str = fn;
222
223 return str;
224}

Referenced by CLogWndFrame::OnLogSave().

Here is the caller graph for this function:

◆ fprintFormat()

void fprintFormat ( int input,
char * fmt,
... )
virtual

Definition at line 359 of file LogWndDoc.cpp.

360{
361 if (ringBuffer==NULL || pView==NULL || fmt==NULL) return;
362
363 va_list args;
364 va_start(args, fmt);
365 ringBuffer->putRingFormat(input, fmt, args);
366 va_end(args);
367
368 InvalidateRect(pView->m_hWnd, NULL, FALSE);
369
370 return;
371}

References CLogWndDoc::pView, and CLogWndDoc::ringBuffer.

◆ free()

void free ( void )

Definition at line 72 of file LogWndDoc.cpp.

73{
74 if (ringBuffer!=NULL) {
75 delete(ringBuffer);
76 ringBuffer = NULL;
77 }
78}

References CLogWndDoc::ringBuffer.

Referenced by CLogWndDoc::~CLogWndDoc().

Here is the caller graph for this function:

◆ GetView()

CLogWndView * GetView ( void )

Definition at line 136 of file LogWndDoc.cpp.

137{
138 //DEBUG_INFO("CLogWndDoc::GetView():\n");
139 POSITION pos = GetFirstViewPosition();
140 while (pos!=NULL) {
141 CLogWndView* pview = (CLogWndView*)GetNextView(pos);
142 if (this==pview->GetDocument()) return pview;
143 }
144 return NULL;
145}
CLogWndDoc * GetDocument() const

References CLogWndView::GetDocument().

Referenced by jbxwl::ExecLogWnd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lfprintFormat()

void lfprintFormat ( int input,
char * fmt,
... )
virtual

Definition at line 272 of file LogWndDoc.cpp.

273{
274 if (ringBuffer==NULL || pView==NULL || fmt==NULL) return;
275
276 int no = 0, trymax = 100;
277
278 CSingleLock lock(&criticalKey);
279 lock.Lock();
280 while (!lock.IsLocked() && no<trymax) {
281 Sleep(100);
282 lock.Lock();
283 no++;
284 }
285
286 va_list args;
287 va_start(args, fmt);
288 ringBuffer->putRingFormat(input, fmt, args);
289 va_end(args);
290
291 lock.Unlock();
292
293 InvalidateRect(pView->m_hWnd, NULL, FALSE);
294
295 return;
296}

References CLogWndDoc::criticalKey, CLogWndDoc::lock(), CLogWndDoc::pView, and CLogWndDoc::ringBuffer.

Here is the call graph for this function:

◆ lock()

virtual void lock ( void )
inlinevirtual

Definition at line 56 of file LogWndDoc.h.

56{ m_locked = TRUE; if (pView!=NULL) pView->lock();}
void lock(void)
Definition LogWndView.h:35

References CLogWndView::lock(), and CLogWndDoc::pView.

Referenced by CLogWndDoc::clear(), CLogWndDoc::lfprintFormat(), CLogWndDoc::lprintBuffer(), CLogWndDoc::lprintFormat(), and CLogWndDoc::writeLogFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lprintBuffer()

void lprintBuffer ( Buffer buf,
int input = LOG_RB_MESG )
virtual

Definition at line 232 of file LogWndDoc.cpp.

233{
234 if (ringBuffer==NULL || pView==NULL || buf.buf==NULL) return;
235
236 int no = 0, trymax = 100;
237
238 CSingleLock lock(&criticalKey);
239 lock.Lock();
240 while (!lock.IsLocked() && no<trymax) {
241 Sleep(100);
242 lock.Lock();
243 no++;
244 }
245
246 ringBuffer->putRingBuffer(buf, input);
247
248 int lastPos = ringBuffer->getLastPosition();
249 if (binHexMode && ringBuffer->getKindData(lastPos-1)==LOG_RB_BINARY_DATA) {
250 ringBuffer->rewriteBinHexRingBuffer(lastPos-1, input);
251 }
252 lock.Unlock();
253
254 InvalidateRect(pView->m_hWnd, NULL, FALSE);
255
256 return;
257}

References CLogWndDoc::binHexMode, CLogWndDoc::criticalKey, CLogWndDoc::lock(), CLogWndDoc::pView, and CLogWndDoc::ringBuffer.

Here is the call graph for this function:

◆ lprintFormat()

void lprintFormat ( char * fmt,
... )
virtual

Definition at line 299 of file LogWndDoc.cpp.

300{
301 if (ringBuffer==NULL || pView==NULL || fmt==NULL) return;
302
303 int no = 0, trymax = 100;
304
305 CSingleLock lock(&criticalKey);
306 lock.Lock();
307 while (!lock.IsLocked() && no<trymax) {
308 Sleep(100);
309 lock.Lock();
310 no++;
311 }
312
313 va_list args;
314 va_start(args, fmt);
315 ringBuffer->putRingFormat(LOG_RB_MESG, fmt, args);
316 va_end(args);
317
318 lock.Unlock();
319
320 InvalidateRect(pView->m_hWnd, NULL, FALSE);
321
322 return;
323}

References CLogWndDoc::criticalKey, CLogWndDoc::lock(), CLogWndDoc::pView, and CLogWndDoc::ringBuffer.

Here is the call graph for this function:

◆ lprintString()

void lprintString ( char * str,
int input = LOG_RB_MESG )
virtual

Definition at line 260 of file LogWndDoc.cpp.

261{
262 if (ringBuffer==NULL || pView==NULL || msg==NULL) return;
263
264 Buffer buf = make_Buffer_bystr(msg);
265 printBuffer(buf, input);
266 free_Buffer(&buf);
267
268 return;
269}
virtual void printBuffer(Buffer buf, int input=LOG_RB_MESG)

References CLogWndDoc::printBuffer(), CLogWndDoc::pView, and CLogWndDoc::ringBuffer.

Here is the call graph for this function:

◆ OnNewDocument()

BOOL OnNewDocument ( )
virtual

Definition at line 81 of file LogWndDoc.cpp.

82{
83 //DEBUG_INFO("CLogWndDoc::OnNewDocument():\n");
84 if (!CDocument::OnNewDocument()) return FALSE;
85 return TRUE;
86}

◆ printBuffer()

void printBuffer ( Buffer buf,
int input = LOG_RB_MESG )
virtual

Definition at line 330 of file LogWndDoc.cpp.

331{
332 if (ringBuffer==NULL || pView==NULL || buf.buf==NULL) return;
333
334 ringBuffer->putRingBuffer(buf, input);
335
336 int lastPos = ringBuffer->getLastPosition();
337 if (binHexMode && ringBuffer->getKindData(lastPos-1)==LOG_RB_BINARY_DATA) {
338 ringBuffer->rewriteBinHexRingBuffer(lastPos-1, input);
339 }
340
341 InvalidateRect(pView->m_hWnd, NULL, FALSE);
342
343 return;
344}

References CLogWndDoc::binHexMode, CLogWndDoc::pView, and CLogWndDoc::ringBuffer.

Referenced by CLogWndDoc::lprintString(), and CLogWndDoc::printString().

Here is the caller graph for this function:

◆ printFormat()

void printFormat ( char * fmt,
... )
virtual

Definition at line 374 of file LogWndDoc.cpp.

375{
376 if (ringBuffer==NULL || pView==NULL || fmt==NULL) return;
377
378 va_list args;
379 va_start(args, fmt);
380 ringBuffer->putRingFormat(LOG_RB_MESG, fmt, args);
381 va_end(args);
382
383 InvalidateRect(pView->m_hWnd, NULL, FALSE);
384
385 return;
386}

References CLogWndDoc::pView, and CLogWndDoc::ringBuffer.

◆ printString()

void printString ( char * str,
int input = LOG_RB_MESG )
virtual

Definition at line 347 of file LogWndDoc.cpp.

348{
349 if (ringBuffer==NULL || pView==NULL || msg==NULL) return;
350
351 Buffer buf = make_Buffer_bystr(msg);
352 printBuffer(buf, input);
353 free_Buffer(&buf);
354
355 return;
356}

References CLogWndDoc::printBuffer(), CLogWndDoc::pView, and CLogWndDoc::ringBuffer.

Here is the call graph for this function:

◆ Serialize()

void Serialize ( CArchive & ar)
virtual

Definition at line 93 of file LogWndDoc.cpp.

94{
95 if (ar.IsStoring())
96 {
97 // TODO: 格納するコードをここに追加してください.
98 }
99 else
100 {
101 // TODO: 読み込むコードをここに追加してください.
102 }
103}

◆ unlock()

virtual void unlock ( void )
inlinevirtual

Definition at line 57 of file LogWndDoc.h.

57{ m_locked = FALSE; if (pView!=NULL) pView->unlock();}

References CLogWndDoc::pView, and CLogWndView::unlock().

Here is the call graph for this function:

◆ writeLogFile()

int writeLogFile ( void )

Definition at line 169 of file LogWndDoc.cpp.

170{
171 if (save_fname==_T("")) return -1;
172
173 CSingleLock lock(&criticalKey);
174 lock.Lock();
175 while (!lock.IsLocked()) {
176 Sleep(100);
177 lock.Lock();
178 }
179
180 int size = 0;
181 FILE* fp = tfopen(save_fname, _T("wb"));
182 if (fp==NULL) {
183 lock.Unlock();
184 return -2;
185 }
186
187 for (int pos=0; pos<ringBuffer->getMaxLineY(); pos++) {
188 Buffer buf = dup_Buffer(ringBuffer->pBuf[pos]);
189 if (ringBuffer->getKindData(pos)!=LOG_RB_BINARY_DATA) {
190 if (buf.buf[buf.vldsz-1]!='\n') cat_s2Buffer("\n", &buf);
191 }
192 fwrite((const char*)buf.buf, strlen((const char*)buf.buf), 1, fp); // buf may be binary
193 size += (int)strlen((const char*)buf.buf);
194 free_Buffer(&buf);
195 }
196 fclose(fp);
197 lock.Unlock();
198
199 return size;
200}

References CLogWndDoc::criticalKey, CLogWndDoc::lock(), CLogWndDoc::ringBuffer, and CLogWndDoc::save_fname.

Referenced by CLogWndFrame::OnLogSave().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ binHexMode

BOOL binHexMode

◆ criticalKey

◆ pFrame

CLogWndFrame* pFrame

Definition at line 36 of file LogWndDoc.h.

Referenced by CLogWndDoc::CLogWndDoc(), and jbxwl::ExecLogWnd().

◆ pView

◆ ringBuffer

◆ save_fname

CString save_fname

◆ Title

CString Title

Definition at line 39 of file LogWndDoc.h.

Referenced by CLogWndDoc::CLogWndDoc().


The documentation for this class was generated from the following files: