SAGA C++ API 1.6
util.hpp
Go to the documentation of this file.
00001 //  Copyright (c) 2005-2009 Hartmut Kaiser
00002 //  Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net)
00003 //  Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu)
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 
00009 /* BEGIN: Exclude from Doxygen */
00010 
00011 #ifndef SAGA_UTIL_HPP
00012 #define SAGA_UTIL_HPP
00013 
00014 #include <utility>
00015 #include <climits>
00016 #include <saga/saga/base.hpp>
00017 
00018 #include <boost/config.hpp>
00019 
00020 // Include Boost specific libraries we rely on in the interface, but which are 
00021 // _not_ replaceable by standard components. We use these as a convenience to 
00022 // avoid reimplementing bicycles. If independence from Boost some day will be a 
00023 // requirement these will have to be replaced.
00024 #include <boost/cstdint.hpp>
00025 
00026 // Include Boost specific libraries we rely on in the interface, but which
00027 // will be replaced by standard headers as soon as TR1 implementations will be
00028 // available more widely
00029 #if defined(SAGA_USE_TR1_NAMESPACE)
00030 
00031 #if defined(SAGA_PRINT_USED_NAMESPACE)
00032 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__DMC__)
00033 #pragma message("Note: using namespace std::tr1")
00034 #elif defined(__GNUC__) || defined(__HP_aCC) || defined(__SUNPRO_CC) || defined(__IBMCPP__)
00035 #warning "using namespace std::tr1"
00036 #endif
00037 #endif
00038 
00039 #include <type_traits>  // type traits
00040 #include <memory>       // shared_ptr, enable_shared_from_this
00041 #include <functional>   // function, ref, bind
00042 #include <regex>        // regex
00043 #include <array>        // array
00044 #define TR1 std::tr1    // define proper namespace
00045 #else
00046 
00047 #if defined(SAGA_PRINT_USED_NAMESPACE)
00048 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__DMC__)
00049 #pragma message("Note: using namespace boost")
00050 #elif defined(__GNUC__) || defined(__HP_aCC) || defined(__SUNPRO_CC) || defined(__IBMCPP__)
00051 #warning "using namespace boost"
00052 #endif
00053 #endif
00054 
00055 #include <boost/ref.hpp>
00056 #include <boost/bind.hpp>
00057 #include <boost/shared_ptr.hpp>
00058 #include <boost/weak_ptr.hpp>
00059 #include <boost/enable_shared_from_this.hpp>
00060 #include <boost/function.hpp>
00061 #include <boost/regex.hpp>
00062 #include <boost/array.hpp>
00063 #include <boost/type_traits/is_base_of.hpp>
00064 #include <boost/type_traits/is_reference.hpp>
00065 #include <boost/type_traits/remove_reference.hpp>
00066 #include <boost/type_traits/remove_pointer.hpp>
00067 #define TR1 boost       // define proper namespace
00068 
00069 // pull in bind placeholders into boost::placeholders
00070 
00071 
00072 namespace boost { namespace placeholders 
00073 {
00074     using ::_1;
00075     using ::_2;
00076     using ::_3;
00077     using ::_4;
00078     using ::_5;
00079     using ::_6;
00080     using ::_7;
00081     using ::_8;
00082     using ::_9;
00083 }}
00084 #endif
00085 
00086 #include <saga/saga/export_definitions.hpp>
00087 
00089 // maximum count of possible API parameters
00090 #ifndef SAGA_ARGUMENT_LIMIT
00091 #define SAGA_ARGUMENT_LIMIT  6              // default argument count limit
00092 #endif
00093 
00094 // make sure this file gets included before any of the Phoenix files
00095 #if defined(PHOENIX_LIMIT) && PHOENIX_LIMIT < 6
00096 # if defined(PHOENIX_TUPLES_HPP)
00097 #  error "This file should be included before any of the Phoenix includes, or #define PHOENIX_LIMIT >= 6."
00098 # else
00099 #  undef PHOENIX_LIMIT
00100 # endif
00101 #endif
00102 
00103 #if !defined(PHOENIX_LIMIT)
00104 # define PHOENIX_LIMIT SAGA_ARGUMENT_LIMIT   // tuple size limit
00105 #endif
00106 
00108 //  Character used to delimit several saga ini paths
00109 #ifdef BOOST_WINDOWS // windows
00110 #  define SAGA_INI_PATH_DELIMITER     ";"
00111 #  define SAGA_SHARED_LIB_EXTENSION   ".dll"
00112 #  define SAGA_PATH_DELIMITERS        "\\/"
00113 #else                // unix like
00114 #  define SAGA_INI_PATH_DELIMITER     ":"
00115 #  define SAGA_PATH_DELIMITERS        "/"
00116 #  ifdef SAGA_APPLE   // apple
00117 #    define SAGA_SHARED_LIB_EXTENSION ".dylib"
00118 #  else              // linux & co
00119 #    define SAGA_SHARED_LIB_EXTENSION ".so"
00120 #  endif
00121 #endif
00122 
00124 // define missing POSIX functions
00125 #if defined(BOOST_WINDOWS)
00126 #define snprintf _snprintf
00127 #endif
00128 
00130 // We don't need to export the plugins functions for SAGA lite
00131 #if defined(BUILD_SAGA_LITE)
00132 #define BOOST_PLUGIN_NO_EXPORT_API
00133 #endif
00134 
00136 // on Windows the debug versions of the libraries have mangled entry points 
00137 #if !defined(BOOST_WINDOWS)
00138 # define SAGA_MANGLE_ADAPTOR_NAME(name)        BOOST_PP_CAT(libsaga_adaptor_, name)
00139 # define SAGA_MANGLE_ADAPTOR_NAME_STR(name)    "libsaga_adaptor_" + name
00140 # define SAGA_MANGLE_PACKAGE_NAME(name)        BOOST_PP_CAT(libsaga_package_, name)
00141 # define SAGA_MANGLE_PACKAGE_NAME_STR(name)    "libsaga_package_" + name
00142 # define SAGA_MANGLE_ENGINE_NAME(name)         BOOST_PP_CAT(libsaga_, name)
00143 # define SAGA_MANGLE_ENGINE_NAME_STR(name)     "libsaga_" + name
00144 #elif defined(_DEBUG)
00145 # define SAGA_MANGLE_ADAPTOR_NAME(name)         BOOST_PP_CAT(name, d)
00146 # define SAGA_MANGLE_ADAPTOR_NAME_STR(name)     name + "d"
00147 # define SAGA_MANGLE_PACKAGE_NAME(name)         BOOST_PP_CAT(name, d)
00148 # define SAGA_MANGLE_PACKAGE_NAME_STR(name)     name + "d"
00149 # define SAGA_MANGLE_ENGINE_NAME(name)          BOOST_PP_CAT(saga_, BOOST_PP_CAT(name, d))
00150 # define SAGA_MANGLE_ENGINE_NAME_STR(name)      "saga_" + name + "d"
00151 #else
00152 # define SAGA_MANGLE_ADAPTOR_NAME(name)         name
00153 # define SAGA_MANGLE_ADAPTOR_NAME_STR(name)     name
00154 # define SAGA_MANGLE_PACKAGE_NAME(name)         name
00155 # define SAGA_MANGLE_PACKAGE_NAME_STR(name)     name
00156 # define SAGA_MANGLE_ENGINE_NAME(name)          BOOST_PP_CAT(saga_, name)
00157 # define SAGA_MANGLE_ENGINE_NAME_STR(name)      "saga_" + name
00158 #endif
00159 
00161 // some people like to have exception specifications, allow to use them if
00162 // SAGA_USE_EXCEPTION_SPECIFICATIONS is defined
00163 #if defined(SAGA_USE_EXCEPTION_SPECIFICATIONS)
00164 #define SAGA_THROW_SPEC(x) x
00165 #else
00166 #define SAGA_THROW_SPEC(x) 
00167 #endif
00168 
00170 // Make sure every module has a name
00171 #if !defined(SAGA_MODULE_NAME)
00172 # if defined(SAGA_PACKAGE_NAME)
00173 #   define SAGA_MODULE_NAME                 SAGA_PACKAGE_NAME
00174 #   define SAGA_MANGLED_MODULE_NAME         SAGA_MANGLE_PACKAGE_NAME(SAGA_PACKAGE_NAME)
00175 # elif defined(SAGA_ADAPTOR_NAME)
00176 #   define SAGA_MODULE_NAME                 SAGA_ADAPTOR_NAME
00177 #   define SAGA_MANGLED_MODULE_NAME         SAGA_MANGLE_ADAPTOR_NAME(SAGA_ADAPTOR_NAME)
00178 # elif defined(SAGA_ENGINE_EXPORTS)
00179 #   define SAGA_MODULE_NAME                 saga_core
00180 #   define SAGA_MANGLED_MODULE_NAME         SAGA_MANGLE_ENGINE_NAME(core)
00181 # else
00182 #   define SAGA_MODULE_NAME                 unknown
00183 #   define SAGA_MANGLED_MODULE_NAME         unknown
00184 # endif
00185 #endif
00186 
00187 #endif  // SAGA_UTIL_HPP
00188 
00190 /* END: Exclude from Doxygen */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines