by::type Class Referenceabstract

Base class for runtime type information in byeol language. More...

#include <type.hpp>

Inheritance diagram for by::type:
by::ttypeBase< T, tmetaTypeDef< T, tifHasMetaTypeDef< T >::is >::is > by::ntype by::ttypeBase< void, type > by::ttype< T > by::expr::exprType by::mgdType by::funcMgdType

Public Member Functions

virtual nbool operator== (const me &rhs) const
 
nbool operator!= (const me &rhs) const
 
virtual nbool isTemplate () const =0
 
virtual nbool isAbstract () const =0
 
virtual const std::string & getName () const
 
virtual void * make () const =0
 create an instance to be refered this type. More...
 
template<typename T >
T * makeAs () const
 
virtual ncnt size () const =0
 
virtual nbool init ()
 
virtual nbool rel ()
 
virtual const typegetSuper () const =0
 
virtual const nbool & isInit () const =0
 
const types & getLeafs () const
 returns all most derived class from this class.
 
const types & getSubs () const
 
const types & getSupers () const
 
virtual nbool isSuper (const type &it) const
 
nbool isSuper (const type *it) const BY_SIDE_FUNC(isSuper)
 
template<typename T >
nbool isSuper () const
 
nbool isSub (const type &it) const
 
nbool isSub (const type *it) const BY_SIDE_FUNC(isSub)
 
template<typename T >
nbool isSub () const
 
const typegetStatic () const BY_CONST_FUNC(_getStatic()) virtual const nchar *getMetaTypeName() const
 Get meta type name for efficient type checking. More...
 

Protected Member Functions

virtual types & _getSubs ()=0
 
virtual types & _getSupers ()=0
 
virtual type_getStatic () const =0
 
void _setInit (nbool newState)
 
virtual void _onAddSubClass (const me &subClass)
 
virtual types ** _onGetLeafs () const =0
 
void _setLeafs (types *newLeafs) const
 
virtual const std::string & _getNativeName () const
 

Detailed Description

Base class for runtime type information in byeol language.

Provides fundamental type metadata and operations. Returns ttype<type> as result of getType() for type introspection.

Member Function Documentation

◆ getStatic()

const type & by::type::getStatic ( ) const

Get meta type name for efficient type checking.

This returns metaTypename. metaTypename can be used like 'dynamic_cast<yourType>'. as you may know, c++'s dynamic_cast is slow. because normally compilers tries to loop in order to figure out which type is fit to given your type parameter. 'meta' library, however, uses 'tier' algorithm and it's O(1), so it's faster.

you can use your own metaType to represent more data on type class. for instance, 'core' module uses 'ntype' custom type class. but in that case, when you compare custom type class, you must compare extended data to 'rhs' variable to base type class, 'type'.

so how can you know that 'type' is actually instance of your derived custom type class in 'tier' algorithm? please don't think about 'dynamic_cast'. it'll vanish our effectiveness to use 'tier' algorithm. that's why I make 'getMetaTypeName()' func.

Returns
static literal c-style string for meta type name. so you are able to use c-style casting if address of 'rhs' variables's getMetaTypeName() isn just same to yours.
yourType& a = ....;
type& rhs = ....;
if(a.getMetaTypeName() != rhs.getMetaTypeName()) return;
yourType& rhsCasted = (yourType&) rhs;
...now you can do something on yourType's data...

◆ make()

virtual void * by::type::make ( ) const
pure virtual

create an instance to be refered this type.

Remarks
available when the type defines a ctor without any params.
Returns
return an address of new instance, however, if ctor without any params isn't defined, then returns null.

Implemented in by::mgdType, and by::ttypeBase< void, type >.


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