Mantid
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
MantidQt::API::FindFilesWorker Class Reference

A class to allow the asynchronous finding of files. More...

#include <FindFilesWorker.h>

Inheritance diagram for MantidQt::API::FindFilesWorker:
MantidQt::API::FakeFindFilesThread

Public Slots

void disconnectWorker ()
 

Signals

void finished (const FindFilesSearchResults &)
 Signal emitted after the search is finished, regardless of whether any file was found. More...
 

Public Member Functions

 FindFilesWorker (FindFilesSearchParameters parameters)
 Constructor. More...
 

Protected Member Functions

virtual void run () override
 Override parent class run(). More...
 

Private Member Functions

FindFilesSearchResults createFindFilesSearchResult (const std::string &error, const std::vector< std::string > &filenames, const std::string &valueForProperty)
 Helper method to create a search result object. More...
 
void finishSearching (const FindFilesSearchResults &result)
 Emit search result if required. More...
 
std::pair< std::vector< std::string >, std::string > getFilesFromAlgorithm ()
 Use the specified algorithm and property to find files instead of using the FileFinder. More...
 

Private Attributes

FindFilesSearchParameters m_parameters
 Struct to hold the parameters of the search. More...
 

Detailed Description

A class to allow the asynchronous finding of files.

Definition at line 60 of file FindFilesWorker.h.

Constructor & Destructor Documentation

◆ FindFilesWorker()

FindFilesWorker::FindFilesWorker ( FindFilesSearchParameters  parameters)

Constructor.

Parameters
parameters:: a struct representing the parameters of the file search

Definition at line 31 of file FindFilesWorker.cpp.

Member Function Documentation

◆ createFindFilesSearchResult()

FindFilesSearchResults FindFilesWorker::createFindFilesSearchResult ( const std::string &  error,
const std::vector< std::string > &  filenames,
const std::string &  valueForProperty 
)
private

Helper method to create a search result object.

Create a struct containing the results of the search.

This will contain a string with an error (empty string if no error occured), a vector of filenames, and a value to display on the property of an algorithm

Parameters
error:: A user friendly error message or the empty string
filenames:: a vector of paths to files found by the search
valueForProperty:: a message to display on the algorithm's property
Returns
A struct holding the results of this search.

Definition at line 180 of file FindFilesWorker.cpp.

References error, MantidQt::API::FindFilesSearchResults::error, MantidQt::API::FindFilesSearchResults::filenames, and MantidQt::API::FindFilesSearchResults::valueForProperty.

Referenced by run().

◆ disconnectWorker

void FindFilesWorker::disconnectWorker ( )
slot

Definition at line 190 of file FindFilesWorker.cpp.

◆ finished

void MantidQt::API::FindFilesWorker::finished ( const FindFilesSearchResults )
signal

Signal emitted after the search is finished, regardless of whether any file was found.

Referenced by finishSearching().

◆ finishSearching()

void FindFilesWorker::finishSearching ( const FindFilesSearchResults result)
private

Emit search result if required.

Finish searching by emitting the results.

Parameters
result:: the result to return to the main thread.

Definition at line 160 of file FindFilesWorker.cpp.

References finished().

Referenced by run().

◆ getFilesFromAlgorithm()

std::pair< std::vector< std::string >, std::string > FindFilesWorker::getFilesFromAlgorithm ( )
private

Use the specified algorithm and property to find files instead of using the FileFinder.

Create a list of files from the given algorithm property.

Returns
a tuple with a vector of filenames and a string for the property value

Definition at line 125 of file FindFilesWorker.cpp.

References MantidQt::API::FindFilesSearchParameters::algorithmName, MantidQt::API::FindFilesSearchParameters::algorithmProperty, Mantid::Kernel::VectorHelper::flattenVector(), Mantid::Kernel::SingletonHolder< T >::Instance(), m_parameters, MantidQt::API::FindFilesSearchParameters::searchText, and Mantid::Kernel::Property::value().

Referenced by run().

◆ run()

void FindFilesWorker::run ( )
overrideprotectedvirtual

Override parent class run().

Called when the thread is ran via start().

Tries to find the files, and populates the error and filenames member variables with the result of the search.

At present, there are two possible use cases:

  1. Files are found directly by the FileFinder. This is the default case.
  2. Files are found using the specified algorithm property. In this case, a class user must have specified the algorithm and property via FileFinderWidget::setAlgorithmProperty().

Reimplemented in MantidQt::API::FakeFindFilesThread.

Definition at line 48 of file FindFilesWorker.cpp.

References MantidQt::API::FindFilesSearchParameters::algorithmName, MantidQt::API::FindFilesSearchParameters::algorithmProperty, createFindFilesSearchResult(), error, MantidQt::API::FindFilesSearchParameters::extensions, Mantid::API::FileFinderImpl::findRuns(), finishSearching(), getFilesFromAlgorithm(), Mantid::API::FileFinderImpl::getFullPath(), Mantid::Kernel::SingletonHolder< T >::Instance(), MantidQt::API::FindFilesSearchParameters::isForRunFiles, MantidQt::API::FindFilesSearchParameters::isOptional, m_parameters, and MantidQt::API::FindFilesSearchParameters::searchText.

Member Data Documentation

◆ m_parameters

FindFilesSearchParameters MantidQt::API::FindFilesWorker::m_parameters
private

Struct to hold the parameters of the search.

Definition at line 91 of file FindFilesWorker.h.

Referenced by getFilesFromAlgorithm(), and run().


The documentation for this class was generated from the following files: