P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::RTTI::Base Struct Referenceabstract
Inheritance diagram for P4::RTTI::Base:
[legend]

Public Member Functions

template<typename T >
bool is () const noexcept
 
virtual bool isA (TypeId typeId) const noexcept=0
 
template<typename T >
const T * to () const noexcept
 Same as to, but returns const pointer to T.
 
template<typename T >
T * to () noexcept
 
virtual TypeId typeId () const noexcept=0
 

Protected Member Functions

virtual const void * toImpl (TypeId typeId) const noexcept=0
 

Member Function Documentation

◆ is()

template<typename T >
bool P4::RTTI::Base::is ( ) const
inlinenodiscardnoexcept

Checks if given object is of specified dynamic type. Same as isA, but typeid to check with is derived from template argument.

◆ isA()

virtual bool P4::RTTI::Base::isA ( TypeId typeId) const
nodiscardpure virtualnoexcept

Checks if given object is of specified dynamic type.

Parameters
typeidto check with

◆ to()

template<typename T >
T * P4::RTTI::Base::to ( )
inlinenodiscardnoexcept

Casts current object to a given type T. Overall the semantics is similar to that of dynamic_cast, however, relies on custom RTTI metadata and intrusive annotation.

Returns
nullptr if object is not compatible with T (e.g. if T is not among its base classes), casted pointer to object of T* type otherwise.

◆ typeId()

virtual TypeId P4::RTTI::Base::typeId ( ) const
nodiscardpure virtualnoexcept

Queries information about dynamic type of an object.

Returns
typeid of current object.