00001 #ifndef __MYTRACE_INCLUDED__ 00002 #define __MYTRACE_INCLUDED__ 00003 00004 // $Id$ 00005 00006 //********************************************************************** 00007 // * 00008 // Description: Class providing simple trace facility that sends * 00009 // passed text to a stream on construction and * 00010 // destruction. * 00011 // * 00012 // Author: Chris White (whitecf@bcs.org.uk) * 00013 // * 00014 // Copyright (C) 2002 Monitor Computing Services Ltd. * 00015 // * 00016 // This program is free software; you can redistribute it and/or * 00017 // modify it under the terms of the GNU General Public License * 00018 // as published by the Free Software Foundation; either version 2 * 00019 // of the License, or any later version. * 00020 // * 00021 // This program is distributed in the hope that it will be useful, * 00022 // but WITHOUT ANY WARRANTY; without even the implied warranty of * 00023 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00024 // GNU General Public License for more details. * 00025 // * 00026 // You should have received a copy of the GNU General Public * 00027 // License (http://www.gnu.org/copyleft/gpl.html) along with this * 00028 // program; if not, write to: * 00029 // The Free Software Foundation Inc., * 00030 // 59 Temple Place - Suite 330, * 00031 // Boston, MA 02111-1307, * 00032 // USA. * 00033 // * 00034 //********************************************************************** 00035 // * 00036 // Notes: * 00037 // * 00038 //********************************************************************** 00039 00040 00041 #include <cstring.h> 00042 00043 00044 namespace Monitor { 00045 namespace Utility { 00046 00050 class MyTrace 00051 { 00052 public: 00062 MyTrace(const string& newTraceMessage); 00063 00070 virtual ~MyTrace(); 00071 00081 static void 00082 setTraceStream(const char* newStreamName); 00083 00089 static ostream& 00090 getTraceStream(); 00091 00092 private: 00096 string traceMessage; 00097 00101 static ostream* traceStream; 00102 }; 00103 00104 }; // namespace Utility 00105 }; // namespace Monitor 00106 00107 00108 #ifdef _DOEXITTRACE_ 00109 #define _DOENTRYTRACE_ 00110 #endif 00111 00112 #ifdef _DOENTRYTRACE_ 00113 #define _USEMYTRACE_(_trace_msg_) \ 00114 ::Monitor::Utility::MyTrace _myTrace_(_trace_msg_); 00115 #else 00116 #define _USEMYTRACE_(_trace_msg_) 00117 #endif 00118 00119 00120 #endif // __MYTRACE_INCLUDED__ 00121