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
00008
00009
00010
00011
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
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
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
00045 namespace saga
00046 {
00047 namespace job {
00048
00056 class SAGA_JOB_PACKAGE_EXPORT service
00057 : public saga::object
00058 {
00059 private:
00060
00061 SAGA_CALL_CREATE_PRIV_2(session const&, saga::url)
00062
00063 SAGA_CALL_PRIV_1(create_job, description)
00064 SAGA_CALL_CONST_PRIV_0(get_url)
00065 SAGA_CALL_PRIV_5(run_job, std::string, std::string,
00066 saga::job::ostream&, saga::job::istream&, saga::job::istream&)
00067 SAGA_CALL_PRIV_2(run_job, std::string, std::string)
00068 SAGA_CALL_PRIV_0(list)
00069 SAGA_CALL_PRIV_1(get_job, std::string)
00070 SAGA_CALL_PRIV_0(get_self)
00071
00072 protected:
00074
00075 friend class saga::impl::job_service;
00076 friend struct saga::detail::create_default<service>;
00077
00078 TR1::shared_ptr <saga::impl::job_service> get_impl (void) const;
00079 explicit service(saga::impl::job_service *impl);
00080 explicit service(int);
00082
00083 public:
00088 explicit service (session const& s, saga::url rm = saga::url());
00089
00094 explicit service (saga::url rm = saga::url());
00095
00100 explicit service (saga::object const& o);
00101
00106 ~service (void);
00107
00111 static service create(session const& s, saga::url rm = saga::url())
00112 {
00113 return service(s, rm);
00114 }
00115 SAGA_CALL_CREATE_2_DEF_1(session const&, saga::url, saga::url())
00116
00117
00119 static service create(saga::url rm = saga::url())
00120 {
00121 return service(rm);
00122 }
00123 template <typename Tag>
00124 static saga::task create(saga::url rm = saga::url())
00125 {
00126 return create<Tag>(saga::detail::get_the_session(), rm);
00127 }
00128
00133 service& operator= (saga::object const& o);
00134
00141 job create_job(description job_desc)
00142 {
00143 saga::task t = create_jobpriv(job_desc, saga::task_base::Sync());
00144 return t.get_result<saga::job::job>();
00145 }
00146 SAGA_CALL_PUB_1_DEF_0(create_job, description)
00147
00148
00152 saga::url get_url() const
00153 {
00154 saga::task t = get_urlpriv(saga::task_base::Sync());
00155 return t.get_result<saga::url>();
00156 }
00157 SAGA_CALL_CONST_PUB_0_DEF_0(get_url)
00158
00159
00165 job run_job(std::string commandline, std::string hostname,
00166 saga::job::ostream& stdin_stream, saga::job::istream& stdout_stream,
00167 saga::job::istream& stderr_stream)
00168 {
00169 saga::task t = run_jobpriv(commandline, hostname, stdin_stream,
00170 stdout_stream, stderr_stream, saga::task_base::Sync());
00171 return t.get_result<saga::job::job>();
00172 }
00174 SAGA_CALL_PUB_5_DEF_0(run_job, std::string, std::string,
00175 saga::job::ostream&, saga::job::istream&, saga::job::istream&)
00177
00178 job run_job(std::string commandline, std::string hostname = "")
00179 {
00180 saga::task t = run_jobpriv(commandline, hostname, saga::task_base::Sync());
00181 return t.get_result<saga::job::job>();
00182 }
00184 SAGA_CALL_PUB_2_DEF_1(run_job, std::string, std::string, "")
00186
00187
00188
00194 std::vector<std::string> list(void)
00195 {
00196 saga::task t = listpriv(saga::task_base::Sync());
00197 return t.get_result<std::vector<std::string> >();
00198 }
00199 SAGA_CALL_PUB_0_DEF_0(list)
00200
00201
00208 job get_job(std::string job_id)
00209 {
00210 saga::task t = get_jobpriv(job_id, saga::task_base::Sync());
00211 return t.get_result<saga::job::job>();
00212 }
00214 SAGA_CALL_PUB_1_DEF_0(get_job, std::string)
00216
00223 saga::job::self get_self()
00224 {
00225 saga::task t = get_selfpriv(saga::task_base::Sync());
00226 return t.get_result<saga::job::self>();
00227 }
00228 SAGA_CALL_PUB_0_DEF_0(get_self)
00229
00230 };
00231
00232 }
00233
00234 namespace detail
00235 {
00236
00237
00238
00239 template<>
00240 struct create_default<saga::job::service>
00241 {
00242 static saga::job::service* call()
00243 {
00244 return new saga::job::service(1);
00245 }
00246 template <typename T_> static void call(T_* obj)
00247 {
00248 new (obj) saga::job::service(1);
00249 }
00250 };
00251 }
00252
00253 }
00254
00256 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
00257 #pragma wave option(output: null)
00258 #endif
00259
00260 #endif // !defined(SAGA_DEBUG)
00261
00262
00263 #if defined(BOOST_MSVC)
00264 #pragma warning(pop)
00265 #endif
00266
00267 #endif // !defined(SAGA_PACKAGES_JOB_JOB_SERVICE_HPP)
00268