SAGA Adaptor CPI v.1.0
|
00001 // Copyright (c) 2005-2009 Hartmut Kaiser 00002 // 00003 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00005 00006 #ifndef SAGA_SAGA_DETAIL_MONITORABLE_IMPL_HPP 00007 #define SAGA_SAGA_DETAIL_MONITORABLE_IMPL_HPP 00008 00009 // include stl 00010 #include <vector> 00011 #include <string> 00012 00013 #include <saga/saga/metric.hpp> 00014 #include <saga/impl/exception.hpp> 00015 00016 // include dependent spec sections 00017 #include <saga/impl/engine/monitorable.hpp> 00018 #include <saga/saga/detail/monitorable.hpp> 00019 00020 // suppress warnings about dependent classes not being exported from the dll 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 // the monitorable API interface is implemented by this template 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 // introspection 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 // callback handling 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 } // namespace saga::detail 00093 00094 #endif // SAGA_SAGA_DETAIL_MONITORABLE_IMPL_HPP 00095