SAGA Adaptor CPI v.1.0
|
00001 #ifndef SAGA_PACKAGES_JOB_JOB_SERVICE_HPP 00002 #define SAGA_PACKAGES_JOB_JOB_SERVICE_HPP 00003 00004 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00005 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/job_service.hpp") 00006 #endif 00007 // Copyright (c) 2005-2009 Hartmut Kaiser 00008 // Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu) 00009 // 00010 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00011 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00012 00013 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00014 #pragma wave option(output: null) 00015 #endif 00016 00017 #include <string> 00018 #include <vector> 00019 00020 // include dependent spec sections 00021 #include <saga/saga/util.hpp> 00022 #include <saga/saga/base.hpp> 00023 #include <saga/saga/types.hpp> 00024 #include <saga/saga/session.hpp> 00025 #include <saga/saga/call.hpp> 00026 #include <saga/saga/url.hpp> 00027 00028 #include <saga/saga/packages/job/config.hpp> 00029 #include <saga/saga/job.hpp> 00030 00031 // suppress warnings about dependent classes not being exported from the dll 00032 #if defined(BOOST_MSVC) 00033 #pragma warning(push) 00034 #pragma warning(disable: 4251 4231 4275 4660) 00035 #endif 00036 00037 #ifdef SAGA_DEBUG 00038 #include <saga/saga/packages/job/preprocessed/job_service.hpp> 00039 #else 00040 00041 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00042 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/job_service.hpp") 00043 #endif 00044 00045 namespace saga 00046 { 00047 namespace job { 00048 00056 class SAGA_JOB_PACKAGE_EXPORT service 00057 : public saga::object 00058 { 00059 private: 00061 00062 // factory 00063 SAGA_CALL_CREATE_PRIV_2(session const&, saga::url) 00064 00065 SAGA_CALL_PRIV_1(create_job, description) 00066 SAGA_CALL_CONST_PRIV_0(get_url) 00067 SAGA_CALL_PRIV_5(run_job, std::string, std::string, 00068 saga::job::ostream&, saga::job::istream&, saga::job::istream&) 00069 SAGA_CALL_PRIV_2(run_job, std::string, std::string) 00070 SAGA_CALL_PRIV_0(list) 00071 SAGA_CALL_PRIV_1(get_job, std::string) 00072 SAGA_CALL_PRIV_0(get_self) 00074 00075 protected: 00077 00078 friend class saga::impl::job_service; 00079 friend struct saga::detail::create_default<service>; 00080 00081 TR1::shared_ptr <saga::impl::job_service> get_impl_sp(void) const; 00082 saga::impl::job_service* get_impl (void) const; 00083 explicit service(saga::impl::job_service *impl); 00084 explicit service(int); // dummy constructor to create empty facade 00086 00087 public: 00092 explicit service (session const& s, saga::url rm = saga::url()); 00093 00098 explicit service (saga::url rm = saga::url()); 00099 00104 explicit service (saga::object const& o); 00105 00110 ~service (void); 00111 00115 static service create(session const& s, saga::url rm = saga::url()) 00116 { 00117 return service(s, rm); 00118 } 00120 SAGA_CALL_CREATE_2_DEF_1(session const&, saga::url, saga::url()) 00122 00125 static service create(saga::url rm = saga::url()) 00126 { 00127 return service(rm); 00128 } 00129 template <typename Tag> 00130 static saga::task create(saga::url rm = saga::url()) 00131 { 00132 return create<Tag>(saga::detail::get_the_session(), rm); 00133 } 00134 00139 service& operator= (saga::object const& o); 00140 00148 job create_job(description job_desc) 00149 { 00150 saga::task t = create_jobpriv(job_desc, saga::task_base::Sync()); 00151 return t.get_result<saga::job::job>(); 00152 } 00153 SAGA_CALL_PUB_1_DEF_0(create_job, description) 00154 00155 00159 saga::url get_url() const 00160 { 00161 saga::task t = get_urlpriv(saga::task_base::Sync()); 00162 return t.get_result<saga::url>(); 00163 } 00164 SAGA_CALL_CONST_PUB_0_DEF_0(get_url) 00165 00166 00173 job run_job(std::string commandline, std::string hostname, 00174 saga::job::ostream& stdin_stream, saga::job::istream& stdout_stream, 00175 saga::job::istream& stderr_stream) 00176 { 00177 saga::task t = run_jobpriv(commandline, hostname, stdin_stream, 00178 stdout_stream, stderr_stream, saga::task_base::Sync()); 00179 return t.get_result<saga::job::job>(); 00180 } 00182 SAGA_CALL_PUB_5_DEF_0(run_job, std::string, std::string, 00183 saga::job::ostream&, saga::job::istream&, saga::job::istream&) 00185 00186 job run_job(std::string commandline, std::string hostname = "") 00187 { 00188 saga::task t = run_jobpriv(commandline, hostname, saga::task_base::Sync()); 00189 return t.get_result<saga::job::job>(); 00190 } 00192 SAGA_CALL_PUB_2_DEF_1(run_job, std::string, std::string, "") 00194 00195 00196 00203 std::vector<std::string> list(void) 00204 { 00205 saga::task t = listpriv(saga::task_base::Sync()); 00206 return t.get_result<std::vector<std::string> >(); 00207 } 00208 SAGA_CALL_PUB_0_DEF_0(list) 00209 00210 00218 job get_job(std::string job_id) 00219 { 00220 saga::task t = get_jobpriv(job_id, saga::task_base::Sync()); 00221 return t.get_result<saga::job::job>(); 00222 } 00224 SAGA_CALL_PUB_1_DEF_0(get_job, std::string) 00226 00234 saga::job::self get_self() 00235 { 00236 saga::task t = get_selfpriv(saga::task_base::Sync()); 00237 return t.get_result<saga::job::self>(); 00238 } 00239 SAGA_CALL_PUB_0_DEF_0(get_self) 00240 00241 }; 00242 00243 } // saga::job 00244 00245 namespace detail 00246 { 00247 // we need to specialize the create_default template (used in hold_any) 00248 // to be able to create a truly default constructed job_service (empty 00249 // facade) 00250 template<> 00251 struct create_default<saga::job::service> 00252 { 00253 static saga::job::service* call() 00254 { 00255 return new saga::job::service(1); // use dummy constructor 00256 } 00257 template <typename T_> static void call(T_* obj) 00258 { 00259 new (obj) saga::job::service(1); 00260 } 00261 }; 00262 } 00263 00264 } // namespace saga 00265 00267 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00268 #pragma wave option(output: null) 00269 #endif 00270 00271 #endif // !defined(SAGA_DEBUG) 00272 00273 // re-enable warnings about dependent classes not being exported from the dll 00274 #if defined(BOOST_MSVC) 00275 #pragma warning(pop) 00276 #endif 00277 00278 #endif // !defined(SAGA_PACKAGES_JOB_JOB_SERVICE_HPP) 00279