00001 //-------------------------------------------------- 00014 //-------------------------------------------------- 00015 00016 #ifndef ALGORITHM_FACTORY_HPP__ 00017 #define ALGORITHM_FACTORY_HPP__ 00018 00019 #include "algorithm.h" 00020 #include "../global/global_definitions.h" 00021 #include "../exceptions/algorithm_factory_exception.h" 00022 #include "../exceptions/algorithm_not_found_exception.h" 00023 #include "../exceptions/null_pointer_exception.h" 00024 00025 #include <QtGui> 00026 #include <QPluginLoader> 00027 #include <string> 00028 #include <map> 00029 00030 00031 class QWidget; 00032 00033 namespace imedgine 00034 { 00035 00036 class AlgorithmInterface; 00037 00038 //-------------------------------------------------- 00055 //--------------------------------------------------- 00056 00057 class AlgorithmFactory 00058 { 00059 public: 00060 00061 //-------------------------------------------------- 00064 00065 typedef boost::shared_ptr<Algorithm> algorithm_pointer_type; 00066 00067 //-------------------------------------------------- 00070 00071 typedef std::string key_type; 00072 00073 //-------------------------------------------------- 00076 00077 AlgorithmFactory() {} 00078 00079 //-------------------------------------------------- 00082 00083 ~AlgorithmFactory() {} 00084 00085 //-------------------------------------------------- 00093 00094 void loadAlgorithm(key_type key, std::string library_path) 00095 throw(AlgorithmFactoryException); 00096 00097 //-------------------------------------------------- 00103 00104 bool isAlgorithmLoaded 00105 (key_type algorithm_key); 00106 00107 //-------------------------------------------------- 00114 00115 bool unloadAlgorithm(key_type algorithm_key); 00116 00117 //-------------------------------------------------- 00128 00129 algorithm_pointer_type createAlgorithm(key_type algorithm_key) const 00130 throw(AlgorithmNotFoundException, NullPointerException); 00131 00132 //-------------------------------------------------- 00143 00144 config_widget_pointer_type createConfigWidget(key_type algorithm_key) const 00145 throw(AlgorithmNotFoundException,NullPointerException); 00146 00147 //-------------------------------------------------- 00157 00158 configuration_pointer_type createConfiguration 00159 (AlgorithmFactory::key_type algorithm_key) const 00160 throw(AlgorithmNotFoundException,NullPointerException); 00161 protected: 00162 00163 typedef AlgorithmInterface* library_handle_type; 00164 typedef std::map<key_type, library_handle_type> key_to_library_handle_map_type; 00165 typedef key_to_library_handle_map_type::iterator 00166 key_to_library_handle_iterator; 00167 typedef key_to_library_handle_map_type::const_iterator 00168 key_to_library_handle_const_iterator; 00169 00170 key_to_library_handle_map_type library_handle_map_; 00171 00172 private: 00173 00174 //-------------------------------------------------- 00177 00178 AlgorithmFactory(AlgorithmFactory const&) {} 00179 00180 //-------------------------------------------------- 00183 00184 AlgorithmFactory& operator = (AlgorithmFactory const&) 00185 { 00186 return(*this); 00187 } 00188 00189 }; // class AlgorithmFactory 00190 00191 } // namespace imedgine 00192 00193 #endif // ALGORITHM_FACTORY_HPP__ 00194