Code Search for Developers
 
 
  

LogWatcher.h from Magnus at Krugle


Show LogWatcher.h syntax highlighted

// Copyright (C) 1997 The New York Group Theory Cooperative
// See magnus/doc/COPYRIGHT for the full notice.

// Contents: Declaration of class LogFileWatcher.
//
// Principal Author: Dmitry Pechkin
//
// Status: under trial.
//
// Revision History:
//

#ifndef _LOG_WATCHER_H_
#define _LOG_WATCHER_H_

#include <iostream>
#include "Chars.h"
#include "Timer.h"

const int WATCHER_BUF_SIZE = 4096;

class LogFileWatcher
{
public:
  LogFileWatcher( const Chars& fname, int timeInterval );

  ~LogFileWatcher( );


  bool changed();
  // Returns true iff there is a line to get from the file.

  Chars getline();
  // Returns complete line and advances position in the file.

  int getInterval( ) const { return interval; }

  void setInterval( int timeInterval ) 
  { 
    interval = timeInterval;
    timer.reset( interval );
  }

private:

  long fileSize( );

  char peekCh( ) { return file.peek(); }

  char getCh( ) { ++filePos; return file.get(); }

  // Data members.

  std::fstream file;
  Chars fileName;
  long filePos; 


  Chars line;  // current line.
  char *buffer;
  int  bufpos;
  bool completeLine;

  Timer timer;
  int interval;

private:
  LogFileWatcher( const LogFileWatcher& watch ); // hidden, not to be implemented
  LogFileWatcher& operator=( const LogFileWatcher& watch );

};


#endif




See more files for this project here

Magnus

Magnus is a special purpose mathematical package for Infinite Group Theory computations

Project homepage: http://sourceforge.net/projects/magnus
Programming language(s): C,C++
License: other

  Associations.h
  BTree.h
  BlackBox.h
  Cell.h
  Chars.h
  DArray.h
  DCell.h
  DList.h
  File.h
  GCD.h
  GlobalRandom.h
  IStreamPoll.h
  Int2.h
  List.h
  LogWatcher.h
  MagnusHome.h
  MultiDimArray.h
  QuickAssociations.h
  RandomNumbers.h
  Set.h
  Stack.h
  Timer.h
  Type.h
  Vector.h
  WordParser.h
  conversions.h