openModeller  Version 1.5.0
AlgorithmFactory.hh
Go to the documentation of this file.
1 
28 #ifndef _ALGORITHM_FACTORYHH_
29 #define _ALGORITHM_FACTORYHH_
30 
33 #include <openmodeller/Sampler.hh>
35 
37 
38 #include <string>
39 #include <list>
40 
41 class AlgParameter;
42 
43 /****************************************************************/
44 /*********************** Algorithm Factory **********************/
45 
55 class dllexp AlgorithmFactory
56 {
57 
58 public:
59 
61 
65  static void setDefaultAlgDir( std::string const dir );
66 
70  static std::string getDefaultAlgDir();
71 
78  static int searchDefaultDirs();
79 
84  static int addDir( const std::string& dirs );
85 
90  static bool addDll( const std::string& file );
91 
108  static AlgMetadata const**availableAlgorithms();
109 
116  static int numAvailableAlgorithms();
117 
123  static AlgMetadata const *algorithmMetadata( std::string const algorithm_id );
124 
132  static AlgorithmPtr newAlgorithm( std::string const id );
133 
134  static AlgorithmPtr newAlgorithm( const ConstConfigurationPtr& );
135 
136  /*
137  * Method to serialize the available algorithms
138  *
139  * Note that this class does not implement "Configurable"
140  * because it cannot be instantiated from outside (singleton
141  * pattern). Also the counterpart setConfiguration method is not
142  * implemented in this case because it makes no sense to load
143  * algorithms from XML - they can only be dynamically loaded
144  * from the respective libraries.
145  */
146  static ConfigurationPtr getConfiguration();
147 
155  static std::string const getCurrentId( std::string const algorithm_id );
156 
157 private:
158 
160 
161  static AlgorithmFactory& getInstance();
162 
163  // Default directory to search for algorithms
164  std::string _default_alg_dir;
165 
166  friend class testDLLId;
167  class DLL;
169  typedef std::list<DLLPtr> ListDLL;
170  typedef std::list<std::string> PluginPath;
171 
174 
179  int p_addDir( const std::string& dir );
180 
185  bool p_addDll( const std::string& file );
186 
188  class DLL : private ReferenceCountedObject
189  {
191  public:
192  DLL();
193  DLL( const std::string& file );
194  ~DLL();
195 
196  operator bool() const;
197 
199  AlgorithmPtr newAlgorithm();
200 
201  AlgMetadata const *getMetadata();
202 
203  private:
207  std::string _file;
208  };
209 
210 
211 };
212 
213 
214 #endif
OM_ALG_DLL_EXPORT AlgMetadata const * algorithmMetadata()
Definition: aquamaps.cpp:223
AlgorithmImpl *(* TAlgFactory)()
Definition: Algorithm.hh:63
std::list< DLLPtr > ListDLL
std::list< std::string > PluginPath
std::string _default_alg_dir
AlgMetadata *(* TAlgMetadata)()
Definition: Algorithm.hh:64
ReferenceCountedPointer< DLL > DLLPtr
void * DLLHandle
Definition: os_specific.hh:81