From e8e4b447a9bbb0bb1a88154522dda9cf31b3edbc Mon Sep 17 00:00:00 2001 From: Attila Afra Date: Tue, 29 Jan 2019 00:12:55 +0200 Subject: [PATCH] added bool operator to object refs, clarified some doc in the headers --- include/OpenImageDenoise/oidn.h | 8 ++++---- include/OpenImageDenoise/oidn.hpp | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/OpenImageDenoise/oidn.h b/include/OpenImageDenoise/oidn.h index 26b0e0d2..fd068c80 100644 --- a/include/OpenImageDenoise/oidn.h +++ b/include/OpenImageDenoise/oidn.h @@ -87,10 +87,10 @@ OIDN_API int oidnGetDevice1i(OIDNDevice device, const char* name); // Sets the error callback function of the device. OIDN_API void oidnSetDeviceErrorFunction(OIDNDevice device, OIDNErrorFunction func, void* userPtr); -// Returns the first unqueried error code stored for the device, optionally -// also returning a string message (if not NULL), and clears the stored error. -// If the device is NULL (e.g. the device creation failed), a thread-local -// error will be returned. +// Returns the first unqueried error code stored in the device for the current +// thread, optionally also returning a string message (if not NULL), and clears +// the stored error. Can be called with a NULL device as well to check why a +// device creation failed. OIDN_API OIDNError oidnGetDeviceError(OIDNDevice device, const char** outMessage); // Commits all previous changes to the device. diff --git a/include/OpenImageDenoise/oidn.hpp b/include/OpenImageDenoise/oidn.hpp index d6aaa8b5..75f66ad4 100644 --- a/include/OpenImageDenoise/oidn.hpp +++ b/include/OpenImageDenoise/oidn.hpp @@ -107,6 +107,11 @@ namespace oidn { return handle; } + operator bool() const + { + return handle != nullptr; + } + // Maps a region of the buffer to host memory. // If byteSize is 0, the maximum available amount of memory will be mapped. void* map(Access access = Access::ReadWrite, size_t byteOffset = 0, size_t byteSize = 0) @@ -187,6 +192,11 @@ namespace oidn { return handle; } + operator bool() const + { + return handle != nullptr; + } + // Sets an image parameter of the filter (stored in a buffer). void setImage(const char* name, const BufferRef& buffer, Format format, @@ -345,6 +355,11 @@ namespace oidn { return handle; } + operator bool() const + { + return handle != nullptr; + } + // Sets a boolean parameter of the device. void set(const char* name, bool value) { @@ -368,12 +383,14 @@ namespace oidn { } // Returns the first unqueried error code and clears the stored error. + // Can be called for a null device as well to check why a device creation failed. Error getError() { return (Error)oidnGetDeviceError(handle, nullptr); } // Returns the first unqueried error code and string message, and clears the stored error. + // Can be called for a null device as well to check why a device creation failed. Error getError(const char*& outMessage) { return (Error)oidnGetDeviceError(handle, &outMessage);