openModeller  Version 1.5.0
AlgorithmFactory Class Reference

#include <AlgorithmFactory.hh>

Collaboration diagram for AlgorithmFactory:
Collaboration graph

Classes

class  DLL
 

Public Member Functions

 ~AlgorithmFactory ()
 

Static Public Member Functions

static void setDefaultAlgDir (std::string const dir)
 
static std::string getDefaultAlgDir ()
 
static int searchDefaultDirs ()
 
static int addDir (const std::string &dirs)
 
static bool addDll (const std::string &file)
 
static AlgMetadata const ** availableAlgorithms ()
 
static int numAvailableAlgorithms ()
 
static AlgMetadata const * algorithmMetadata (std::string const algorithm_id)
 
static AlgorithmPtr newAlgorithm (std::string const id)
 
static AlgorithmPtr newAlgorithm (const ConstConfigurationPtr &)
 
static ConfigurationPtr getConfiguration ()
 
static std::string const getCurrentId (std::string const algorithm_id)
 

Private Types

typedef
ReferenceCountedPointer< DLL
DLLPtr
 
typedef std::list< DLLPtrListDLL
 
typedef std::list< std::string > PluginPath
 

Private Member Functions

 AlgorithmFactory ()
 
int p_addDir (const std::string &dir)
 
bool p_addDll (const std::string &file)
 

Static Private Member Functions

static AlgorithmFactorygetInstance ()
 

Private Attributes

std::string _default_alg_dir
 
ListDLL _dlls
 
PluginPath _pluginpath
 

Friends

class testDLLId
 

Detailed Description

Responsable for instantiate algorithms.

Obs: Besides instantiate the algorithms it does not sets the Sampler object of the algorithms. So, before use an algorithm returned by this classe one needs to calls the method Algorithm::setSample().

Definition at line 55 of file AlgorithmFactory.hh.

Member Typedef Documentation

Definition at line 167 of file AlgorithmFactory.hh.

typedef std::list<DLLPtr> AlgorithmFactory::ListDLL
private

Definition at line 169 of file AlgorithmFactory.hh.

typedef std::list<std::string> AlgorithmFactory::PluginPath
private

Definition at line 170 of file AlgorithmFactory.hh.

Constructor & Destructor Documentation

AlgorithmFactory::~AlgorithmFactory ( )

Definition at line 177 of file AlgorithmFactory.cpp.

AlgorithmFactory::AlgorithmFactory ( )
private

Definition at line 168 of file AlgorithmFactory.cpp.

Member Function Documentation

int AlgorithmFactory::addDir ( const std::string &  dirs)
static

Search for all DLLs in some directories.

Parameters
dirsnull terminated string representing a directory to scan
Returns
Number of DLLs found.

Definition at line 366 of file AlgorithmFactory.cpp.

References getInstance(), and p_addDir().

Referenced by searchDefaultDirs().

Here is the call graph for this function:

bool AlgorithmFactory::addDll ( const std::string &  file)
static

Add a single file to the DLL search list.

Parameters
filename of dll file to attempt to load
Returns
true for success.

Definition at line 404 of file AlgorithmFactory.cpp.

References getInstance(), and p_addDll().

Here is the call graph for this function:

AlgMetadata const * AlgorithmFactory::algorithmMetadata ( std::string const  algorithm_id)
static

Returns an specific algorithm metadata

Parameters
algorithm_idIdentifier of the algorithm.
Returns
Algorithm's metadata or zero if there algorithm was not found.

Definition at line 257 of file AlgorithmFactory.cpp.

References _dlls, Log::error(), getCurrentId(), getInstance(), and Log::instance().

Referenced by OpenModeller::algorithmMetadata(), and main().

Here is the call graph for this function:

AlgMetadata const ** AlgorithmFactory::availableAlgorithms ( )
static

Finds the system available algorithms.

Note that the returned algorithms can not run because they are not initialized with "Sampler" and parameters! To do so, use the method newAlgorithm().

