KWStyle - itkStdStreamLogOutput.cxx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkStdStreamLogOutput.cxx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:48 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 DEF =========================================================================*/
17
18 #include<iostream>
19 #include"itkStdStreamLogOutput.h"
20
21
22 namespace itk
23 {
24
25 /** Constructor */
26 StdStreamLogOutput::StdStreamLogOutput()
27 {
28   this->m_Stream = 0;
29 }
30
31 /** Destructor */
32 StdStreamLogOutput::~StdStreamLogOutput()
33 {
34   if( this->m_Stream )
35 IND **{
36     this->m_Stream->flush();
37 IND **}
38 }
39
40
41 /** Set file stream */
42 void StdStreamLogOutput::SetStream(StreamType &Stream)
43 {
44   this->m_Stream = &Stream;
45   this->m_Stream->precision(30);
46 }
47
48
49 /** flush a buffer */
50 void StdStreamLogOutput::Flush()
51 {
52   StdStreamLogOutput::m_Mutex.Lock();
53   if( this->m_Stream )
54 IND **{
55     this->m_Stream->flush();
56 IND **}
57   StdStreamLogOutput::m_Mutex.Unlock();
58 }
59
60
61 /** Write to a buffer */
62 void StdStreamLogOutput::Write(double timestamp)
63 {
64   StdStreamLogOutput::m_Mutex.Lock();
65   if( this->m_Stream )
66 IND **{
67     (*this->m_Stream) << timestamp;
68   }
69   StdStreamLogOutput::m_Mutex.Unlock();
70 }
71
72
73 /** Write to a buffer */
74 void StdStreamLogOutput::Write(std::string const &content)
75 {
76   StdStreamLogOutput::m_Mutex.Lock();
77   if( this->m_Stream )
78 IND **{
79     (*this->m_Stream) << content;
80   }
81   StdStreamLogOutput::m_Mutex.Unlock();
82 }
83
84
85 /** Write to a buffer */
86 void StdStreamLogOutput::Write(std::string const &content, double timestamp)
87 {
88   StdStreamLogOutput::m_Mutex.Lock();
89   if( this->m_Stream )
90 IND **{
91     (*this->m_Stream) << timestamp << "  :  " << content;
92 IND **}
93   StdStreamLogOutput::m_Mutex.Unlock();
94 }
95
96 void StdStreamLogOutput::PrintSelf(std::ostream &os, Indent indent) const
97 {
98   Superclass::PrintSelf(os,indent);
99 SEM   os << indent << "Stream: " << m_Stream << std::endl;;
100 }
101
102 }
103
104 EOF

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:48PM
© Kitware Inc.