tvm
|
Base class of all object reference. More...
#include <object.h>
Public Types | |
using | ContainerType = Object |
type indicate the container type. More... | |
Public Member Functions | |
ObjectRef ()=default | |
default constructor More... | |
ObjectRef (ObjectPtr< Object > data) | |
Constructor from existing object ptr. More... | |
bool | same_as (const ObjectRef &other) const |
Comparator. More... | |
bool | operator== (const ObjectRef &other) const |
Comparator. More... | |
bool | operator!= (const ObjectRef &other) const |
Comparator. More... | |
bool | operator< (const ObjectRef &other) const |
Comparator. More... | |
bool | defined () const |
const Object * | get () const |
const Object * | operator-> () const |
bool | unique () const |
int | use_count () const |
template<typename ObjectType , typename = std::enable_if_t<std::is_base_of_v<Object, ObjectType>>> | |
const ObjectType * | as () const |
Try to downcast the internal Object to a raw pointer of a corresponding type. More... | |
template<typename ObjectRefType , typename = std::enable_if_t<std::is_base_of_v<ObjectRef, ObjectRefType>>> | |
Optional< ObjectRefType > | as () const |
Try to downcast the ObjectRef to a Optional<T> of the requested type. More... | |
Static Public Attributes | |
static constexpr bool | _type_is_nullable = true |
Protected Member Functions | |
Object * | get_mutable () const |
Static Protected Member Functions | |
template<typename T > | |
static T | DowncastNoCheck (ObjectRef ref) |
Internal helper function downcast a ref without check. More... | |
static void | FFIClearAfterMove (ObjectRef *ref) |
Clear the object ref data field without DecRef after we successfully moved the field. More... | |
template<typename ObjectType > | |
static ObjectPtr< ObjectType > | GetDataPtr (const ObjectRef &ref) |
Internal helper function get data_ as ObjectPtr of ObjectType. More... | |
Protected Attributes | |
ObjectPtr< Object > | data_ |
Internal pointer that backs the reference. More... | |
Friends | |
struct | ObjectPtrHash |
class | TVMRetValue |
class | TVMArgsSetter |
class | ObjectInternal |
template<typename SubRef , typename BaseRef > | |
SubRef | Downcast (BaseRef ref) |
Downcast a base reference type to a more specific type. More... | |
Base class of all object reference.
type indicate the container type.
|
default |
default constructor
Constructor from existing object ptr.
|
inline |
|
inline |
Try to downcast the ObjectRef to a Optional<T> of the requested type.
The function will return a NullOpt if the cast failed.
if (Optional<Add> opt = node_ref.as<Add>()) { // This is an add node }
ObjectRefType | the target type, must be a subtype of ObjectRef |
|
inline |
|
inlinestaticprotected |
Internal helper function downcast a ref without check.
T | The target reference type. |
|
inlinestaticprotected |
Clear the object ref data field without DecRef after we successfully moved the field.
ref | The reference data. |
|
inline |
|
inlineprotected |
|
inlinestaticprotected |
Internal helper function get data_ as ObjectPtr of ObjectType.
ObjectType | The corresponding object type. |
|
inline |
Comparator.
other | Another object ref. |
|
inline |
|
inline |
Comparator.
other | Another object ref by address. |
|
inline |
Comparator.
other | Another object ref. |
|
inline |
Comparator.
other | Another object ref. |
|
inline |
|
inline |
|
friend |
Downcast a base reference type to a more specific type.
ref | The input reference |
SubRef | The target specific reference type. |
BaseRef | the current reference type. |
|
friend |
|
friend |
|
friend |
|
friend |
|
staticconstexpr |
Internal pointer that backs the reference.