📄 filefilterframewithheader.hpp
字号:
#pragma ident "$Id: FileFilterFrameWithHeader.hpp 274 2006-10-27 14:24:35Z rickmach $"/** * @file FileFilterFrameWithHeader.hpp * Wrapper for gpstk::FileHunter and gpstk::FileFilter that also handles header data */#ifndef GPSTK_FILEFILTERFRAMEWITHHEADER_HPP#define GPSTK_FILEFILTERFRAMEWITHHEADER_HPP//============================================================================//// This file is part of GPSTk, the GPS Toolkit.//// The GPSTk is free software; you can redistribute it and/or modify// it under the terms of the GNU Lesser General Public License as published// by the Free Software Foundation; either version 2.1 of the License, or// any later version.//// The GPSTk is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU Lesser General Public License for more details.//// You should have received a copy of the GNU Lesser General Public// License along with GPSTk; if not, write to the Free Software Foundation,// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA// // Copyright 2004, The University of Texas at Austin////============================================================================//============================================================================////This software developed by Applied Research Laboratories at the University of//Texas at Austin, under contract to an agency or agencies within the U.S. //Department of Defense. The U.S. Government retains all rights to use,//duplicate, distribute, disclose, or release this software. ////Pursuant to DoD Directive 523024 //// DISTRIBUTION STATEMENT A: This software has been approved for public // release, distribution is unlimited.////=============================================================================#include "FileFilterFrame.hpp"namespace gpstk{ /** @addtogroup filedirgroup */ //@{ /** * This is just like FileFilterFrame but it can also handle header * data. The header data is stored in an internal list that can be * accessed with the *Header() methods below. Certain classes (like * RINEX Obs and Met) have filter functions that can be used with * touch() to combine header data from various files. The merge utilities * in wonky use this ability, and other file types with header data * can benefit from using this class's ability to store and write * header data - see the RINEX and FIC GFW classes for more examples. * * When initializing, this uses the FileFilterFrame::init() to read * the FileData into the filter, then does a second pass with its own * init() function to read the headers from those files. This * is a little inefficient, but the goal of these classes was never * efficiency. */ template <class FileStream, class FileData, class FileHeader> class FileFilterFrameWithHeader : public FileFilterFrame<FileStream, FileData> { public: /// Default constructor FileFilterFrameWithHeader(const gpstk::DayTime& start = gpstk::DayTime::BEGINNING_OF_TIME, const gpstk::DayTime& end = gpstk::DayTime::END_OF_TIME) throw(gpstk::Exception) : FileFilterFrame<FileStream, FileData>(start, end) {} /// Takes a list of files to open in lieu of day times FileFilterFrameWithHeader(const std::vector<std::string>& fileList, const gpstk::DayTime& start = gpstk::DayTime::BEGINNING_OF_TIME, const gpstk::DayTime& end = gpstk::DayTime::END_OF_TIME) throw(gpstk::Exception) : FileFilterFrame<FileStream, FileData>(fileList, start, end) { std::vector<std::string>::const_iterator itr = fileList.begin(); while (itr != fileList.end()) { this->fs.newSpec(*itr); init(); itr++; } } /// Takes a file name for a single file filter. /// This can throw an exception when there's a file error. FileFilterFrameWithHeader(const std::string& filename, const gpstk::DayTime& start = gpstk::DayTime::BEGINNING_OF_TIME, const gpstk::DayTime& end = gpstk::DayTime::END_OF_TIME) throw(gpstk::Exception) : FileFilterFrame<FileStream, FileData>(filename, start, end) {init();} /// Uses the FileSpec to retrieve files. Use filter like you would /// in FileHunter, to filter FOR stations, receivers, etc. /// This can throw an exception when there's a file error. FileFilterFrameWithHeader(const FileSpec& spec, const gpstk::DayTime& start = gpstk::DayTime::BEGINNING_OF_TIME, const gpstk::DayTime& end = gpstk::DayTime::END_OF_TIME, const std::vector<FileHunter::FilterPair>& filter = std::vector<FileHunter::FilterPair>()) throw(gpstk::Exception) : FileFilterFrame<FileStream, FileData>(spec, start, end, filter) {init(filter);} /// Gets the files from the file spec and the time, then adds /// the data to the filter. Use filter like you would /// in FileHunter, to filter FOR stations, receivers, etc. FileFilterFrameWithHeader& newSource(const FileSpec& filespec, const gpstk::DayTime& start = gpstk::DayTime::BEGINNING_OF_TIME, const gpstk::DayTime& end = gpstk::DayTime::END_OF_TIME, const std::vector<FileHunter::FilterPair>& filter = std::vector<FileHunter::FilterPair>()) throw(gpstk::Exception) { FileFilterFrame<FileStream, FileData>::newSource(filespec, start, end, filter); init(filter); return *this; } /// Reads in the file and adds the data to the filter. FileFilterFrameWithHeader& newSource(const std::string& filename, const gpstk::DayTime& start = gpstk::DayTime::BEGINNING_OF_TIME, const gpstk::DayTime& end = gpstk::DayTime::END_OF_TIME) throw(gpstk::Exception) { FileFilterFrame<FileStream, FileData>::newSource(filename, start, end); init(); return *this; } /// Reads in the file and adds the data to the filter. FileFilterFrameWithHeader& newSource(const std::vector<std::string>& fileList, const gpstk::DayTime& start = gpstk::DayTime::BEGINNING_OF_TIME, const gpstk::DayTime& end = gpstk::DayTime::END_OF_TIME) throw(gpstk::Exception) { FileFilterFrame<FileStream, FileData>::newSource(fileList, start, end); typename std::vector<std::string>::const_iterator itr; for (itr = fileList.begin(); itr != fileList.end(); itr++) { this->fs.newSpec(*itr); init(); } return *this; } virtual ~FileFilterFrameWithHeader() {} /** * Writes the data to the file outputFile with the given header. * This will overwrite any existing file with the same name. * This can throw an exception when there's a file error. * @return true when it works. * @warning This will not write out headers for files that need them. */ bool writeFile(const std::string& outputFile, const FileHeader& fh) const throw(gpstk::Exception); /** performs the operation op on the header list. */ template <class Operation> FileFilterFrameWithHeader& touchHeader(Operation& op) { typename std::list<FileHeader>::iterator itr = headerList.begin(); while (itr != headerList.end()) { op(*itr); itr++; } return *this; } /// Returns the contents of the header data list. std::list<FileHeader>& getHeaderData(void) {return headerList;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -