SAGA Adaptor CPI v.1.0
|
00001 // Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net) 00002 // Copyright (c) 2005-2009 Hartmut Kaiser 00003 // Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu) 00004 // 00005 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00006 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00007 00008 #ifndef SAGA_METRIC_HPP 00009 #define SAGA_METRIC_HPP 00010 00011 // include stl 00012 #include <map> 00013 #include <string> 00014 #include <vector> 00015 00016 // include dependent spec sections 00017 #include <saga/saga/util.hpp> 00018 #include <saga/saga/base.hpp> 00019 #include <saga/saga/monitorable.hpp> 00020 #include <saga/saga/session.hpp> 00021 #include <saga/saga/context.hpp> 00022 #include <saga/saga/detail/attribute.hpp> 00023 00024 // suppress warnings about dependent classes not being exported from the dll 00025 #if defined(BOOST_MSVC) 00026 #pragma warning(push) 00027 #pragma warning(disable: 4251 4231 4660) 00028 #endif 00029 00031 namespace saga 00032 { 00033 namespace attributes 00034 { 00036 // attribute names for metric 00037 char const* const metric_name = "Name"; 00038 char const* const metric_description = "Description"; 00039 char const* const metric_mode = "Mode"; 00040 char const* const metric_unit = "Unit"; 00041 char const* const metric_type = "Type"; 00042 char const* const metric_value = "Value"; 00043 00045 // attribute values for metric's type attribute 00046 char const* const metric_type_string = "String"; 00047 char const* const metric_type_int = "Int"; 00048 char const* const metric_type_enum = "Enum"; 00049 char const* const metric_type_float = "Float"; 00050 char const* const metric_type_bool = "Bool"; 00051 char const* const metric_type_time = "Time"; 00052 char const* const metric_type_trigger = "Trigger"; 00053 00055 // attribute values for metric's mode attribute 00056 char const* const metric_mode_readonly = "ReadOnly"; 00057 char const* const metric_mode_readwrite = "ReadWrite"; 00058 char const* const metric_mode_final = "Final"; 00059 00060 } 00061 00064 namespace metrics 00065 { 00067 // initialization data for list of metrics 00068 struct init_data 00069 { 00070 char const* const name; 00071 char const* const description; 00072 char const* const mode; 00073 char const* const unit; 00074 char const* const type; 00075 char const* const value; 00076 }; 00077 } 00079 00084 class SAGA_EXPORT metric 00085 : public saga::object, 00086 public saga::detail::attribute<metric> 00087 { 00088 protected: 00090 TR1::shared_ptr <saga::impl::metric> get_impl_sp (void) const; 00091 saga::impl::metric* get_impl (void) const; 00092 00093 friend struct saga::detail::attribute<metric>; // needs to access get_impl() 00094 friend class saga::impl::metric; 00095 00096 explicit metric(saga::impl::metric *impl); 00098 00099 public: 00104 enum frequency 00105 { 00106 Unknown = -1, 00107 Cont = 0, // always available 00108 Descreet = 1, // available at specific intervals 00109 Pull = 2, // available when asked for 00110 Push = 3, // available when set 00111 Event = 4 // available when a specific event occurs 00112 }; 00113 00118 typedef saga::monitorable::cookie_handle metric_cookie; 00119 00124 metric (void); 00125 00130 explicit metric (saga::object const& o); 00131 00136 // FIXME: the spec does not say anything about a target object parameter. 00137 // In fact, a metric should be usable on multiple objects. For example, an 00138 // application may want to add the same metrics to several steerable 00139 // job instances. 00140 metric (saga::object target, 00141 std::string name, std::string desc, std::string mode, 00142 std::string unit, std::string type, std::string val); 00143 00148 ~metric (void); 00149 00154 metric &operator= (saga::object const& o); 00155 00160 void fire (saga::context ctx = saga::context()); 00161 00166 metric_cookie add_callback (saga::callback f); 00167 00172 void remove_callback (metric_cookie cookie); 00173 00178 friend SAGA_EXPORT 00179 bool operator== (metric const & lhs, metric const & rhs); 00180 00181 }; 00183 00184 typedef std::vector <saga::metric> metric_list_type; 00186 00187 } // namespace saga 00189 00190 // re-enable warnings about dependent classes not being exported from the dll 00191 #if defined(BOOST_MSVC) 00192 #pragma warning(pop) 00193 #endif 00194 00195 #endif // SAGA_METRIC_HPP 00196 00197