Photon Common Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
assertion.h File Reference
#include "Common/config.h"
#include "Common/macro.h"
#include <string>

Go to the source code of this file.

Namespaces

namespace  ph
 The root for all renderer implementations.
 
namespace  ph::detail
 Implementation detail mainly for internal usages.
 

Macros

#define PH_ASSERT_MSG(condition, message)   PH_NO_OP()
 
#define PH_INTERNAL_RANGE_MSG(value, lowerBound, upperBound, lowerBoundSymbol, upperBoundSymbol)   PH_NO_OP()
 
#define PH_ASSERT(condition)    PH_ASSERT_MSG(condition, "")
 
#define PH_ASSERT_UNREACHABLE_SECTION()    PH_ASSERT_MSG(false, "executing supposedly unreachable code")
 
#define PH_ASSERT_EQ(a, b)    PH_ASSERT_MSG(a == b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
 
#define PH_ASSERT_NE(a, b)    PH_ASSERT_MSG(a != b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
 
#define PH_ASSERT_GT(a, b)    PH_ASSERT_MSG(a > b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
 
#define PH_ASSERT_LT(a, b)    PH_ASSERT_MSG(a < b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
 
#define PH_ASSERT_GE(a, b)    PH_ASSERT_MSG(a >= b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
 
#define PH_ASSERT_LE(a, b)    PH_ASSERT_MSG(a <= b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))
 
#define PH_ASSERT_IN_RANGE(value, begin, end)    PH_ASSERT_MSG(begin <= value && value < end, PH_INTERNAL_RANGE_MSG(value, begin, end, "[", ")"))
 Assert that value is within [begin, end).
 
#define PH_ASSERT_IN_RANGE_INCLUSIVE(value, lowerBound, upperBound)    PH_ASSERT_MSG(lowerBound <= value && value <= upperBound, PH_INTERNAL_RANGE_MSG(value, lowerBound, upperBound, "[", "]"))
 Similar to PH_ASSERT_IN_RANGE(3), except the bounds are inclusive.
 
#define PH_ASSERT_IN_RANGE_EXCLUSIVE(value, lowerBound, upperBound)    PH_ASSERT_MSG(lowerBound < value && value < upperBound, PH_INTERNAL_RANGE_MSG(value, lowerBound, upperBound, "(", ")"))
 Similar to PH_ASSERT_IN_RANGE(3), except the bounds are exclusive.
 
#define PH_STATIC_ASSERT_DEPENDENT_FALSE(DependentType, message)    static_assert(::ph::detail::DEPENDENT_FALSE<DependentType>, #message)
 

Functions

void ph::detail::output_assertion_message (const std::string &filename, const std::string &lineNumber, const std::string &condition, const std::string &message)
 
void ph::detail::on_assertion_failed ()
 

Variables

template<typename T >
constexpr bool ph::detail::DEPENDENT_FALSE = false
 

Macro Definition Documentation

◆ PH_ASSERT

#define PH_ASSERT ( condition)     PH_ASSERT_MSG(condition, "")

◆ PH_ASSERT_EQ

#define PH_ASSERT_EQ ( a,
b )    PH_ASSERT_MSG(a == b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))

◆ PH_ASSERT_GE

#define PH_ASSERT_GE ( a,
b )    PH_ASSERT_MSG(a >= b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))

◆ PH_ASSERT_GT

#define PH_ASSERT_GT ( a,
b )    PH_ASSERT_MSG(a > b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))

◆ PH_ASSERT_IN_RANGE

#define PH_ASSERT_IN_RANGE ( value,
begin,
end )    PH_ASSERT_MSG(begin <= value && value < end, PH_INTERNAL_RANGE_MSG(value, begin, end, "[", ")"))

Assert that value is within [begin, end).

◆ PH_ASSERT_IN_RANGE_EXCLUSIVE

#define PH_ASSERT_IN_RANGE_EXCLUSIVE ( value,
lowerBound,
upperBound )    PH_ASSERT_MSG(lowerBound < value && value < upperBound, PH_INTERNAL_RANGE_MSG(value, lowerBound, upperBound, "(", ")"))

Similar to PH_ASSERT_IN_RANGE(3), except the bounds are exclusive.

◆ PH_ASSERT_IN_RANGE_INCLUSIVE

#define PH_ASSERT_IN_RANGE_INCLUSIVE ( value,
lowerBound,
upperBound )    PH_ASSERT_MSG(lowerBound <= value && value <= upperBound, PH_INTERNAL_RANGE_MSG(value, lowerBound, upperBound, "[", "]"))

Similar to PH_ASSERT_IN_RANGE(3), except the bounds are inclusive.

◆ PH_ASSERT_LE

#define PH_ASSERT_LE ( a,
b )    PH_ASSERT_MSG(a <= b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))

◆ PH_ASSERT_LT

#define PH_ASSERT_LT ( a,
b )    PH_ASSERT_MSG(a < b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))

◆ PH_ASSERT_MSG

#define PH_ASSERT_MSG ( condition,
message )   PH_NO_OP()

◆ PH_ASSERT_NE

#define PH_ASSERT_NE ( a,
b )    PH_ASSERT_MSG(a != b, std::string(#a) + " = " + std::to_string(a) + ", " + #b + " = " + std::to_string(b))

◆ PH_ASSERT_UNREACHABLE_SECTION

#define PH_ASSERT_UNREACHABLE_SECTION ( )     PH_ASSERT_MSG(false, "executing supposedly unreachable code")

◆ PH_INTERNAL_RANGE_MSG

#define PH_INTERNAL_RANGE_MSG ( value,
lowerBound,
upperBound,
lowerBoundSymbol,
upperBoundSymbol )   PH_NO_OP()

◆ PH_STATIC_ASSERT_DEPENDENT_FALSE

#define PH_STATIC_ASSERT_DEPENDENT_FALSE ( DependentType,
message )    static_assert(::ph::detail::DEPENDENT_FALSE<DependentType>, #message)