OSSIM - Open Source Software Image Map
Version 1.9.0 (20180803)
|
Utility class to walk through directories and get a list of files to process. More...
#include <ossimFileWalker.h>
Classes | |
class | ossimFileWalkerJob |
Private ossimJob class. More... | |
class | ossimFileWalkerJobCallback |
Private ossimJobCallback class. More... | |
Public Member Functions | |
ossimFileWalker () | |
default constructor More... | |
~ossimFileWalker () | |
destructor More... | |
void | walk (const std::vector< ossimFilename > &files) |
Takes an array of files. More... | |
void | walk (const ossimFilename &root) |
This will walk "root" and execute a callback for each file found. More... | |
void | setFileProcessor (ossimFileProcessorInterface *fpi) |
Sets ossimFileProcessorInterfacecallback method to process files. More... | |
const std::vector< std::string > & | getFilteredExtensions () const |
std::vector< std::string > & | getFilteredExtensions () |
Non const method to allow access for adding or deleting extensions from the list. More... | |
void | dumpFilteredExtensionList () const |
Dumps filtered image extenstions to std out. More... | |
void | initializeDefaultFilterList () |
Initializes the filter list with a default set of filtered out file names. More... | |
void | setRecurseFlag (bool flag) |
Sets recurse flag. More... | |
void | setWaitOnDirFlag (bool flag) |
Sets waitOnDir flag. More... | |
void | setAbortFlag (bool flag) |
If set to true this stops files walking (aborts). More... | |
void | setNumberOfThreads (ossim_uint32 nThreads) |
Sets the max number of threads(jobs) to run at one time. More... | |
Private Member Functions | |
void | walkDir (const ossimFilename &dir) |
Processes files in directory. More... | |
bool | isFiltered (const ossimFilename &f) const |
Convenience method for file walker code to check file to see is it should be processed. More... | |
bool | isDotFile (const ossimFilename &f) const |
isDotFile method. More... | |
Private Attributes | |
ossimFileProcessorInterface * | m_fileProcessor |
Callback to method to process a file. More... | |
std::shared_ptr< ossimJobMultiThreadQueue > | m_jobQueue |
std::vector< std::string > | m_filteredExtensions |
bool | m_recurseFlag |
bool | m_waitOnDirFlag |
bool | m_abortFlag |
std::mutex | m_mutex |
Utility class to walk through directories and get a list of files to process.
For each file found the ossimFileProcessorInterface::processFile method is excecuted. Internally the processFile calls are placed in a job queue.
Typical usage (snip from ossimTiledElevationDatabase):
ossimFileWalker* fw = new ossimFileWalker(); fw->initializeDefaultFilterList(); fw->setFileProcessor( this ); fw->walk(f);
Definition at line 46 of file ossimFileWalker.h.
ossimFileWalker::ossimFileWalker | ( | ) |
default constructor
Definition at line 28 of file ossimFileWalker.cpp.
ossimFileWalker::~ossimFileWalker | ( | ) |
destructor
Definition at line 39 of file ossimFileWalker.cpp.
References m_jobQueue.
void ossimFileWalker::dumpFilteredExtensionList | ( | ) | const |
Dumps filtered image extenstions to std out.
Definition at line 406 of file ossimFileWalker.cpp.
References m_filteredExtensions, ossimNotify(), and ossimNotifyLevel_NOTICE.
const std::vector< std::string > & ossimFileWalker::getFilteredExtensions | ( | ) | const |
Definition at line 396 of file ossimFileWalker.cpp.
References m_filteredExtensions.
std::vector< std::string > & ossimFileWalker::getFilteredExtensions | ( | ) |
Non const method to allow access for adding or deleting extensions from the list.
The list is used by the private isFiltered method to avoid trying to process unwanted files.
Definition at line 401 of file ossimFileWalker.cpp.
References m_filteredExtensions.
void ossimFileWalker::initializeDefaultFilterList | ( | ) |
Initializes the filter list with a default set of filtered out file names.
Definition at line 418 of file ossimFileWalker.cpp.
References m_filteredExtensions, and m_mutex.
Referenced by ossimImageElevationDatabase::loadFileMap().
|
private |
isDotFile method.
f | File/directory to check. |
Definition at line 354 of file ossimFileWalker.cpp.
References ossimString::find(), ossimString::find_last_of(), and ossimString::size().
Referenced by isFiltered().
|
private |
Convenience method for file walker code to check file to see is it should be processed.
f | File to check. |
Definition at line 311 of file ossimFileWalker.cpp.
References ossimString::c_str(), ossimString::downcase(), ossimFilename::ext(), isDotFile(), m_filteredExtensions, and ossimString::size().
void ossimFileWalker::setAbortFlag | ( | bool | flag | ) |
If set to true this stops files walking (aborts).
flag | True to abort current "walk". |
Definition at line 473 of file ossimFileWalker.cpp.
References m_abortFlag, and m_mutex.
void ossimFileWalker::setFileProcessor | ( | ossimFileProcessorInterface * | fpi | ) |
Sets ossimFileProcessorInterfacecallback method to process files.
fpi | ossimFileProcessorInterface pointer |
Definition at line 487 of file ossimFileWalker.cpp.
References m_fileProcessor, and m_mutex.
Referenced by ossimImageElevationDatabase::loadFileMap().
void ossimFileWalker::setNumberOfThreads | ( | ossim_uint32 | nThreads | ) |
Sets the max number of threads(jobs) to run at one time.
Definition at line 480 of file ossimFileWalker.cpp.
References m_jobQueue, and m_mutex.
void ossimFileWalker::setRecurseFlag | ( | bool | flag | ) |
Sets recurse flag.
If set to true this stops recursing of the current directory. Defaulted to true in the constructor. Typically used to indicate the directory being processed holds a directory based image, e.g. RPF data.
flag | True to recurse, false to stop recursion of current directory. |
Definition at line 459 of file ossimFileWalker.cpp.
References m_mutex, and m_recurseFlag.
void ossimFileWalker::setWaitOnDirFlag | ( | bool | flag | ) |
Sets waitOnDir flag.
If set to true each directory is processed in entirety before sub directories are recursed. This allows callers of setRecurseFlag to disable directory walking. If your code is calling setRecurseFlag this flag should be set to true.
flag | true to wait, false to not wait. Defaulted to false in the constructor. |
Definition at line 466 of file ossimFileWalker.cpp.
References m_mutex, and m_waitOnDirFlag.
void ossimFileWalker::walk | ( | const std::vector< ossimFilename > & | files | ) |
Takes an array of files.
For each file in array: If files is a directory, it will walk it. Files found in walk or files(not directories) in the array will be processed via a job queue.
Files are filter prior to the callback execution. The filtering is to eliminate sending unwanted files to the callback. There is a default filter table. This can be edited by calling the non-const getFilteredExtensions method.
Each callback is placed in a threaded job queue. So users should ensure their callback is thread safe.
Definition at line 44 of file ossimFileWalker.cpp.
Referenced by ossimImageElevationDatabase::loadFileMap().
void ossimFileWalker::walk | ( | const ossimFilename & | root | ) |
This will walk "root" and execute a callback for each file found.
Files are filter prior to the callback execution. The filtering is to eliminate sending unwanted files to the callback. There is a default filter table. This can be edited by calling the non-const getFilteredExtensions method.
Each callback is placed in a threaded job queue. So users should ensure their callback is thread safe.
Definition at line 132 of file ossimFileWalker.cpp.
|
private |
Processes files in directory.
If a file in the directory is itself a directory this will do a recursive call to itself. Individual files are processed in a job queue...
Definition at line 182 of file ossimFileWalker.cpp.
|
private |
Definition at line 221 of file ossimFileWalker.h.
Referenced by setAbortFlag().
|
private |
Callback to method to process a file.
const | ossimFilename& First parameter(argument) file to process. |
Definition at line 216 of file ossimFileWalker.h.
Referenced by ossimFileWalker::ossimFileWalkerJob::run(), and setFileProcessor().
|
private |
Definition at line 218 of file ossimFileWalker.h.
Referenced by dumpFilteredExtensionList(), getFilteredExtensions(), initializeDefaultFilterList(), and isFiltered().
|
private |
Definition at line 217 of file ossimFileWalker.h.
Referenced by setNumberOfThreads(), and ~ossimFileWalker().
|
private |
Definition at line 222 of file ossimFileWalker.h.
Referenced by initializeDefaultFilterList(), setAbortFlag(), setFileProcessor(), setNumberOfThreads(), setRecurseFlag(), and setWaitOnDirFlag().
|
private |
Definition at line 219 of file ossimFileWalker.h.
Referenced by setRecurseFlag().
|
private |
Definition at line 220 of file ossimFileWalker.h.
Referenced by setWaitOnDirFlag().