| 1 |
// Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net) |
|---|
| 2 |
// Copyright (c) 2005-2009 Hartmut Kaiser |
|---|
| 3 |
// Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu) |
|---|
| 4 |
// |
|---|
| 5 |
// Distributed under the Boost Software License, Version 1.0. (See accompanying |
|---|
| 6 |
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 7 |
|
|---|
| 8 |
#ifndef SAGA_METRIC_HPP |
|---|
| 9 |
#define SAGA_METRIC_HPP |
|---|
| 10 |
|
|---|
| 11 |
// include stl |
|---|
| 12 |
#include <map> |
|---|
| 13 |
#include <string> |
|---|
| 14 |
#include <vector> |
|---|
| 15 |
|
|---|
| 16 |
// include dependent spec sections |
|---|
| 17 |
#include <saga/saga/util.hpp> |
|---|
| 18 |
#include <saga/saga/base.hpp> |
|---|
| 19 |
#include <saga/saga/monitorable.hpp> |
|---|
| 20 |
#include <saga/saga/session.hpp> |
|---|
| 21 |
#include <saga/saga/context.hpp> |
|---|
| 22 |
#include <saga/saga/detail/attribute.hpp> |
|---|
| 23 |
|
|---|
| 24 |
// suppress warnings about dependent classes not being exported from the dll |
|---|
| 25 |
#if defined(BOOST_MSVC) |
|---|
| 26 |
#pragma warning(push) |
|---|
| 27 |
#pragma warning(disable: 4251 4231 4660) |
|---|
| 28 |
#endif |
|---|
| 29 |
|
|---|
| 30 |
/////////////////////////////////////////////////////////////////////////////// |
|---|
| 31 |
namespace saga |
|---|
| 32 |
{ |
|---|
| 33 |
namespace attributes |
|---|
| 34 |
{ |
|---|
| 35 |
/////////////////////////////////////////////////////////////////////////// |
|---|
| 36 |
// attribute names for metric |
|---|
| 37 |
char const* const metric_name = "Name"; |
|---|
| 38 |
char const* const metric_description = "Description"; |
|---|
| 39 |
char const* const metric_mode = "Mode"; |
|---|
| 40 |
char const* const metric_unit = "Unit"; |
|---|
| 41 |
char const* const metric_type = "Type"; |
|---|
| 42 |
char const* const metric_value = "Value"; |
|---|
| 43 |
|
|---|
| 44 |
/////////////////////////////////////////////////////////////////////////// |
|---|
| 45 |
// attribute values for metric's type attribute |
|---|
| 46 |
char const* const metric_type_string = "String"; |
|---|
| 47 |
char const* const metric_type_int = "Int"; |
|---|
| 48 |
char const* const metric_type_enum = "Enum"; |
|---|
| 49 |
char const* const metric_type_float = "Float"; |
|---|
| 50 |
char const* const metric_type_bool = "Bool"; |
|---|
| 51 |
char const* const metric_type_time = "Time"; |
|---|
| 52 |
char const* const metric_type_trigger = "Trigger"; |
|---|
| 53 |
|
|---|
| 54 |
/////////////////////////////////////////////////////////////////////////// |
|---|
| 55 |
// attribute values for metric's mode attribute |
|---|
| 56 |
char const* const metric_mode_readonly = "ReadOnly"; |
|---|
| 57 |
char const* const metric_mode_readwrite = "ReadWrite"; |
|---|
| 58 |
char const* const metric_mode_final = "Final"; |
|---|
| 59 |
|
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
///@cond |
|---|
| 63 |
///////////////////////////////////////////////////////////////////////////// |
|---|
| 64 |
namespace metrics |
|---|
| 65 |
{ |
|---|
| 66 |
///////////////////////////////////////////////////////////////////////// |
|---|
| 67 |
// initialization data for list of metrics |
|---|
| 68 |
struct init_data |
|---|
| 69 |
{ |
|---|
| 70 |
char const* const name; |
|---|
| 71 |
char const* const description; |
|---|
| 72 |
char const* const mode; |
|---|
| 73 |
char const* const unit; |
|---|
| 74 |
char const* const type; |
|---|
| 75 |
char const* const value; |
|---|
| 76 |
}; |
|---|
| 77 |
} |
|---|
| 78 |
///@endcond |
|---|
| 79 |
|
|---|
| 80 |
/*! \brief Brief %description starts here |
|---|
| 81 |
* |
|---|
| 82 |
* |
|---|
| 83 |
*/ |
|---|
| 84 |
class SAGA_EXPORT metric |
|---|
| 85 |
: public saga::object, |
|---|
| 86 |
public saga::detail::attribute<metric> |
|---|
| 87 |
{ |
|---|
| 88 |
protected: |
|---|
| 89 |
/// @cond |
|---|
| 90 |
TR1::shared_ptr <saga::impl::metric> get_impl (void) const; |
|---|
| 91 |
|
|---|
| 92 |
friend struct saga::detail::attribute<metric>; // needs to access get_impl() |
|---|
| 93 |
friend class saga::impl::metric; |
|---|
| 94 |
|
|---|
| 95 |
explicit metric(saga::impl::metric *impl); |
|---|
| 96 |
/// @endcond |
|---|
| 97 |
|
|---|
| 98 |
public: |
|---|
| 99 |
/*! \brief Brief %description starts here |
|---|
| 100 |
* |
|---|
| 101 |
* |
|---|
| 102 |
*/ |
|---|
| 103 |
enum frequency |
|---|
| 104 |
{ |
|---|
| 105 |
Unknown = -1, |
|---|
| 106 |
Cont = 0, // always available |
|---|
| 107 |
Descreet = 1, // available at specific intervals |
|---|
| 108 |
Pull = 2, // available when asked for |
|---|
| 109 |
Push = 3, // available when set |
|---|
| 110 |
Event = 4 // available when a specific event occurs |
|---|
| 111 |
}; |
|---|
| 112 |
|
|---|
| 113 |
/*! \brief Brief %description starts here |
|---|
| 114 |
* |
|---|
| 115 |
* |
|---|
| 116 |
*/ |
|---|
| 117 |
typedef saga::monitorable::cookie_handle metric_cookie; |
|---|
| 118 |
|
|---|
| 119 |
/*! \brief Brief %description starts here |
|---|
| 120 |
* |
|---|
| 121 |
* |
|---|
| 122 |
*/ |
|---|
| 123 |
metric (void); |
|---|
| 124 |
|
|---|
| 125 |
/*! \brief Brief %description starts here |
|---|
| 126 |
* |
|---|
| 127 |
* |
|---|
| 128 |
*/ |
|---|
| 129 |
explicit metric (saga::object const& o); |
|---|
| 130 |
|
|---|
| 131 |
/*! \brief Brief %description starts here |
|---|
| 132 |
* |
|---|
| 133 |
* |
|---|
| 134 |
*/ |
|---|
| 135 |
metric (saga::object target, |
|---|
| 136 |
std::string name, std::string desc, std::string mode, |
|---|
| 137 |
std::string unit, std::string type, std::string val); |
|---|
| 138 |
|
|---|
| 139 |
/*! \brief Brief %description starts here |
|---|
| 140 |
* |
|---|
| 141 |
* |
|---|
| 142 |
*/ |
|---|
| 143 |
~metric (void); |
|---|
| 144 |
|
|---|
| 145 |
/*! \brief Brief %description starts here |
|---|
| 146 |
* |
|---|
| 147 |
* |
|---|
| 148 |
*/ |
|---|
| 149 |
metric &operator= (saga::object const& o); |
|---|
| 150 |
|
|---|
| 151 |
/*! \brief Brief %description starts here |
|---|
| 152 |
* |
|---|
| 153 |
* |
|---|
| 154 |
*/ |
|---|
| 155 |
void fire (saga::context ctx = saga::context()); |
|---|
| 156 |
|
|---|
| 157 |
/*! \brief Brief %description starts here |
|---|
| 158 |
* |
|---|
| 159 |
* |
|---|
| 160 |
*/ |
|---|
| 161 |
metric_cookie add_callback (saga::callback f); |
|---|
| 162 |
|
|---|
| 163 |
/*! \brief Brief %description starts here |
|---|
| 164 |
* |
|---|
| 165 |
* |
|---|
| 166 |
*/ |
|---|
| 167 |
void remove_callback (metric_cookie cookie); |
|---|
| 168 |
|
|---|
| 169 |
/*! \brief Brief %description starts here |
|---|
| 170 |
* |
|---|
| 171 |
* |
|---|
| 172 |
*/ |
|---|
| 173 |
friend SAGA_EXPORT |
|---|
| 174 |
bool operator== (metric const & lhs, metric const & rhs); |
|---|
| 175 |
|
|---|
| 176 |
}; |
|---|
| 177 |
/// @cond |
|---|
| 178 |
/** These methods are not within API scope */ |
|---|
| 179 |
typedef std::vector <saga::metric> metric_list_type; |
|---|
| 180 |
/// @endcond |
|---|
| 181 |
|
|---|
| 182 |
} // namespace saga |
|---|
| 183 |
/////////////////////////////////////////////////////////////////////////////// |
|---|
| 184 |
|
|---|
| 185 |
// re-enable warnings about dependent classes not being exported from the dll |
|---|
| 186 |
#if defined(BOOST_MSVC) |
|---|
| 187 |
#pragma warning(pop) |
|---|
| 188 |
#endif |
|---|
| 189 |
|
|---|
| 190 |
#endif // SAGA_METRIC_HPP |
|---|
| 191 |
|
|---|
| 192 |
|
|---|