Blob is a general container that hosts a typed pointer. More...
#include <blob.h>
Public Member Functions | |
Blob () noexcept | |
Initializes an empty Blob. | |
Blob (Blob &&other) noexcept | |
Blob & | operator= (Blob &&other) noexcept |
template<class T > | |
bool | IsType () const noexcept |
Checks if the content stored in the blob is of type T. | |
const TypeMeta & | meta () const noexcept |
Returns the meta info of the blob. | |
const char * | TypeName () const noexcept |
Returns a printable typename of the blob. | |
template<class T > | |
const T & | Get () const |
Gets the const reference of the stored object. More... | |
const void * | GetRaw () const noexcept |
void * | GetRaw () noexcept |
template<class T > | |
T * | GetMutable () |
Gets a mutable pointer to the stored object. More... | |
template<class T > | |
T * | GetMutableOrNull () |
template<class T > | |
T * | Reset (T *allocated) |
Sets the underlying object to the allocated one. More... | |
template<class T > | |
std::remove_const< T >::type * | ShareExternal (typename std::remove_const< T >::type *allocated) |
Sets the underlying object to the allocated one, but does not take over the ownership of the passed in pointer. More... | |
void * | ShareExternal (void *allocated, const TypeMeta &meta) |
void | Reset () |
Resets the Blob to an empty one. | |
void | swap (Blob &rhs) |
Swaps the underlying storage of two blobs. | |
Additional Inherited Members | |
Protected Member Functions inherited from c10::intrusive_ptr_target | |
intrusive_ptr_target (intrusive_ptr_target &&other) noexcept | |
intrusive_ptr_target & | operator= (intrusive_ptr_target &&other) noexcept |
intrusive_ptr_target (const intrusive_ptr_target &other) noexcept | |
intrusive_ptr_target & | operator= (const intrusive_ptr_target &other) noexcept |
Blob is a general container that hosts a typed pointer.
A Blob hosts a pointer as well as its type, and takes charge of deleting it properly when the blob is deallocated or re-allocated with a new type. A blob could contain anything, although the most common case is to contain a Tensor.
|
inline |
|
inline |
Sets the underlying object to the allocated one.
The Blob then takes over the ownership of the passed in pointer. If there is already an object in the Blob, the old object is freed.
This is used when the underlying class T does not have a default ctor, or complex initializations needs to be done outside the blob.
|
inline |
Sets the underlying object to the allocated one, but does not take over the ownership of the passed in pointer.
If there is already an object in the Blob, the old object is freed.
Unlike Reset, this does not take over the ownership of the pointer and the caller is responsible for making sure that the lifetime of the allocated blob outlasts the lifetime of any access to this blob, until another Reset call is made or the blob is destructed.