Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Types | Public Member Functions | Static Public Member Functions
caffe2::TypeMeta Class Reference

TypeMeta is a thin class that allows us to store the type of a container such as a blob, or the data type of a tensor, with a unique run-time id. More...

#include <typeid.h>

Public Types

typedef void(* PlacementNew) (void *, size_t)
 
typedef void(* TypedCopy) (const void *, void *, size_t)
 
typedef void(* TypedDestructor) (void *, size_t)
 

Public Member Functions

 TypeMeta ()
 Create a dummy TypeMeta object. More...
 
 TypeMeta (const TypeMeta &src)
 Copy constructor.
 
TypeMetaoperator= (const TypeMeta &src)
 Assignment operator.
 
const CaffeTypeId & id () const
 Returns the type id.
 
const size_t & itemsize () const
 Returns the size of the item.
 
PlacementNew ctor () const
 Returns the placement new function pointer for individual items.
 
TypedCopy copy () const
 Returns the typed copy function pointer for individual iterms.
 
TypedDestructor dtor () const
 Returns the destructor function pointer for individual items.
 
const char * name () const
 Returns a printable name for the type.
 
bool operator== (const TypeMeta &m) const
 
bool operator!= (const TypeMeta &m) const
 
template<typename T >
bool Match () const
 

Static Public Member Functions

template<typename T >
static CAFFE2_EXPORT CaffeTypeId Id ()
 Returns the unique id for the given type T. More...
 
template<typename T >
static size_t ItemSize ()
 Returns the item size of the type. More...
 
template<typename T >
static const char * Name ()
 Returns the printable name of the type. More...
 
template<typename T >
static void _Ctor (void *ptr, size_t n)
 Placement new function for the type.
 
template<typename T >
static void _Copy (const void *src, void *dst, size_t n)
 Typed copy function for classes.
 
template<typename T >
static void _CopyNotAllowed (const void *src, void *dst, size_t n)
 A placeholder function for types that do not allow assignment.
 
template<typename T >
static void _Dtor (void *ptr, size_t n)
 Destructor for non-fundamental types.
 
template<typename T >
static std::enable_if< std::is_fundamental< T >::value, TypeMeta >::type Make ()
 Returns a TypeMeta object that corresponds to the typename T.
 
template<typename T , typename std::enable_if< !std::is_fundamental< T >::value &&std::is_copy_assignable< T >::value >::type * = nullptr>
static TypeMeta Make ()
 
template<typename T >
static TypeMeta Make (typename std::enable_if< !std::is_fundamental< T >::value &&!std::is_copy_assignable< T >::value >::type *=0)
 

Detailed Description

TypeMeta is a thin class that allows us to store the type of a container such as a blob, or the data type of a tensor, with a unique run-time id.

It also stores some additional data such as the item size and the name of the type for run-time inspection.

Definition at line 66 of file typeid.h.

Constructor & Destructor Documentation

◆ TypeMeta()

caffe2::TypeMeta::TypeMeta ( )
inline

Create a dummy TypeMeta object.

To create a TypeMeta object for a specific type, use TypeMeta::Make<T>().

Definition at line 74 of file typeid.h.

Member Function Documentation

◆ Id()

template<typename T >
static CAFFE2_EXPORT CaffeTypeId caffe2::TypeMeta::Id ( )
static

Returns the unique id for the given type T.

The id is unique for the type T in the sense that for any two different types, their id are different; for the same type T, the id remains the same over different calls of the function. However, this is not guaranteed over different runs, as the id is generated during run-time. Do NOT serialize the id for storage.

◆ ItemSize()

template<typename T >
static size_t caffe2::TypeMeta::ItemSize ( )
inlinestatic

Returns the item size of the type.

This is equivalent to sizeof(T).

Definition at line 178 of file typeid.h.

◆ Name()

template<typename T >
static const char* caffe2::TypeMeta::Name ( )
inlinestatic

Returns the printable name of the type.

Works for all types, not only the ones registered with CAFFE_KNOWN_TYPE

Definition at line 188 of file typeid.h.


The documentation for this class was generated from the following file: