SAGA Adaptor CPI v.1.0
|
00001 // Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net) 00002 // Copyright (c) 2005-2009 Hartmut Kaiser 00003 // Copyright (c) 2005 Michel Zandstra (michelzandstra@gmail.com) 00004 // 00005 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00006 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00007 00008 #ifndef SAGA_IMPL_ENGINE_BASE_HPP 00009 #define SAGA_IMPL_ENGINE_BASE_HPP 00010 00011 #include <cstdlib> 00012 #include <cstddef> 00013 00014 #include <saga/saga/export_definitions.hpp> 00015 #include <saga/saga/detail.hpp> 00016 00017 #include <boost/logging/format/named_write_fwd.hpp> 00018 #include <boost/logging/format_fwd.hpp> 00019 00020 BOOST_LOG_FORMAT_MSG(optimize::cache_string_one_str<>) 00021 00022 00023 #define SAGA_CPIVERSION_1_0 0x0100 00024 #define SAGA_CPIVERSION_MINORMASK 0x000F 00025 #define SAGA_CPIVERSION_LATEST SAGA_CPIVERSION_1_0 00026 00028 00030 00031 namespace saga 00032 { 00033 namespace adaptors 00034 { 00035 class task; 00036 class attribute; 00037 class metric; 00038 class exception; 00039 } 00040 00041 // forward declaration for implementation 00042 namespace impl 00043 { 00044 struct runtime; 00045 struct job_runtime; 00046 class exception; 00047 00048 class url; 00049 class uuid; 00050 class const_buffer; 00051 class buffer; 00052 00053 class object; 00054 class session; 00055 class context; 00056 class attribute; 00057 class permissions; 00058 struct permissions_interface; 00059 00060 struct task_interface; 00061 class task_base; 00062 class task_container; 00063 class adaptor_selector_state; 00064 00065 class namespace_entry; 00066 class namespace_dir; 00067 00068 class directory; 00069 class file; 00070 class const_iovec; 00071 class iovec; 00072 00073 class logical_directory; 00074 class logical_file; 00075 00076 class advert; 00077 class advert_directory; 00078 00079 class rpc; 00080 class parameter; 00081 00082 class stream; 00083 class server; 00084 00085 class job; 00086 class self; 00087 class job_service; 00088 class description; 00089 class istream_interface; 00090 class ostream_interface; 00091 00092 class service_description; 00093 class service_data; 00094 class discoverer; 00095 00096 class cpr_job; 00097 class cpr_job_service; 00098 class cpr_checkpoint; 00099 class cpr_directory; 00100 class cpr_job_description; 00101 00102 class metric; 00103 // class monitor; 00104 // class actor; 00105 00106 class adaptor_selector; 00107 00108 class proxy; 00109 00110 namespace v1_0 00111 { 00112 class cpi; 00113 class cpi_info; 00114 class op_info; 00115 } 00116 00117 // interfaces 00118 class attribute; 00119 class monitorable; 00120 class steerable; 00121 struct task_interface; 00122 00123 // exception handling 00124 class exception_list; 00125 00126 // special void class 00127 struct void_t {}; 00128 } // namespace impl 00129 00130 namespace ini 00131 { 00132 class section; 00133 } 00134 } // namespace saga 00135 00137 00139 // 00140 // Macros for verbose and debug output 00141 // 00142 00143 namespace saga { namespace impl 00144 { 00146 SAGA_EXPORT std::string levelname(int level); 00147 SAGA_EXPORT std::string logging_filename(char const* filename, int lineno); 00148 SAGA_EXPORT std::vector<std::string> const& get_logging_init_data(); 00149 SAGA_EXPORT void init_logging(saga::ini::section const& ini); 00150 00152 typedef boost::logging::named_logger<>::type logger_type; 00153 typedef boost::logging::level::holder filter_type; 00154 00156 SAGA_EXPORT BOOST_DECLARE_LOG_FILTER(logger_level, filter_type) 00157 SAGA_EXPORT BOOST_DECLARE_LOG(logger, logger_type) 00158 }} 00159 00161 #define SAGA_LOG(lvl) BOOST_LOG_USE_LOG_IF_LEVEL( \ 00162 saga::impl::logger(), saga::impl::logger_level(), lvl) \ 00163 << saga::impl::levelname(::boost::logging::level::lvl) << " " \ 00164 << saga::impl::logging_filename(__FILE__, __LINE__) << " " \ 00165 00166 00167 #define SAGA_VERBOSE(lvl) \ 00168 if (saga::impl::logger_level()->is_enabled(::boost::logging::level::lvl)) \ 00169 00170 00172 #define SAGA_LOG_ALWAYS(msg) \ 00173 SAGA_LOG(SAGA_VERBOSE_LEVEL_ALWAYS) << msg; \ 00174 00175 00176 #define SAGA_LOG_CRITICAL(msg) \ 00177 SAGA_LOG(SAGA_VERBOSE_LEVEL_CRITICAL) << msg; \ 00178 00179 00180 #define SAGA_LOG_ERROR(msg) \ 00181 SAGA_LOG(SAGA_VERBOSE_LEVEL_ERROR) << msg; \ 00182 00183 00184 #define SAGA_LOG_WARN(msg) \ 00185 SAGA_LOG(SAGA_VERBOSE_LEVEL_WARNING) << msg; \ 00186 00187 00188 #define SAGA_LOG_INFO(msg) \ 00189 SAGA_LOG(SAGA_VERBOSE_LEVEL_INFO) << msg; \ 00190 00191 00192 #define SAGA_LOG_DEBUG(msg) \ 00193 SAGA_LOG(SAGA_VERBOSE_LEVEL_DEBUG) << msg; \ 00194 00195 00196 #define SAGA_LOG_BLURB(msg) \ 00197 SAGA_LOG(SAGA_VERBOSE_LEVEL_BLURB) << msg; \ 00198 00199 00200 #define SAGA_VERBOSE_LEVEL_ALWAYS enable_all 00201 #define SAGA_VERBOSE_LEVEL_CRITICAL fatal 00202 #define SAGA_VERBOSE_LEVEL_ERROR error 00203 #define SAGA_VERBOSE_LEVEL_WARNING warning 00204 #define SAGA_VERBOSE_LEVEL_INFO info 00205 #define SAGA_VERBOSE_LEVEL_DEBUG debug 00206 #define SAGA_VERBOSE_LEVEL_BLURB debug 00207 00209 // Helper macros/functions to overcome the lack of stringstream on certain 00210 // architectures 00211 #ifdef BOOST_NO_STRINGSTREAM 00212 # include <strstream> 00213 inline std::string SAGA_OSSTREAM_GETSTRING (std::ostrstream & ss) 00214 { 00215 ss << std::ends; 00216 std::string rval = ss.str (); 00217 ss.freeze (false); 00218 return (rval); 00219 } 00220 # define SAGA_OSSTREAM std::ostrstream 00221 # define SAGA_ISSTREAM std::istrstream 00222 #else 00223 # include <sstream> 00224 # define SAGA_OSSTREAM_GETSTRING(ss) ss.str() 00225 # define SAGA_OSSTREAM std::ostringstream 00226 # define SAGA_ISSTREAM std::istringstream 00227 #endif 00228 00230 #if defined(__AIX__) && defined(__GNUC__) 00231 // we must call the initialization functions of the shared libraries ourselves, 00232 // because AIX's dlopen() system call does not know about it. 00233 extern "C" { 00234 void _GLOBAL__DI(); // call constructors of all global objects 00235 void _GLOBAL__DD(); // call destructors of all global objects 00236 } 00237 #endif 00238 00239 #endif // SAGA_IMPL_ENGINE_BASE_HPP 00240 00241