FileHunter.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: FileHunter.hpp 70 2006-08-01 18:36:21Z ehagen $"
00002 
00003 
00004 
00010 #ifndef GPSTK_FILEHUNTER_HPP
00011 #define GPSTK_FILEHUNTER_HPP
00012 
00013 //============================================================================
00014 //
00015 //  This file is part of GPSTk, the GPS Toolkit.
00016 //
00017 //  The GPSTk is free software; you can redistribute it and/or modify
00018 //  it under the terms of the GNU Lesser General Public License as published
00019 //  by the Free Software Foundation; either version 2.1 of the License, or
00020 //  any later version.
00021 //
00022 //  The GPSTk is distributed in the hope that it will be useful,
00023 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025 //  GNU Lesser General Public License for more details.
00026 //
00027 //  You should have received a copy of the GNU Lesser General Public
00028 //  License along with GPSTk; if not, write to the Free Software Foundation,
00029 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00030 //  
00031 //  Copyright 2004, The University of Texas at Austin
00032 //
00033 //============================================================================
00034 
00035 //============================================================================
00036 //
00037 //This software developed by Applied Research Laboratories at the University of
00038 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00039 //Department of Defense. The U.S. Government retains all rights to use,
00040 //duplicate, distribute, disclose, or release this software. 
00041 //
00042 //Pursuant to DoD Directive 523024 
00043 //
00044 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00045 //                           release, distribution is unlimited.
00046 //
00047 //=============================================================================
00048 
00049 
00050 
00051 
00052 
00053 
00054 #include "FileSpec.hpp"
00055 
00056 namespace gpstk
00057 {
00060 
00063    NEW_EXCEPTION_CLASS(FileHunterException, gpstk::Exception);
00064 
00104    class FileHunter
00105    {
00106    public:
00107 
00110       enum FileChunking
00111       {
00112          WEEK,
00113          DAY,
00114          HOUR,
00115          MINUTE
00116       };
00117       
00120       typedef std::pair<FileSpec::FileSpecType, std::vector<std::string> >
00121          FilterPair;
00122 
00129       FileHunter(const std::string& filespec)
00130          throw(FileHunterException);
00131 
00136       FileHunter(const FileSpec& filespec)
00137          throw(FileHunterException);
00138 
00144       FileHunter& newHunt(const std::string& filespec)
00145          throw(FileHunterException);
00146 
00151       FileHunter& newHunt(const FileSpec& filespec)
00152          throw(FileHunterException)
00153          {return newHunt(filespec.getSpecString());}
00154 
00162       FileHunter& setFilter(const FileSpec::FileSpecType fst,
00163                                     const std::vector<std::string>& filter)
00164          throw(FileHunterException);
00165 
00180       std::vector<std::string> 
00181       find(const gpstk::DayTime& start = gpstk::DayTime::BEGINNING_OF_TIME,
00182            const gpstk::DayTime& end = gpstk::DayTime::END_OF_TIME,
00183            const FileSpec::FileSpecSortType fsst = FileSpec::ascending,
00184            enum FileChunking chunk = DAY) const
00185          throw(FileHunterException);
00186 
00188       void dump(std::ostream& o) const;
00189 
00190    private:
00191          // disallow these
00192       FileHunter();
00193       FileHunter(const FileHunter& fh);
00194       FileHunter& operator=(const FileHunter& fh);
00195 
00196    protected:
00198       void init(const std::string& filespec)
00199          throw(FileHunterException);
00200 
00204       std::vector<std::string> 
00205       searchHelper(const std::string& directory,
00206                    const FileSpec& fs) const
00207          throw(FileHunterException);
00208 
00211       void filterHelper(std::vector<std::string>& fileList, 
00212                         const FileSpec& fs) const
00213          throw(FileHunterException);
00214 
00216       std::vector<FileSpec> fileSpecList;
00217 
00219       std::vector<FilterPair> filterList;
00220    }; // FileHunter
00221 
00223 
00224 } // namespace
00225 
00226 
00227 
00228 
00229 #endif

Generated on Tue May 22 03:30:58 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1