openModeller
Version 1.4.0
|
00001 00027 #include "PreAlgorithm.hh" 00028 00029 #include <openmodeller/Log.hh> 00030 #include <openmodeller/Exceptions.hh> 00031 00032 PreAlgorithm::PreAlgorithm() 00033 { 00034 } 00035 00036 PreAlgorithm::PreAlgorithm( const PreAlgorithm& ) 00037 { 00038 }; 00039 00040 00041 PreAlgorithm::~PreAlgorithm() 00042 { 00043 } 00044 00045 00046 bool PreAlgorithm::reset( const PreParameters& params ) 00047 { 00048 if( checkParameters( params ) ) { 00049 00050 params_.clear(); 00051 params_ = params; 00052 00053 return true; 00054 } 00055 else 00056 { 00057 std::string msg = "PreAlgorithm::Reset: Invalid supplied parameters.\n"; 00058 Log::instance()->error( msg.c_str() ); 00059 throw InvalidParameterException( msg ); 00060 } 00061 } 00062 00063 void 00064 PreAlgorithm::resetState( PreParameters& params ) 00065 { 00066 params.clear(); 00067 params = params_; 00068 } 00069 00070 00071 bool PreAlgorithm::apply() 00072 { 00073 bool return_value = false; 00074 00075 if( checkInternalParameters() ) { 00076 return_value = runImplementation(); 00077 } 00078 else 00079 { 00080 std::string msg = "TePreAlgorithm::apply: Invalid supplied parameters.\n"; 00081 Log::instance()->error( msg.c_str() ); 00082 throw InvalidParameterException( msg ); 00083 } 00084 00085 return return_value; 00086 } 00087 00088 const PreParameters& PreAlgorithm::getParameters() const 00089 { 00090 return params_; 00091 } 00092 00093 00094 bool PreAlgorithm::checkInternalParameters() const 00095 { 00096 return checkParameters( params_ ); 00097 } 00098 00099 00100 const PreAlgorithm& PreAlgorithm::operator=( 00101 const PreAlgorithm& external ) 00102 { 00103 std::string msg = "PreAlgorithm::operator=: Algorithms cannot be copied.\n"; 00104 Log::instance()->error( msg.c_str() ); 00105 throw InvalidParameterException( msg ); 00106 00107 return external; 00108 } 00109 00110 void PreAlgorithm::getLayerResult( const string layer_id, PreParameters& result ) 00111 { 00112 result.clear(); 00113 00114 std::map<string, PreParameters>::iterator it; 00115 00116 if ( result_by_layer_.find( layer_id ) == result_by_layer_.end() ) { 00117 00118 string msg = "PreAlgorithm::getLayerResult: No results for the specified layer ("; 00119 msg.append( layer_id ); 00120 msg.append(")\n"); 00121 Log::instance()->error( msg.c_str() ); 00122 throw InvalidParameterException( msg ); 00123 } 00124 00125 result = result_by_layer_[layer_id]; 00126 }