SAGA C++ API 1.6
|
00001 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00002 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/cpr_job.cpp") 00003 #endif 00004 // Copyright (c) 2005-2009 Hartmut Kaiser 00005 // Copyright (c) 2008 Andre Merzky (andre@merzky.net) 00006 // 00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00009 00010 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00011 #pragma wave option(output: null) 00012 #endif 00013 00014 // this is needed in every file including detail/attribute_impl.hpp and not 00015 // belonging to the engine 00016 #define SAGA_NO_IMPORT_ATTRIBUTE 00017 #define SAGA_EXPORT_ATTRIBUTE SAGA_CPR_PACKAGE_EXPORT 00018 00019 #define SAGA_NO_IMPORT_PERMISSIONS 00020 #define SAGA_EXPORT_PERMISSIONS SAGA_CPR_PACKAGE_EXPORT 00021 00022 #include <boost/assign/list_inserter.hpp> 00023 #include <boost/assign/std/vector.hpp> 00024 00025 // include cpr API and implementation 00026 #include <saga/saga/cpr.hpp> 00027 #include <saga/impl/cpr.hpp> 00028 #include <saga/saga/detail/call.hpp> 00029 00030 #include <saga/saga/detail/attribute_impl.hpp> 00031 #include <saga/saga/detail/permissions_impl.hpp> 00032 00033 #ifdef SAGA_DEBUG 00034 #include <saga/saga/packages/cpr/preprocessed/cpr_job.cpp> 00035 #else 00036 00037 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES) 00038 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/cpr_job.cpp") 00039 #endif 00040 00041 namespace saga 00042 { 00043 namespace cpr 00044 { 00045 namespace metrics 00046 { 00048 saga::metrics::init_data const metric_data[] = 00049 { 00050 // FIXME: are we inherting metrics from job? 00051 // additional metrics for a cpr::job 00052 { 00053 saga::cpr::metrics::checkpoint, 00054 "metric fires when application level checkpoint is requested.", 00055 saga::attributes::metric_mode_readonly, 00056 "STRING", 00057 saga::attributes::metric_type_string, 00058 "" 00059 }, 00060 { 00061 saga::cpr::metrics::checkpointed, 00062 "metric fires when application level checkpoint is finished.", 00063 saga::attributes::metric_mode_readonly, 00064 "TRIGGER", 00065 saga::attributes::metric_type_trigger, 00066 "" 00067 }, 00068 { 00069 saga::cpr::metrics::recover, 00070 "metric fires when application level recover is requested.", 00071 saga::attributes::metric_mode_readonly, 00072 "STRING", 00073 saga::attributes::metric_type_string, 00074 "" 00075 }, 00076 { 00077 saga::cpr::metrics::recovered, 00078 "metric fires when application level recover is finished.", 00079 saga::attributes::metric_mode_readonly, 00080 "TRIGGER", 00081 saga::attributes::metric_type_trigger, 00082 "" 00083 } 00084 }; 00086 00087 } 00088 00089 00090 00092 job::job() 00093 { 00094 } 00095 00096 job::job(saga::impl::cpr_job* impl) 00097 : saga::job::job (impl) 00098 { 00099 SAGA_LOG_BLURB("saga::cpr::job ctor start"); 00100 using namespace boost::assign; 00101 00102 // initialize metrics 00103 std::vector<saga::metric> metrics; 00104 for (unsigned int i = 0; 00105 i < sizeof(saga::cpr::metrics::metric_data)/sizeof(saga::metrics::init_data); 00106 ++i) 00107 { 00108 saga::metrics::init_data const* p = &saga::cpr::metrics::metric_data[i]; 00109 saga::metric m(*this, p->name, p->description, p->mode, p->unit, 00110 p->type, p->value); 00111 metrics.push_back(m); 00112 } 00113 this->monitorable_base::init (metrics); 00114 00115 SAGA_LOG_BLURB("saga::cpr::job ctor done"); 00116 } 00117 00118 job::~job (void) 00119 { 00120 } 00121 00123 job::job (saga::object const& o) 00124 : saga::job::job (o) 00125 { 00126 if (this->get_type() != saga::object::CPRJob) 00127 { 00128 SAGA_THROW("Bad type conversion.", saga::BadParameter); 00129 } 00130 } 00131 00132 job &job::operator= (saga::object const& o) 00133 { 00134 return saga::job::job::operator=(o), *this; 00135 } 00136 00138 saga::impl::cpr_job* job::get_impl() const 00139 { 00140 typedef saga::object base_type; 00141 return static_cast<saga::impl::cpr_job*>(this->base_type::get_impl()); 00142 } 00143 00144 TR1::shared_ptr <saga::impl::cpr_job> job::get_impl_sp(void) const 00145 { 00146 // FIXME: this needs documentation 00147 typedef saga::object base_type; 00148 return TR1::static_pointer_cast <saga::impl::cpr_job> ( 00149 this->base_type::get_impl_sp()); 00150 } 00151 00152 // job cpr management 00154 SAGA_CALL_IMP_1 (job, checkpoint, saga::url); 00155 SAGA_CALL_IMP_1 (job, recover, saga::url); 00156 00157 SAGA_CALL_IMP_1 (job, cpr_stage_in, saga::url); 00158 SAGA_CALL_IMP_1 (job, cpr_stage_out, saga::url); 00159 00160 SAGA_CALL_IMP_0 (job, cpr_list); 00161 SAGA_CALL_IMP_0 (job, cpr_last); 00163 } // namspace cpr 00164 00165 } // namespace saga 00167 00168 #endif 00169