INTRODUCTION Overview Download and Install Quick Start Documentation Publications NONFRAMEWORK CODE Driver Interfaces Drivers Libraries Utilities FRAMEWORK CODE Interfaces Components Libraries Utilities Full Software Listings DEVELOPER Tutorials Examples Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
masterfilereader.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2009 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_MASTER_FILE_READER_H 00012 #define ORCA_ORCALOG_MASTER_FILE_READER_H 00013 00014 #include <memory> 00015 #include <IceUtil/Mutex.h> 00016 #include <orcaice/context.h> 00017 00018 namespace orcalog 00019 { 00020 namespace detail{ 00021 template<typename IndexType> 00022 class FileBreadCrumbs; 00023 } 00024 00028 class MasterFileReader 00029 { 00030 public: 00031 MasterFileReader( const std::string& filename, const orcaice::Context& context ); 00032 ~MasterFileReader(); 00033 00035 void getLogs( std::vector<std::string> &filenames, 00036 std::vector<std::string> &interfaceTypes, 00037 std::vector<std::string> &formats, 00038 std::vector<bool> &enableds ); 00039 00042 void rewindToStart(); 00043 00048 int getData( int &seconds, int &useconds, int &id, int &index ); 00049 00060 int getDataAtOrAfterTime( int &seconds, int &useconds, int &id, int &index, int seekSec, int seekUsec=0 ); 00061 00063 void placeCursorBeforeTime( int seekSec, int seekUsec=0 ); 00064 00069 int placeCursorAtOrAfterTime( int seekSec, int seekUsec=0 ); 00070 00073 bool getCursorTime( int &seconds, int &useconds ) const; 00074 00078 void stepBackward(); 00079 00080 private: 00081 00082 void calcConstituentLogs(); 00083 void calcCursorInfo(); 00084 int readData( int& seconds, int& useconds, int& id, int& index ); 00085 void moveTo( const std::ios::pos_type &pos ); 00086 00087 std::ifstream *file_; 00088 00089 // The time of the first entry 00090 IceUtil::Time initialCursorTime_; 00091 00092 // What's at the cursor. Ie: 00093 // if (cursorValid): what we'll get if we call getData() now. 00094 // if (!cursorValid): the last timeStamp in the file. 00095 int cursorSec_; 00096 int cursorUsec_; 00097 int cursorId_; 00098 int cursorIndex_; 00099 00100 bool cursorValid_; 00101 00102 // remember the dir where the master file is located 00103 // the individual log files MUST be in the same dir. 00104 std::string dir_; 00105 00106 // Details of the logs referenced in this master file 00107 std::vector<std::string> filenames_; 00108 std::vector<std::string> interfaceTypes_; 00109 std::vector<std::string> formats_; 00110 std::vector<bool> enableds_; 00111 00112 // Used for recording positions in the file. 00113 // detail::FileBreadCrumbs<IceUtil::Time> *breadCrumbs_; 00114 std::auto_ptr< detail::FileBreadCrumbs<IceUtil::Time> > breadCrumbs_; 00115 00116 orcaice::Context context_; 00117 }; 00118 00119 } 00120 00121 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)