Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

mytrace.cpp

Go to the documentation of this file.
00001 // $Id$
00002 
00003 //**********************************************************************
00004 //                                                                     *
00005 //    Description:   Class providing simple trace facility that sends  *
00006 //                   passed text to a stream on construction and       *
00007 //                   destruction.                                      *
00008 //                                                                     *
00009 //    Author:        Chris White (whitecf@bcs.org.uk)                  *
00010 //                                                                     *
00011 //    Copyright (C) 2002  Monitor Computing Services Ltd.              *
00012 //                                                                     *
00013 //    This program is free software; you can redistribute it and/or    *
00014 //    modify it under the terms of the GNU General Public License      *
00015 //    as published by the Free Software Foundation; either version 2   *
00016 //    of the License, or any later version.                            *
00017 //                                                                     *
00018 //    This program is distributed in the hope that it will be useful,  *
00019 //    but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00020 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00021 //    GNU General Public License for more details.                     *
00022 //                                                                     *
00023 //    You should have received a copy of the GNU General Public        *
00024 //    License (http://www.gnu.org/copyleft/gpl.html) along with this   *
00025 //    program; if not, write to:                                       *
00026 //       The Free Software Foundation Inc.,                            *
00027 //       59 Temple Place - Suite 330,                                  *
00028 //       Boston, MA  02111-1307,                                       *
00029 //       USA.                                                          *
00030 //                                                                     *
00031 //**********************************************************************
00032 //                                                                     *
00033 //    Notes:                                                           *
00034 //                                                                     *
00035 //**********************************************************************
00036 
00037 #include <fstream.h>
00038 #include <iostream.h>
00039 
00040 #include "mytrace.h"
00041 
00042 
00043 using namespace Monitor::Utility;
00044 
00045 
00046 
00047 ostream    *MyTrace::traceStream = &cerr;
00048 
00049 
00050 
00051 MyTrace::MyTrace(const string&    newTraceMessage) :
00052     traceMessage(newTraceMessage)
00053 {
00054 #ifdef _DOENTRYTRACE_
00055 #ifdef _DOEXITTRACE_
00056     *traceStream << "Scoped: " << traceMessage << endl;
00057 #else
00058     *traceStream << traceMessage << endl;
00059 #endif
00060     traceStream->flush();
00061 #endif
00062 }
00063 
00064 
00065 
00066 MyTrace::~MyTrace()
00067 {
00068 #ifdef _DOEXITTRACE_
00069     *traceStream << "Descoped: " << traceMessage << endl;
00070     traceStream->flush();
00071 #endif
00072 }
00073 
00074 
00075 
00076 #ifdef _DOENTRYTRACE_
00077 void
00078 MyTrace::setTraceStream(const char    *newStreamName)
00079 {
00080     traceStream = new fstream(newStreamName, ios::out);
00081 #else
00082 void
00083 MyTrace::setTraceStream(const char*)
00084 {
00085 #endif
00086 }
00087 
00088 
00089 
00090 ostream&
00091 MyTrace::getTraceStream()
00092 {
00093     return *traceStream;
00094 }
00095 

Generated on Wed Oct 29 20:51:59 2003 for Utility BC Common by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002