00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SAGA_METRIC_HPP
00009 #define SAGA_METRIC_HPP
00010
00011
00012 #include <map>
00013 #include <string>
00014 #include <vector>
00015
00016
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
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
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
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
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
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>;
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,
00108 Descreet = 1,
00109 Pull = 2,
00110 Push = 3,
00111 Event = 4
00112 };
00113
00118 typedef saga::monitorable::cookie_handle metric_cookie;
00119
00124 metric (void);
00125
00130 explicit metric (saga::object const& o);
00131
00136
00137
00138
00139
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 }
00189
00190
00191 #if defined(BOOST_MSVC)
00192 #pragma warning(pop)
00193 #endif
00194
00195 #endif // SAGA_METRIC_HPP
00196
00197