#ifndef SAGA_IMPL_PACKAGES_JOB_JOB_HPP #define SAGA_IMPL_PACKAGES_JOB_JOB_HPP #if defined(__WAVE__) #pragma wave option(preserve: 2, line: 0, output: "preprocessed/job.hpp") #endif // Copyright (c) 2005-2007 Hartmut Kaiser (hartmut.kaiser@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if defined(__WAVE__) #pragma wave option(output: null) #endif #include #include #include #include #include #include #include // suppress warnings about dependent classes not being exported from the dll #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable: 4251 4231 4275 4660) #endif #ifdef SAGA_DEBUG #include #else #if defined(__WAVE__) #pragma wave option(output: "preprocessed/job.hpp") #endif /////////////////////////////////////////////////////////////////////////////// namespace saga { namespace impl { /** * This class acts as a proxy class, hiding all the nasty Saga stuff * (like creating and using adaptors) for the user. Users just call * the functions of this class like to would on every local object, * and don't have to worry about adaptors. It extends saga::job_cpi. * * Note, the impl::job class is somewhat specific as it represents a * task (wrapping the job_service::create_job() function) and at the same * time it is a proxy for job CPI's. */ class job : public saga::impl::task_base, public saga::impl::proxy, public saga::impl::attribute { typedef v1_0::job_cpi job_cpi; typedef v1_0::preference_type preference_type; private: // implement task interface by the means of the job_cpi int run() { saga::void_t r; run(r, true); return 1; } void cancel() { saga::void_t r; cancel(r, true); } bool wait(double timeout) { bool r; wait(r, timeout, true); return r; } // initialize newly attached CPI instance void init(); public: /** * Constructor of job */ job (std::string rm, saga::job_description jd, saga::session const& s, TR1::shared_ptr cpi_instance); job (std::string rm, std::string jobid, saga::session const& s, TR1::shared_ptr cpi_instance); /*! destructor of job, destroys job and the adaptor it is * bound to */ ~job (void); // task interface SAGA_CALL_IMPL_DECL_0 (saga::void_t, run) SAGA_CALL_IMPL_DECL_0 (saga::void_t, cancel) SAGA_CALL_IMPL_DECL_1 (bool, wait, double) // job inspection SAGA_CALL_IMPL_DECL_0 (std::string, get_job_id) SAGA_CALL_IMPL_DECL_0 (saga::job::state, get_state) SAGA_CALL_IMPL_DECL_0 (std::string, get_state_detail) SAGA_CALL_IMPL_DECL_0 (saga::job_description, get_job_description) SAGA_CALL_IMPL_DECL_0 (saga::ostream, get_stdin) SAGA_CALL_IMPL_DECL_0 (saga::istream, get_stdout) SAGA_CALL_IMPL_DECL_0 (saga::istream, get_stderr) // job management SAGA_CALL_IMPL_DECL_0 (saga::void_t, suspend) SAGA_CALL_IMPL_DECL_0 (saga::void_t, resume) SAGA_CALL_IMPL_DECL_0 (saga::void_t, checkpoint) SAGA_CALL_IMPL_DECL_2 (saga::void_t, migrate, saga::job_description, std::string) SAGA_CALL_IMPL_DECL_1 (saga::void_t, signal, int) /////////////////////////////////////////////////////////////////////// // return the task_interface to the facade saga::impl::task_interface* get_task_interface() { return this; } saga::impl::task_interface const* get_task_interface() const { return this; } /////////////////////////////////////////////////////////////////////// // return the monitorable interface to the facade saga::impl::monitorable* get_monitorable() { return this; } saga::impl::monitorable const* get_monitorable() const { return this; } /////////////////////////////////////////////////////////////////////// // return the attribute interface to the facade saga::impl::attribute* get_attributes() { return this; } saga::impl::attribute const* get_attributes() const { return this; } /////////////////////////////////////////////////////////////////////// // return the object interface to the facade saga::impl::proxy* get_proxy() { return this; } saga::impl::proxy const* get_proxy() const { return this; } virtual saga::uuid get_id() const { return this->get_uuid(); } }; /////////////////////////////////////////////////////////////////////////////// }} // namespace saga::impl #if defined(__WAVE__) #pragma wave option(output: null) #endif #endif // !defined(SAGA_DEBUG) // re-enable warnings about dependent classes not being exported from the dll #if defined(BOOST_MSVC) #pragma warning(pop) #endif #endif // !defined(SAGA_IMPL_PACKAGES_JOB_JOB_HPP)