Template Class CoreResource
Defined in File CoreResource.hpp
Inheritance Relationships
Base Type
private nvcv::SharedHandle< Handle >
(Template Class SharedHandle)
Class Documentation
-
template<typename Handle, typename Actual>
class CoreResource : private nvcv::SharedHandle<Handle> CRTP base for resources based on reference-counting handles
This class adds constructors and assignment with the
Actual
type, so that Actual doesn’t need to tediously reimplement them, but can simply reexpose them withusing
.It also exposes the
handle
with aget
and re-exposesreset
andrelease
functions.- Template Parameters:
Handle – The handle type, e.g. NVCVImageHandle
Actual – The actual class, e.g. Image
Public Functions
-
CoreResource() = default
A default constructor that constructs an empty
CoreResource
.
-
inline CoreResource(std::nullptr_t)
A constructor that constructs an empty
CoreResource
from a nullptr.
-
inline explicit CoreResource(HandleType &&handle)
Wraps and assumes ownership of a handle.
This functions stores the resource handle in the wrapper object. The handle passed in the argument is reset to a null handle value to prevent inadvertent usage by the caller after the ownership has been transferred to the wrapper.
- Parameters:
handle – The handle to the resource.
-
inline CoreResource(const Actual &other)
A copy constructor that creates a
CoreResource
from another instance.- Parameters:
other – The other instance to copy from.
-
inline CoreResource(Actual &&other)
A move constructor that transfers ownership from another instance.
- Parameters:
other – The other instance to move from.
-
inline CoreResource &operator=(const Actual &other)
A copy assignment operator that copies from another instance.
- Parameters:
other – The other instance to copy from.
- Returns:
This instance after the copy.
-
inline CoreResource &operator=(Actual &&other)
A move assignment operator that moves from another instance.
- Parameters:
other – The other instance to move from.
- Returns:
This instance after the move.
-
inline const HandleType handle() const noexcept
Returns the handle to the resource.
- Returns:
The handle to the resource.
-
inline bool operator==(const Actual &other) const
Checks if this instance is equal to another.
- Parameters:
other – The other instance to compare with.
- Returns:
true if they are equal, false otherwise.
Public Static Functions
-
static inline Actual FromHandle(HandleType handle, bool incRef)
A factory method to create a
CoreResource
from a handle.- Parameters:
handle – The handle to the resource.
incRef – Indicates whether to increment the reference count of the handle.
- Returns:
A
CoreResource
wrapping the provided handle.
Protected Functions
-
~CoreResource() = default