openModeller  Version 1.5.0
PreAlgorithm.cpp
Go to the documentation of this file.
1 
27 #include "PreAlgorithm.hh"
28 
29 #include <openmodeller/Log.hh>
31 
33 {
34 }
35 
37 {
38 };
39 
40 
42 {
43 }
44 
45 
46 bool PreAlgorithm::reset( const PreParameters& params )
47 {
48  if( checkParameters( params ) ) {
49 
50  params_.clear();
51  params_ = params;
52 
53  return true;
54  }
55  else
56  {
57  std::string msg = "PreAlgorithm::Reset: Invalid supplied parameters.\n";
58  Log::instance()->error( msg.c_str() );
59  throw InvalidParameterException( msg );
60  }
61 }
62 
63 void
65 {
66  params.clear();
67  params = params_;
68 }
69 
70 
72 {
73  bool return_value = false;
74 
75  if( checkInternalParameters() ) {
76  return_value = runImplementation();
77  }
78  else
79  {
80  std::string msg = "TePreAlgorithm::apply: Invalid supplied parameters.\n";
81  Log::instance()->error( msg.c_str() );
82  throw InvalidParameterException( msg );
83  }
84 
85  return return_value;
86 }
87 
89 {
90  return params_;
91 }
92 
93 
95 {
96  return checkParameters( params_ );
97 }
98 
99 
101  const PreAlgorithm& external )
102 {
103  std::string msg = "PreAlgorithm::operator=: Algorithms cannot be copied.\n";
104  Log::instance()->error( msg.c_str() );
105  throw InvalidParameterException( msg );
106 
107  return external;
108 }
109 
110 void PreAlgorithm::getLayerResult( const string layer_id, PreParameters& result )
111 {
112  result.clear();
113 
114  std::map<string, PreParameters>::iterator it;
115 
116  if ( result_by_layer_.find( layer_id ) == result_by_layer_.end() ) {
117 
118  string msg = "PreAlgorithm::getLayerResult: No results for the specified layer (";
119  msg.append( layer_id );
120  msg.append(")\n");
121  Log::instance()->error( msg.c_str() );
122  throw InvalidParameterException( msg );
123  }
124 
125  result = result_by_layer_[layer_id];
126 }
void getLayerResult(const string layer_id, PreParameters &result)
virtual ~PreAlgorithm()
const PreAlgorithm & operator=(const PreAlgorithm &external)
static Log * instance()
Returns the instance pointer, creating the object on the first call.
Definition: Log.cpp:45
bool reset(const PreParameters &params)
std::map< string, PreParameters > result_by_layer_
PreParameters params_
void error(const char *format,...)
'Error' level.
Definition: Log.cpp:290
virtual bool runImplementation()=0
void resetState(PreParameters &params)
const PreParameters & getParameters() const
bool checkInternalParameters() const
virtual bool checkParameters(const PreParameters &parameters) const =0