SAGA Adaptor CPI v.1.0
|
00001 // Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net) 00002 // Copyright (c) 2005-2009 Hartmut Kaiser 00003 // Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu) 00004 // 00005 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00006 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00007 00008 #ifndef SAGA_EXCEPTION_HPP 00009 #define SAGA_EXCEPTION_HPP 00010 00011 // include stl 00012 #include <exception> 00013 #include <iostream> 00014 #include <string> 00015 #include <vector> 00016 00017 // include saga dependencies 00018 #include <saga/saga/base.hpp> 00019 #include <saga/saga/util.hpp> 00020 #include <saga/saga/error.hpp> 00021 #include <saga/saga/object.hpp> 00022 00023 // suppress warnings about dependent classes not being exported from the dll 00024 #if defined(BOOST_MSVC) 00025 #pragma warning(push) 00026 #pragma warning(disable: 4251 4231 4660) 00027 #endif 00028 00030 // 00031 namespace saga 00032 { 00052 class SAGA_EXCEPTION_EXPORT exception : public std::exception 00053 { 00054 private: 00056 TR1::shared_ptr<saga::impl::exception> impl_; 00057 saga::impl::exception* get_impl() const { return impl_.get(); } 00058 friend struct saga::impl::runtime; 00060 00061 public: 00062 // default constructor 00063 // exception() {} 00064 00070 exception (saga::object obj, std::string const& m, error e = NoSuccess); 00071 00077 exception (saga::object obj, std::vector<saga::exception> const& l); 00078 00085 exception (saga::object obj, std::vector<saga::exception> const& l, error e); 00086 00092 explicit exception (std::string const& m, error e = NoSuccess); 00093 00099 explicit exception (std::vector<saga::exception> const& l); 00100 00103 ~exception() throw() {} 00104 00107 char const* what() const throw(); 00108 00112 char const* get_message() const throw(); 00113 00116 saga::error get_error () const throw(); 00117 00121 saga::object get_object () const throw(); 00122 00125 std::vector<saga::exception> const& get_all_exceptions() const throw(); 00126 00131 std::vector<std::string> get_all_messages() const; 00132 }; 00133 00135 class SAGA_EXCEPTION_EXPORT not_implemented : public saga::exception 00136 { 00137 public: 00140 not_implemented (saga::object obj, std::string const& m) 00141 : saga::exception(obj, m, NotImplemented) 00142 {} 00143 00144 not_implemented (saga::object obj, std::vector<saga::exception> const& l) 00145 : saga::exception(obj, l) 00146 {} 00147 00150 explicit not_implemented (std::string const& m) 00151 : saga::exception(m, NotImplemented) 00152 {} 00153 }; 00154 00156 class SAGA_EXCEPTION_EXPORT parameter_exception : public saga::exception 00157 { 00158 protected: 00161 parameter_exception (saga::object obj, std::string const& m, saga::error e) 00162 : saga::exception(obj, m, e) 00163 {} 00164 00165 parameter_exception (saga::object obj, std::vector<saga::exception> const& l) 00166 : saga::exception(obj, l) 00167 {} 00168 00171 parameter_exception (std::string const& m, saga::error e) 00172 : saga::exception(m, e) 00173 {} 00174 }; 00175 00177 class SAGA_EXCEPTION_EXPORT incorrect_url : public saga::parameter_exception 00178 { 00179 public: 00182 incorrect_url (saga::object obj, std::string const& m) 00183 : saga::parameter_exception(obj, m, IncorrectURL) 00184 {} 00185 00186 incorrect_url (saga::object obj, std::vector<saga::exception> const& l) 00187 : saga::parameter_exception(obj, l) 00188 {} 00189 00192 explicit incorrect_url (std::string const& m) 00193 : saga::parameter_exception(m, IncorrectURL) 00194 {} 00195 }; 00196 00198 class SAGA_EXCEPTION_EXPORT bad_parameter : public saga::parameter_exception 00199 { 00200 public: 00203 bad_parameter (saga::object obj, std::string const& m) 00204 : saga::parameter_exception(obj, m, BadParameter) 00205 {} 00206 00207 bad_parameter (saga::object obj, std::vector<saga::exception> const& l) 00208 : saga::parameter_exception(obj, l) 00209 {} 00210 00213 explicit bad_parameter (std::string const& m) 00214 : saga::parameter_exception(m, BadParameter) 00215 {} 00216 }; 00217 00219 class SAGA_EXCEPTION_EXPORT state_exception : public saga::exception 00220 { 00221 protected: 00224 state_exception (saga::object obj, std::string const& m, saga::error e) 00225 : saga::exception(obj, m, e) 00226 {} 00227 00228 state_exception (saga::object obj, std::vector<saga::exception> const& l) 00229 : saga::exception(obj, l) 00230 {} 00231 00234 state_exception (std::string const& m, saga::error e) 00235 : saga::exception(m, e) 00236 {} 00237 }; 00238 00240 class SAGA_EXCEPTION_EXPORT already_exists : public saga::state_exception 00241 { 00242 public: 00245 already_exists (saga::object obj, std::string const& m) 00246 : saga::state_exception(obj, m, AlreadyExists) 00247 {} 00248 00249 already_exists (saga::object obj, std::vector<saga::exception> const& l) 00250 : saga::state_exception(obj, l) 00251 {} 00252 00255 explicit already_exists (std::string const& m) 00256 : saga::state_exception(m, AlreadyExists) 00257 {} 00258 }; 00259 00261 class SAGA_EXCEPTION_EXPORT does_not_exist : public saga::state_exception 00262 { 00263 public: 00266 does_not_exist (saga::object obj, std::string const& m) 00267 : saga::state_exception(obj, m, DoesNotExist) 00268 {} 00269 00270 does_not_exist (saga::object obj, std::vector<saga::exception> const& l) 00271 : saga::state_exception(obj, l) 00272 {} 00273 00276 explicit does_not_exist (std::string const& m) 00277 : saga::state_exception(m, DoesNotExist) 00278 {} 00279 }; 00280 00282 class SAGA_EXCEPTION_EXPORT incorrect_state : public saga::state_exception 00283 { 00284 public: 00287 incorrect_state (saga::object obj, std::string const& m) 00288 : saga::state_exception(obj, m, IncorrectState) 00289 {} 00290 00291 incorrect_state (saga::object obj, std::vector<saga::exception> const& l) 00292 : saga::state_exception(obj, l) 00293 {} 00294 00297 explicit incorrect_state (std::string const& m) 00298 : saga::state_exception(m, IncorrectState) 00299 {} 00300 }; 00301 00303 class SAGA_EXCEPTION_EXPORT security_exception : public saga::exception 00304 { 00305 protected: 00308 security_exception (saga::object obj, std::string const& m, saga::error e) 00309 : saga::exception(obj, m, e) 00310 {} 00311 00312 security_exception (saga::object obj, std::vector<saga::exception> const& l) 00313 : saga::exception(obj, l) 00314 {} 00315 00318 security_exception (std::string const& m, saga::error e) 00319 : saga::exception(m, e) 00320 {} 00321 }; 00322 00324 class SAGA_EXCEPTION_EXPORT permission_denied 00325 : public saga::security_exception 00326 { 00327 public: 00330 permission_denied (saga::object obj, std::string const& m) 00331 : saga::security_exception(obj, m, PermissionDenied) 00332 {} 00333 00334 permission_denied (saga::object obj, std::vector<saga::exception> const& l) 00335 : saga::security_exception(obj, l) 00336 {} 00337 00340 explicit permission_denied (std::string const& m) 00341 : saga::security_exception(m, PermissionDenied) 00342 {} 00343 }; 00344 00346 class SAGA_EXCEPTION_EXPORT authorization_failed 00347 : public saga::security_exception 00348 { 00349 public: 00352 authorization_failed (saga::object obj, std::string const& m) 00353 : saga::security_exception(obj, m, AuthorizationFailed) 00354 {} 00355 00356 authorization_failed (saga::object obj, std::vector<saga::exception> const& l) 00357 : saga::security_exception(obj, l) 00358 {} 00359 00362 explicit authorization_failed (std::string const& m) 00363 : saga::security_exception(m, AuthorizationFailed) 00364 {} 00365 }; 00366 00368 class SAGA_EXCEPTION_EXPORT authentication_failed 00369 : public saga::security_exception 00370 { 00371 public: 00374 authentication_failed (saga::object obj, std::string const& m) 00375 : saga::security_exception(obj, m, AuthenticationFailed) 00376 {} 00377 00378 authentication_failed (saga::object obj, std::vector<saga::exception> const& l) 00379 : saga::security_exception(obj, l) 00380 {} 00381 00384 explicit authentication_failed (std::string const& m) 00385 : saga::security_exception(m, AuthenticationFailed) 00386 {} 00387 }; 00388 00390 class SAGA_EXCEPTION_EXPORT timeout : public saga::state_exception 00391 { 00392 public: 00395 timeout (saga::object obj, std::string const& m) 00396 : saga::state_exception(obj, m, Timeout) 00397 {} 00398 00399 timeout (saga::object obj, std::vector<saga::exception> const& l) 00400 : saga::state_exception(obj, l) 00401 {} 00402 00405 explicit timeout (std::string const& m) 00406 : saga::state_exception(m, Timeout) 00407 {} 00408 }; 00409 00411 class SAGA_EXCEPTION_EXPORT no_success : public saga::exception 00412 { 00413 public: 00416 no_success (saga::object obj, std::string const& m) 00417 : saga::exception(obj, m, NoSuccess) 00418 {} 00419 00420 no_success (saga::object obj, std::vector<saga::exception> const& l) 00421 : saga::exception(obj, l) 00422 {} 00423 00426 explicit no_success (std::string const& m) 00427 : saga::exception(m, NoSuccess) 00428 {} 00429 }; 00430 00432 // adaptors::exception is not in the spec, but to be used by adaptors 00434 00435 namespace adaptors 00436 { 00438 class SAGA_EXCEPTION_EXPORT exception : public saga::exception 00439 { 00440 public: 00441 exception (saga::object obj, 00442 std::string const& name, std::string const& m, 00443 saga::error e = NoSuccess) 00444 : saga::exception (obj, name + ": " + m, e) 00445 { 00446 } 00447 00448 exception (saga::object obj, std::vector<saga::exception> const& l) 00449 : saga::exception (obj, l) 00450 { 00451 } 00452 00453 ~exception (void) throw () {} 00454 }; 00455 00457 } // namespace adaptors 00459 00461 } // namespace saga 00462 00463 // re-enable warnings about dependent classes not being exported from the dll 00464 #if defined(BOOST_MSVC) 00465 #pragma warning(pop) 00466 #endif 00467 00468 #endif // SAGA_EXCEPTION_HPP 00469