OpenMS
TVToolDiscovery Class Reference

Scans for tools/utils and generates a param for each asynchronously. More...

#include <OpenMS/VISUAL/TVToolDiscovery.h>

Collaboration diagram for TVToolDiscovery:
[legend]

Public Member Functions

 TVToolDiscovery ()
 
 TVToolDiscovery (const TVToolDiscovery &)=delete
 
TVToolDiscoveryoperator= (const TVToolDiscovery &)=delete
 
 ~TVToolDiscovery ()=default
 
void loadToolParams ()
 Start creating params for each tool/util asynchronously. More...
 
void waitForToolParams ()
 Wait for all future params to finish evaluating. More...
 
void waitForPluginParams ()
 
const ParamgetToolParams ()
 Returns a Param object containing the params for each tool/util. More...
 
const ParamgetPluginParams ()
 Returns a param containing the params for each plugin. More...
 
const std::vector< std::string > & getPlugins ()
 Returns the list of read plugin names as saved in the ini. More...
 
bool setPluginPath (const String &path, bool create=false)
 Sets the path that will be searched for Plugins. More...
 
void setVerbose (int verbosity_level)
 set the verbosity level of the tool discovery for debug purposes More...
 
const std::string getPluginPath ()
 Returns the current set path to search plugins in. More...
 
std::string findPluginExecutable (const std::string &name)
 Returns the path to the plugin executable or an empty string if the plugin name is unknown. More...
 

Private Member Functions

void loadPluginParams ()
 
const StringList getPlugins_ ()
 Returns a list of executables that are found at the plugin path. More...
 

Static Private Member Functions

static Param getParamFromIni_ (const String &tool_path, bool plugins=false)
 

Private Attributes

std::string plugin_path_
 The filepath to search pugins in. More...
 
std::vector< std::future< Param > > tool_param_futures_
 The futures for asyncronous loading of the tools/utils and plugins. More...
 
std::vector< std::future< Param > > plugin_param_futures_
 
Param tool_params_
 Contains all the params of the tools/utils. More...
 
Param plugin_params_
 Contains all the params of the plugins. More...
 
std::vector< std::string > plugins_
 The names of all loaded plugins, this is used to add the plugins to the list in the ToolsDialog. More...
 
int verbosity_level_ = 0
 Set to value > 0 to output tool discovery debug information. More...
 

Detailed Description

Scans for tools/utils and generates a param for each asynchronously.

All tools and utils listed in the ToolHandler class are considered.

scanner.loadToolParams();
// Do something else before explicitly waiting for the threads to finish
...
// Wait when convenient. Keeps the GUI responsive while waiting
scanner.waitForToolParams();
// Access the params. If no special timing for waiting or loading is needed this function can be safely called directly.
scanner.getToolParams();
TVToolDiscovery()
Definition: TVToolDiscovery.h:65

Constructor & Destructor Documentation

◆ TVToolDiscovery() [1/2]

TVToolDiscovery ( )
inline

◆ TVToolDiscovery() [2/2]

TVToolDiscovery ( const TVToolDiscovery )
delete

◆ ~TVToolDiscovery()

~TVToolDiscovery ( )
default

Member Function Documentation

◆ findPluginExecutable()

std::string findPluginExecutable ( const std::string &  name)

Returns the path to the plugin executable or an empty string if the plugin name is unknown.

Referenced by TOPPViewBase::runTOPPTool_().

◆ getParamFromIni_()

static Param getParamFromIni_ ( const String tool_path,
bool  plugins = false 
)
staticprivate

Returns param for a given tool/util. This function is thread-safe. Additionally inserts names of tools into plugin list

◆ getPluginParams()

const Param& getPluginParams ( )

Returns a param containing the params for each plugin.

This function will ALWAYS trigger a reload of the plugins.

◆ getPluginPath()

const std::string getPluginPath ( )

Returns the current set path to search plugins in.

Referenced by TOPPViewBase::savePreferences().

◆ getPlugins()

const std::vector<std::string>& getPlugins ( )

Returns the list of read plugin names as saved in the ini.

◆ getPlugins_()

const StringList getPlugins_ ( )
private

Returns a list of executables that are found at the plugin path.

◆ getToolParams()

const Param& getToolParams ( )

Returns a Param object containing the params for each tool/util.

Note that it is possible that not all param futures have been finished (or loaded) yet if this function is called. In that case, the function starts param parsing (loadParam()) and waits for completion (waitForToolParams()) before returning the result.

Referenced by TOPPViewBase::savePreferences(), and TOPPViewBase::showTOPPDialog_().

◆ loadPluginParams()

void loadPluginParams ( )
private

Start creating params for each plugin in the set plugin path asynchronously This should only be called from waitForPluginParams() or the names in the plugins vector are not correct

◆ loadToolParams()

void loadToolParams ( )

Start creating params for each tool/util asynchronously.

Referenced by TOPPViewBase::loadPreferences().

◆ operator=()

TVToolDiscovery& operator= ( const TVToolDiscovery )
delete

◆ setPluginPath()

bool setPluginPath ( const String path,
bool  create = false 
)

Sets the path that will be searched for Plugins.

Parameters
pathThe new path to set
createAttempt to create the directory if it does not already exist
Returns
False if setting/creating the path fails. True otherwise.

Referenced by TOPPViewBase::loadPreferences(), TOPPViewBase::savePreferences(), and TOPPViewBase::TOPPViewBase().

◆ setVerbose()

void setVerbose ( int  verbosity_level)

set the verbosity level of the tool discovery for debug purposes

Referenced by TOPPViewBase::TOPPViewBase().

◆ waitForPluginParams()

void waitForPluginParams ( )

◆ waitForToolParams()

void waitForToolParams ( )

Wait for all future params to finish evaluating.

While waiting the GUI remains responsive. After waiting it is safe to access the params without further waiting.

Referenced by TOPPViewBase::savePreferences(), and TOPPViewBase::showTOPPDialog_().

Member Data Documentation

◆ plugin_param_futures_

std::vector<std::future<Param> > plugin_param_futures_
private

◆ plugin_params_

Param plugin_params_
private

Contains all the params of the plugins.

◆ plugin_path_

std::string plugin_path_
private

The filepath to search pugins in.

◆ plugins_

std::vector<std::string> plugins_
private

The names of all loaded plugins, this is used to add the plugins to the list in the ToolsDialog.

◆ tool_param_futures_

std::vector<std::future<Param> > tool_param_futures_
private

The futures for asyncronous loading of the tools/utils and plugins.

◆ tool_params_

Param tool_params_
private

Contains all the params of the tools/utils.

◆ verbosity_level_

int verbosity_level_ = 0
private

Set to value > 0 to output tool discovery debug information.