Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef SAGA_SAGA_DETAIL_MONITORABLE_IMPL_HPP
00007 #define SAGA_SAGA_DETAIL_MONITORABLE_IMPL_HPP
00008
00009
00010 #include <vector>
00011 #include <string>
00012
00013 #include <saga/saga/metric.hpp>
00014 #include <saga/impl/exception.hpp>
00015
00016
00017 #include <saga/impl/engine/monitorable.hpp>
00018 #include <saga/saga/detail/monitorable.hpp>
00019
00020
00021 #if defined(BOOST_MSVC)
00022 #pragma warning(push)
00023 #pragma warning(disable : 4251 4231 4660)
00024 #endif
00025
00027 namespace saga
00028 {
00029 namespace detail
00030 {
00031
00032 template <typename Derived>
00033 void
00034 monitorable <Derived>::init (std::vector <saga::metric> const & metrics)
00035 {
00036 if (!derived().is_impl_valid()) {
00037 SAGA_THROW("The object has not been properly initialized.",
00038 saga::IncorrectState);
00039 }
00040 derived().get_impl()->get_monitorable()->add_metrics_to_metrics (metrics);
00041 }
00042
00043
00044 template <typename Derived>
00045 inline std::vector <saga::metric>
00046 monitorable <Derived>::list_metrics (void) const
00047 {
00048 if (!derived().is_impl_valid()) {
00049 SAGA_THROW("The object has not been properly initialized.",
00050 saga::IncorrectState);
00051 }
00052 return derived().get_impl()->get_monitorable()->list_metrics ();
00053 }
00054
00055 template <typename Derived>
00056 inline saga::metric
00057 monitorable <Derived>::get_metric (std::string name) const
00058 {
00059 if (!derived().is_impl_valid()) {
00060 SAGA_THROW("The object has not been properly initialized.",
00061 saga::IncorrectState);
00062 }
00063 return derived().get_impl()->get_monitorable()->get_metric (name);
00064 }
00065
00066
00067 template <typename Derived>
00068 inline saga::monitorable::cookie_handle
00069 monitorable <Derived>::add_callback (std::string name, saga::callback cb)
00070 {
00071 if (!derived().is_impl_valid()) {
00072 SAGA_THROW("The object has not been properly initialized.",
00073 saga::IncorrectState);
00074 }
00075 return derived().get_impl()->get_monitorable()->add_callback (name, cb);
00076 }
00077
00078 template <typename Derived>
00079 inline void
00080 monitorable <Derived>::remove_callback (std::string name,
00081 saga::monitorable::cookie_handle cookie)
00082 {
00083 if (!derived().is_impl_valid()) {
00084 SAGA_THROW("The object has not been properly initialized.",
00085 saga::IncorrectState);
00086 }
00087 derived().get_impl()->get_monitorable()->remove_callback (name, cookie);
00088 }
00089
00090 }
00091 }
00093
00094 #endif // SAGA_SAGA_DETAIL_MONITORABLE_IMPL_HPP
00095