![]() |
LibraryLink Utilities
3.0.1
Modern C++ wrapper over LibraryLink and WSTP
|
Template of the base class for all generic containers.
MContainerBase stores the raw LibraryLink container and defines a common interface for all generic containers.
| Type | - container type |
#include <Base.hpp>
Public Types | |
| using | Container = Argument::CType< Type > |
| The type of underlying LibraryLink structure (e.g. MTensor, MImage, etc.) will be called "Container". More... | |
Public Member Functions | |
| MContainerBase ()=default | |
| Default constructor, creates an empty wrapper. More... | |
| MContainerBase (Container c, Ownership owner) | |
| Create MContainerBase from a raw container and its owner. More... | |
| MContainerBase (const MContainerBase &mc)=delete | |
| Container wrappers are non-copyable, they act somewhat like unique_ptr around the raw container. More... | |
| MContainerBase (MContainerBase &&mc) noexcept | |
| Move-constructor steals the raw container keeping the ownership info. More... | |
| MContainerBase & | operator= (const MContainerBase &mc)=delete |
| Copy-assignment is deleted, same as copy-constructor. More... | |
| MContainerBase & | operator= (MContainerBase &&mc) noexcept |
| Move-assignment operator disposes of the current raw container and steals the new one keeping its ownership intact. More... | |
| virtual | ~MContainerBase () noexcept |
| Destructor takes appropriate action depending on the ownership info. More... | |
| Container | getContainer () const noexcept |
| Get internal container. More... | |
| Container | abandonContainer () const noexcept |
| Give a handle to internal container and stop owning it. More... | |
| mint | shareCount () const noexcept |
| Return share count of internal container, if present and 0 otherwise. More... | |
| void | pass (MArgument &res) const |
| Pass the internal container as result of a LibraryLink function. More... | |
| Ownership | getOwner () const noexcept |
| Get ownership information. More... | |
Protected Member Functions | |
| Container | cloneContainer () const |
| Clone the raw container, if it's present. More... | |
| void | disown () const noexcept |
| Disown internal container if present. More... | |
| void | free () const noexcept |
| Free internal container if present. More... | |
| void | reset (Container newCont, Ownership newOwnerMode=Ownership::Library) noexcept |
| Set a new internal container safely disposing of the old one. More... | |
| using LLU::MContainerBase< Type >::Container = Argument::CType<Type> |
The type of underlying LibraryLink structure (e.g. MTensor, MImage, etc.) will be called "Container".
|
default |
Default constructor, creates an empty wrapper.
|
inline |
Create MContainerBase from a raw container and its owner.
| c | - raw LibraryLink container (MTensor, MNumericArray, etc.), passing a nullptr will trigger an exception |
| owner | - who manages the raw container's memory |
|
delete |
Container wrappers are non-copyable, they act somewhat like unique_ptr around the raw container.
|
inlinenoexcept |
Move-constructor steals the raw container keeping the ownership info.
| mc | - MContainerBase to be moved-from, it's internal container becomes nullptr |
|
inlinevirtualnoexcept |
Destructor takes appropriate action depending on the ownership info.
|
inlinenoexcept |
Give a handle to internal container and stop owning it.
Should be used with caution as it may potentially result with resource leak.
|
inlineprotected |
Clone the raw container, if it's present.
|
inlineprotectednoexcept |
Disown internal container if present.
|
inlineprotectednoexcept |
Free internal container if present.
|
inlinenoexcept |
Get internal container.
|
inlinenoexcept |
Get ownership information.
|
delete |
Copy-assignment is deleted, same as copy-constructor.
|
inlinenoexcept |
Move-assignment operator disposes of the current raw container and steals the new one keeping its ownership intact.
| mc | - MContainerBase to be moved-from, it's internal container becomes nullptr |
|
inline |
Pass the internal container as result of a LibraryLink function.
| res | - MArgument which will hold internal container of this MContainerBase |
|
inlineprotectednoexcept |
Set a new internal container safely disposing of the old one.
| newCont | - new internal container |
| newOwnerMode | - owner of the new container |
|
inlinenoexcept |
Return share count of internal container, if present and 0 otherwise.