/usr/include/opengm/opengm.hxx is in libopengm-dev 2.3.6-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | #pragma once
#ifndef OPENGM_HXX
#define OPENGM_HXX
#include <stdexcept>
#include <sstream>
#include "opengm/config.hxx"
#include "opengm/utilities/metaprogramming.hxx"
// as runtime assertion but cefined even if NDEBUG
#define OPENGM_CHECK_OP(a,op,b,message) \
if(! static_cast<bool>( a op b ) ) { \
std::stringstream s; \
s << "OpenGM Error: "<< message <<"\n";\
s << "OpenGM check : " << #a <<#op <<#b<< " failed:\n"; \
s << #a " = "<<a<<"\n"; \
s << #b " = "<<b<<"\n"; \
s << "in file " << __FILE__ << ", line " << __LINE__ << "\n"; \
throw std::runtime_error(s.str()); \
}
#define OPENGM_CHECK(expression,message) if(!(expression)) { \
std::stringstream s; \
s << message <<"\n";\
s << "OpenGM assertion " << #expression \
<< " failed in file " << __FILE__ \
<< ", line " << __LINE__ << std::endl; \
throw std::runtime_error(s.str()); \
}
/// runtime assertion
#ifdef NDEBUG
#ifndef OPENGM_DEBUG
#define OPENGM_ASSERT_OP(a,op,b) { }
#else
#define OPENGM_ASSERT_OP(a,op,b) \
if(! static_cast<bool>( a op b ) ) { \
std::stringstream s; \
s << "OpenGM assertion : " << #a <<#op <<#b<< " failed:\n"; \
s << #a " = "<<a<<"\n"; \
s << #b " = "<<b<<"\n"; \
s << "in file " << __FILE__ << ", line " << __LINE__ << "\n"; \
throw std::runtime_error(s.str()); \
}
#endif
#else
#define OPENGM_ASSERT_OP(a,op,b) \
if(! static_cast<bool>( a op b ) ) { \
std::stringstream s; \
s << "OpenGM assertion : " << #a <<#op <<#b<< " failed:\n"; \
s << #a " = "<<a<<"\n"; \
s << #b " = "<<b<<"\n"; \
s << "in file " << __FILE__ << ", line " << __LINE__ << "\n"; \
throw std::runtime_error(s.str()); \
}
#endif
#ifdef NDEBUG
#ifndef OPENGM_DEBUG
#define OPENGM_ASSERT(expression) {}
#else
#define OPENGM_ASSERT(expression) if(!(expression)) { \
std::stringstream s; \
s << "OpenGM assertion " << #expression \
<< " failed in file " << __FILE__ \
<< ", line " << __LINE__ << std::endl; \
throw std::runtime_error(s.str()); \
}
#endif
#else
#define OPENGM_ASSERT(expression) if(!(expression)) { \
std::stringstream s; \
s << "OpenGM assertion " << #expression \
<< " failed in file " << __FILE__ \
<< ", line " << __LINE__ << std::endl; \
throw std::runtime_error(s.str()); \
}
#endif
/// opengm compile time assertion
#define OPENGM_META_ASSERT(assertion, msg) { \
meta::Assert< meta::Compare< meta::Bool<(assertion)> , meta::Bool<true> >::value > \
OPENGM_COMPILE_TIME_ASSERTION_FAILED_____REASON_____##msg; \
(void) OPENGM_COMPILE_TIME_ASSERTION_FAILED_____REASON_____##msg; \
}
/// The OpenGM namespace
namespace opengm {
typedef double DefaultTimingType;
typedef opengm::UIntType SerializationIndexType;
/// OpenGM runtime error
struct RuntimeError
: public std::runtime_error
{
typedef std::runtime_error base;
RuntimeError(const std::string& message)
: base(std::string("OpenGM error: ") + message) {}
};
// abs function
template<class T>
inline T abs(const T& x) {
return x > 0 ? x : -x;
}
template<class T>
inline T opengmMax(const T& x, const T& y) {
return x >= y ? x : y;
}
template<class T>
inline T opengmMin(const T& x, const T& y) {
return x <= y ? x : y;
}
} // namespace opengm
#endif // #ifndef OPENGM_HXX
|