Skip to content

Commit

Permalink
added bool operator to object refs, clarified some doc in the headers
Browse files Browse the repository at this point in the history
  • Loading branch information
atafra committed Jan 28, 2019
1 parent be5106f commit e8e4b44
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/OpenImageDenoise/oidn.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 17 additions & 0 deletions include/OpenImageDenoise/oidn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down

0 comments on commit e8e4b44

Please sign in to comment.