13 #ifndef __defined_libdai_exceptions_h
14 #define __defined_libdai_exceptions_h
24 #define DAI_QUOTE(x) #x
27 #define DAI_TOSTRING(x) DAI_QUOTE(x)
39 #if defined __GNUG__ // GNU C++
40 #define FUNCTION_NAME __PRETTY_FUNCTION__
41 #elif defined _MSC_VER // Visual Studio
42 #define FUNCTION_NAME __FUNCTION__
43 #else // other compilers
44 #define FUNCTION_NAME __func__
46 #define DAI_THROW(cod) throw dai::Exception(dai::Exception::cod, __FILE__, FUNCTION_NAME, DAI_TOSTRING(__LINE__), "")
57 #define DAI_THROWE(cod,msg) throw dai::Exception(dai::Exception::cod, __FILE__, FUNCTION_NAME, DAI_TOSTRING(__LINE__), msg)
60 #define DAI_ASSERT(condition) ((condition) ? ((void)0) : DAI_THROWE(ASSERTION_FAILED, std::string("Assertion \"" #condition "\" failed")))
65 #define DAI_DEBASSERT(x) do {DAI_ASSERT(x);} while(0)
67 #define DAI_DEBASSERT(x) do {} while(0)
82 enum Code {NOT_IMPLEMENTED,
88 UNKNOWN_DAI_ALGORITHM,
89 UNKNOWN_PARAMETER_ESTIMATION_METHOD,
90 UNKNOWN_PROPERTY_TYPE,
93 NOT_ALL_PROPERTIES_SPECIFIED,
97 INVALID_FACTORGRAPH_FILE,
98 INVALID_EVIDENCE_FILE,
102 FACTORGRAPH_NOT_CONNECTED,
109 Exception(
Code code,
const char *filename,
const char *
function,
const char *line,
const std::string& detailedMsg ) :
110 std::runtime_error(
ErrorStrings[code] + (detailedMsg.empty() ?
"" : (
": " + detailedMsg)) +
" [File " + filename +
", line " + line +
", function: " + function +
"]"),