The pointer to the array must be deallocated by the caller using delete []. However, the individual AlgMetadata*'s in the array must not be deallocated. For instance:

AlgMetadata const **algorithms = om->availableAlgorithms(); // do something delete [] algorithms;

Returns
a null terminated list of available algorithms.

Definition at line 213 of file AlgorithmFactory.cpp.

References _dlls, getInstance(), and metadata.

Referenced by OpenModeller::availableAlgorithms().

Here is the call graph for this function:

string const AlgorithmFactory::getCurrentId ( std::string const  algorithm_id)
static

Returns the current algorithm id in case it matches one of the previous ids of an algorithm. This method was created to allow changes in algorithm ids without breaking compatibility with serialized data.

Parameters
algorithm_idIdentifier of an algorithm.
Returns
Current algorithm identifier when the parameter matches a known previous identifier, otherwise it returns the parameter.

Definition at line 575 of file AlgorithmFactory.cpp.

Referenced by algorithmMetadata().

std::string AlgorithmFactory::getDefaultAlgDir ( )
static

Return the default directory to search for algorithms.

Returns
Default directory

Definition at line 203 of file AlgorithmFactory.cpp.

References _default_alg_dir, and getInstance().

Referenced by initialPluginPath().

Here is the call graph for this function:

AlgorithmFactory & AlgorithmFactory::getInstance ( )
staticprivate
static AlgorithmPtr AlgorithmFactory::newAlgorithm ( std::string const  id)
static
AlgorithmPtr AlgorithmFactory::newAlgorithm ( const ConstConfigurationPtr config)
static

Definition at line 328 of file AlgorithmFactory.cpp.

References Log::debug(), Log::instance(), and newAlgorithm().

Here is the call graph for this function:

int AlgorithmFactory::numAvailableAlgorithms ( )
static

Number of available algorithms. If the algorithms are not already searched in the system, searchs them first.

Returns
Number of available algorithms.

Definition at line 244 of file AlgorithmFactory.cpp.

References _dlls, and getInstance().

Referenced by OpenModeller::numAvailableAlgorithms().

Here is the call graph for this function:

int AlgorithmFactory::p_addDir ( const std::string &  dir)
private

Implementation of directory scan.

Parameters
dirDirectory to scan.
Returns
Number of libraries found.

Definition at line 376 of file AlgorithmFactory.cpp.

References _dlls, Log::instance(), p_addDll(), scanDirectory(), and Log::warn().

Referenced by addDir().

Here is the call graph for this function:

bool AlgorithmFactory::p_addDll ( const std::string &  file)
private

Implementation of Dll load.

Parameters
fileName of file to laod.
Returns
True if successfully loaded.

Definition at line 414 of file AlgorithmFactory.cpp.

References _dlls, Log::debug(), and Log::instance().

Referenced by addDll(), and p_addDir().

Here is the call graph for this function:

int AlgorithmFactory::searchDefaultDirs ( )
static

Search for all DLLs in default directories.

The default search algorithm is platform specific.

Returns
Number of DLLs loaded.

Definition at line 351 of file AlgorithmFactory.cpp.

References addDir(), Log::debug(), initialPluginPath(), and Log::instance().

Referenced by main().

Here is the call graph for this function:

void AlgorithmFactory::setDefaultAlgDir ( std::string const  dir)
static

Set a default directory to search for algorithms.

Parameters
dirDefault directory

Definition at line 193 of file AlgorithmFactory.cpp.

References _default_alg_dir, and getInstance().

Referenced by setupExternalResources().

Here is the call graph for this function:

Friends And Related Function Documentation

friend class testDLLId
friend

Definition at line 166 of file AlgorithmFactory.hh.

Member Data Documentation

std::string AlgorithmFactory::_default_alg_dir
private

Definition at line 164 of file AlgorithmFactory.hh.

Referenced by getDefaultAlgDir(), and setDefaultAlgDir().

ListDLL AlgorithmFactory::_dlls
private
PluginPath AlgorithmFactory::_pluginpath
private

Definition at line 173 of file AlgorithmFactory.hh.


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