SAGA Adaptor CPI v.1.0
|
00001 #ifndef SAGA_PACKAGES_CPR_SERVICE_HPP 00002 #define SAGA_PACKAGES_CPR_SERVICE_HPP 00003 00004 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00005 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/cpr_job_service.hpp") 00006 #endif 00007 // Copyright (c) 2005-2009 Hartmut Kaiser 00008 // Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu) 00009 // Copyright (c) 2008 Andre Merzky (andre@merzky.net) 00010 // 00011 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00012 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00013 00014 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00015 #pragma wave option(output: null) 00016 #endif 00017 00018 #include <string> 00019 #include <vector> 00020 00021 // include dependent spec sections 00022 #include <saga/saga/util.hpp> 00023 #include <saga/saga/base.hpp> 00024 #include <saga/saga/types.hpp> 00025 #include <saga/saga/session.hpp> 00026 #include <saga/saga/call.hpp> 00027 #include <saga/saga/url.hpp> 00028 #include <saga/saga/job.hpp> 00029 00030 #include <saga/saga/cpr.hpp> 00031 #include <saga/saga/packages/cpr/config.hpp> 00032 00033 // suppress warnings about dependent classes not being exported from the dll 00034 #if defined(BOOST_MSVC) 00035 #pragma warning(push) 00036 #pragma warning(disable: 4251 4231 4275 4660) 00037 #endif 00038 00039 #ifdef SAGA_DEBUG 00040 #include <saga/saga/packages/cpr/preprocessed/cpr_job_service.hpp> 00041 #else 00042 00043 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00044 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/cpr_job_service.hpp") 00045 #endif 00046 00047 namespace saga 00048 { 00049 namespace cpr 00050 { 00055 class SAGA_CPR_PACKAGE_EXPORT service 00056 : public saga::job::service 00057 { 00058 private: 00059 // factory 00060 SAGA_CALL_CREATE_PRIV_2(session const&, saga::url) 00061 00062 SAGA_CALL_PRIV_1 (create_job, saga::cpr::description) 00063 SAGA_CALL_PRIV_2 (create_job, saga::cpr::description, saga::cpr::description) 00064 SAGA_CALL_PRIV_5 (run_job, std::string, std::string, 00065 saga::job::ostream &, 00066 saga::job::istream &, 00067 saga::job::istream &); 00068 SAGA_CALL_PRIV_2 (run_job, std::string, std::string) 00069 00070 protected: 00072 00073 friend class saga::impl::cpr_job_service; 00074 friend struct saga::detail::create_default<service>; 00075 00076 TR1::shared_ptr <saga::impl::cpr_job_service> get_impl_sp(void) const; 00077 saga::impl::cpr_job_service* get_impl (void) const; 00078 explicit service(saga::impl::cpr_job_service *impl); 00079 explicit service(int); // dummy constructor to create empty facade 00081 00082 public: 00087 explicit service (session const& s, saga::url rm = saga::url()); 00088 00093 explicit service (saga::url rm = saga::url()); 00094 00099 explicit service (saga::object const& o); 00100 00105 ~service (void); 00106 00110 static service create(session const& s, saga::url rm = saga::url()) 00111 { 00112 return service(s, rm); 00113 } 00115 SAGA_CALL_CREATE_2_DEF_1(session const&, saga::url, saga::url()) 00117 00120 static service create(saga::url rm = saga::url()) 00121 { 00122 return service(rm); 00123 } 00124 template <typename Tag> 00125 static saga::task create(saga::url rm = saga::url()) 00126 { 00127 return create<Tag>(detail::get_the_session(), rm); 00128 } 00129 00134 service& operator= (saga::object const& o); 00135 00143 saga::cpr::job create_job(saga::cpr::description job_desc) 00144 { 00145 saga::task t = create_jobpriv(job_desc, saga::task_base::Sync()); 00146 return t.get_result<saga::cpr::job>(); 00147 } 00149 SAGA_CALL_PUB_1_DEF_0 (create_job, saga::cpr::description) 00151 00161 saga::cpr::job create_job(saga::cpr::description job_desc, saga::cpr::description restart_desc) 00162 { 00163 saga::task t = create_jobpriv(job_desc, restart_desc, saga::task_base::Sync()); 00164 return t.get_result<saga::cpr::job>(); 00165 } 00167 SAGA_CALL_PUB_2_DEF_0 (create_job, saga::cpr::description, saga::cpr::description) 00169 00170 saga::cpr::job run_job(std::string cmd, 00171 std::string host, 00172 saga::job::ostream & in, 00173 saga::job::istream & out, 00174 saga::job::istream & err) 00175 00176 { 00177 saga::task t = run_jobpriv(cmd, host, in, out, err, saga::task_base::Sync()); 00178 return t.get_result<saga::cpr::job>(); 00179 } 00181 SAGA_CALL_PUB_5_DEF_0 (run_job, 00182 std::string, std::string, saga::job::ostream, 00183 saga::job::istream, saga::job::istream); 00185 00186 saga::cpr::job run_job(std::string cmd, std::string host) 00187 00188 { 00189 saga::task t = run_jobpriv(cmd, host, saga::task_base::Sync()); 00190 return t.get_result<saga::cpr::job>(); 00191 } 00193 SAGA_CALL_PUB_2_DEF_0 (run_job, 00194 std::string, std::string); 00196 00197 }; 00198 00199 } 00200 00201 namespace detail 00202 { 00203 // we need to specialize the create_default template (used in hold_any) 00204 // to be able to create a truly default constructed service (empty 00205 // facade) 00206 template<> 00207 struct create_default<saga::cpr::service> 00208 { 00209 static saga::cpr::service* call() 00210 { 00211 return new saga::cpr::service(1); // use dummy constructor 00212 } 00213 template <typename T_> static void call(T_* obj) 00214 { 00215 new (obj) saga::cpr::service(1); 00216 } 00217 }; 00218 } 00219 00220 } // namespace saga 00221 00223 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00224 #pragma wave option(output: null) 00225 #endif 00226 00227 #endif // !defined(SAGA_DEBUG) 00228 00229 // re-enable warnings about dependent classes not being exported from the dll 00230 #if defined(BOOST_MSVC) 00231 #pragma warning(pop) 00232 #endif 00233 00234 #endif // !defined(SAGA_PACKAGES_CPR_SERVICE_HPP) 00235