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_HPP 00007 #define SAGA_SAGA_DETAIL_MONITORABLE_HPP 00008 00009 // include stl 00010 #include <vector> 00011 #include <string> 00012 00013 // include dependent spec sections 00014 #include <saga/saga/util.hpp> 00015 #include <saga/saga/base.hpp> 00016 #include <saga/saga/monitorable.hpp> 00017 00018 // For symbol import/export macros 00019 #include <saga/saga-defs.hpp> 00020 00021 // suppress warnings about dependent classes not being exported from the dll 00022 #if defined(BOOST_MSVC) 00023 #pragma warning(push) 00024 #pragma warning(disable : 4251 4231 4660) 00025 #endif 00026 00028 // for modules not belonging to the engine attributes should not be exported 00029 #if !defined (SAGA_CREATE_PREPROCESSED_FILES) && !defined(SAGA_EXPORT_MONITORABLE) 00030 00031 # if defined(SAGA_ENGINE_EXPORTS) || defined(SAGA_MONITORABLE_EXPORTS) 00032 # define SAGA_EXPORT_MONITORABLE SAGA_SYMBOL_EXPORT 00033 # elif !defined (SAGA_NO_IMPORT_MONITORABLE) && !defined(BUILD_SAGA_LITE) 00034 # define SAGA_EXPORT_MONITORABLE SAGA_SYMBOL_IMPORT 00035 # else 00036 # define SAGA_EXPORT_MONITORABLE /* empty */ 00037 # endif 00038 00039 #endif // !SAGA_CREATE_PREPROCESSED_FILES 00040 00042 namespace saga 00043 { 00044 namespace detail 00045 { 00046 00051 template <typename Derived> 00052 struct SAGA_EXPORT_MONITORABLE monitorable 00053 { 00058 typedef saga::monitorable::cookie_handle cookie_handle; 00059 00061 void init (std::vector <saga::metric> const & metrics); 00062 00063 Derived & derived (void) 00064 { 00065 return static_cast <Derived&> (*this); 00066 } 00067 00068 Derived const & derived (void) const 00069 { 00070 return static_cast <Derived const &> (*this); 00071 } 00073 00080 std::vector <saga::metric> list_metrics (void) const; 00081 00089 saga::metric get_metric (std::string name) const; 00090 00099 cookie_handle add_callback (std::string name, saga::callback cb); 00100 00108 void remove_callback (std::string name, cookie_handle cookie); 00109 }; 00110 } 00111 } // namespace saga::detail 00113 00114 #if defined(BOOST_MSVC) 00115 #pragma warning(pop) 00116 #endif 00117 00118 #endif // SAGA_SAGA_DETAIL_MONITORABLE_HPP 00119