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

/magnus/back_end/general/include/LogWatcher.h

Go to the documentation of this file.
00001 /*
00002  *   $Id: LogWatcher.h,v 1.1 1997/06/30 20:13:13 bormotov Exp $
00003  */
00004 
00005 // Copyright (C) 1997 The New York Group Theory Cooperative
00006 // See magnus/doc/COPYRIGHT for the full notice.
00007 
00008 // Contents: Declaration of class LogFileWatcher.
00009 //
00010 // Principal Author: Dmitry Pechkin
00011 //
00012 // Status: under trial.
00013 //
00014 // Revision History:
00015 //
00016 
00017 #ifndef _LOG_WATCHER_H_
00018 #define _LOG_WATCHER_H_
00019 
00020 #include <iostream.h>
00021 #include "Chars.h"
00022 #include "Timer.h"
00023 
00024 const int WATCHER_BUF_SIZE = 4096;
00025 
00026 class LogFileWatcher
00027 {
00028 public:
00029   LogFileWatcher( const Chars& fname, int timeInterval );
00030 
00031   ~LogFileWatcher( );
00032 
00033 
00034   bool changed();
00035   // Returns true iff there is a line to get from the file.
00036 
00037   Chars getline();
00038   // Returns complete line and advances position in the file.
00039 
00040   int getInterval( ) const { return interval; }
00041 
00042   void setInterval( int timeInterval ) 
00043   { 
00044     interval = timeInterval;
00045     timer.reset( interval );
00046   }
00047 
00048 private:
00049 
00050   long fileSize( );
00051 
00052   char peekCh( ) { return file.peek(); }
00053 
00054   char getCh( ) { ++filePos; return file.get(); }
00055 
00056   // Data members.
00057 
00058   fstream file;
00059   Chars fileName;
00060   long filePos; 
00061 
00062 
00063   Chars line;  // current line.
00064   char *buffer;
00065   int  bufpos;
00066   bool completeLine;
00067 
00068   Timer timer;
00069   int interval;
00070 
00071 private:
00072   LogFileWatcher( const LogFileWatcher& watch ); // hidden, not to be implemented
00073   LogFileWatcher& operator=( const LogFileWatcher& watch );
00074 
00075 };
00076 
00077 
00078 #endif

Generated at Tue Jun 19 09:49:35 2001 for Magnus Classes by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001