orca-robotics INTRODUCTION Overview Download and Install Quick Start Documentation Publications REPOSITORY Interfaces Components Libraries Utilities Software Map DEVELOPER Tutorials Examples Dev Guide Dashboard Wiki login/pass: orca/orca PEOPLE Contributors Users Project Download Mailing lists
|
logreader.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This copy of Orca is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef ORCA_ORCALOG_LOGREADER_H 00012 #define ORCA_ORCALOG_LOGREADER_H 00013 00014 #include <string> 00015 #include <vector> 00016 #include <orcaice/context.h> 00017 #include <orcalog/logreaderinfo.h> 00018 00019 namespace orcalog 00020 { 00021 00022 namespace detail{ 00023 template<typename IndexType> 00024 class FileBreadCrumbs; 00025 } 00026 00030 class LogReader 00031 { 00032 public: 00033 00034 LogReader( const LogReaderInfo &logReaderInfo ); 00035 virtual ~LogReader(); 00036 00038 void init(); 00039 00040 const LogReaderInfo &logReaderInfo() const { return logReaderInfo_; } 00041 00043 std::ifstream *file_; 00044 00046 int logIndex() const { return logIndex_; } 00047 00049 void setLogIndex( int index ); 00050 00053 virtual std::string toString() const; 00054 00055 protected: 00056 00057 // Derived classes should call this to let us know when we're at log index zero 00058 void zeroLogIndex(); 00059 00060 // Derived classes should call this when they have just read an item. 00061 void advanceLogIndex(); 00062 00069 virtual void openLogFile(); 00070 00073 virtual void read()=0; 00074 00075 private: 00076 00077 LogReaderInfo logReaderInfo_; 00078 00079 // An index into the log: we're currently pointing at the start of the logIndex_'th object. 00080 int logIndex_; 00081 00082 // As we move through the file, leave a trail of bread-crumbs so we can rewind 00083 // (use the index as the key) 00084 std::auto_ptr< detail::FileBreadCrumbs<int> > breadCrumbs_; 00085 }; 00086 00089 std::ifstream *openAsciiFileForReading( const std::string &filename ); 00090 00093 std::ifstream *openBinaryFileForReading( const std::string &filename ); 00094 00095 } // namespace 00096 00097 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)