00001 #ifndef CDB_DEBUG_STREAM_HH 00002 #define CDB_DEBUG_STREAM_HH 00003 00004 // File and Version Information: 00005 // $Id: CdbDebugStream.hh,v 1.4 2004/10/08 04:55:01 salnikov Exp $ 00006 00007 #include "CdbBase/CdbTimeUtils.hh" 00008 00009 #include <iostream> 00010 #include <fstream> 00011 00012 /// The "debug" streamer utility 00013 /** 00014 * This utility class provides an interface to a controllable "debug" stream to where 00015 * a test output of client code can be printed through. 00016 * 00017 * This facility provides essentially the same kind of service as "COUT1" when 00018 * the following environment variable is set up as follows: 00019 * 00020 * setenv BDBDEBUG1 std::cout 00021 * 00022 * Note, that in the current implementation of the class there is _no_ check 00023 * on the actual value of the above mentioned variable. A prsense of teh variable 00024 * would turn the stream on. 00025 */ 00026 class CdbDebugStream { 00027 00028 private: 00029 00030 /// Default constructor 00031 /** 00032 * Can only be used by the static fuctory method. 00033 * 00034 * @see CdbDebugStream::instance() 00035 */ 00036 CdbDebugStream( ); 00037 00038 /// The copy constructor (NOT IMPLEMENTED) 00039 00040 CdbDebugStream( const CdbDebugStream& ); 00041 00042 /// Destructor 00043 /** 00044 * Can only be used by the static fuctory method. 00045 * 00046 * @see CdbDebugStream::instance() 00047 */ 00048 ~CdbDebugStream( ); 00049 00050 /// The asignment operator (NOT IMPLEMENTED) 00051 00052 CdbDebugStream& operator=( const CdbDebugStream& ); 00053 00054 public: 00055 00056 /// Get the instance of the streamer 00057 00058 static CdbDebugStream& instance( ); 00059 00060 public: 00061 00062 /// Get the stream 00063 /** 00064 * This is the actual stream to be used for the output. 00065 */ 00066 std::ostream& stream( ) { return *_myStream ; } 00067 00068 private: 00069 00070 std::ostream* _myStream ; 00071 bool _destroy ; 00072 }; 00073 00074 /// A shortcut definition for the stream 00075 /** 00076 * The current timestamp would be printed at the beginning of the line. 00077 * 00078 * @see CdbTimeUtils::get_current_timestamp( ) 00079 */ 00080 #define CDB_DEBUG_STREAM CdbDebugStream::instance( ).stream( ) << CdbTimeUtils::get_current_timestamp( ) << " " 00081 00082 #endif // CDB_DEBUG_STREAM_HH
1.3-rc3