ComponentDescriptor Class Reference

#include <objectbase.h>

Detailed Description

ComponentDescriptor describes a component implementation (created by MAXON_COMPONENT and MAXON_COMPONENT_ONLY_REGISTER) at runtime. It is an EntityDefinition object, the component descriptor can be published as an object via MAXON_DECLARATION.

Public Member Functions

 ComponentDescriptor ()
 
 ~ComponentDescriptor ()
 
template<typename C , typename REG >
 ComponentDescriptor (C *ctype, LiteralId &&cid, TranslationUnit *unit, const Char *file, EntityBase::FLAGS flags, REG *registry)
 
const IdGetId () const
 
Result< void > Initialize (const Id &cause) const
 
String ToString (const FormatStatement *fs=nullptr) const
 
const EntityDefinition & GetDefinition () const
 
const ComponentDescriptorGetClassProxy () const
 
const Block< const InterfaceReference *const > & GetInterfaces () const
 
EntityBase::FLAGS GetFlags () const
 
Int GetSize () const
 

Static Public Member Functions

static MAXON_ATTRIBUTE_FORCE_INLINE const ComponentDescriptorNullValue ()
 

Public Attributes

Result< void >(*)(const DataSerializeInterface &) GetDescribeIO () const
 

Private Member Functions

 ComponentDescriptor (Bool dummy, const ComponentDescriptor &base)
 
 ComponentDescriptor (LiteralId &&cid, TranslationUnit *unit, const Char *file, EntityBase::FLAGS flags)
 
template<typename C >
void Construct ()
 

Private Attributes

EntityDefinition _super
 
void(* _construct )(void *component)
 
DestructorPointer _destruct
 
Result< void >(* _init )(void *component)
 
void(* _free )(void *component)
 
Result< void >(* _copyFrom )(void *destComp, const void *srcObject)
 
Bool(* _constructMTable )(ClassInfo *info, Int offset, void *supervtable)
 
Result< void >(* _initImplementation )()
 
void(* _freeImplementation )()
 
Result< void >(* _describeIO )(const DataSerializeInterface &)
 
Block< const InterfaceReference *const > _interfaces
 
Int _size
 
Int _alignment
 
Int _superMTableSize
 
UInt _hashCode
 
Int _selfPtrOffset
 
Int _simpleMTableSize
 
Id _registry
 
const ComponentDescriptor_classProxy
 
void * _implementedMethods
 
const PrivateSuperCallBase_supercalls
 

Friends

class ObjectModel
 
class ObjectInterface
 
class PrivateSuperCallBase
 
class ClassInfo
 
class ClassImpl
 
class VirtualInterfaceInfo
 
struct VirtualInterfaceVersion
 

Constructor & Destructor Documentation

◆ ComponentDescriptor() [1/4]

◆ ~ComponentDescriptor()

◆ ComponentDescriptor() [2/4]

ComponentDescriptor ( C *  ctype,
LiteralId &&  cid,
TranslationUnit *  unit,
const Char file,
EntityBase::FLAGS  flags,
REG *  registry 
)

Constructs the ComponentDescriptor object and adds it to the definition list of the current translation unit. Class C is used as implementation class of the component.

Parameters
[in]ctypeDummy parameter, this is only needed to determine template parameter C.
[in]cidThe unique component identifier.
[in]unitThe translation unit containing the component implementation.
[in]fileSource file name.
[in]flagsPROXY may be set here.
[in]registryDummy parameter to pass the registry.
Template Parameters
CImplementation class of the component.

◆ ComponentDescriptor() [3/4]

ComponentDescriptor ( Bool  dummy,
const ComponentDescriptor base 
)
private

◆ ComponentDescriptor() [4/4]

ComponentDescriptor ( LiteralId &&  cid,
TranslationUnit *  unit,
const Char file,
EntityBase::FLAGS  flags 
)
private

Member Function Documentation

◆ GetId()

const Id& GetId ( void  ) const

Returns the component identifier of this descriptor.

Returns
Unique identifier.

◆ Initialize()

Result<void> Initialize ( const Id cause) const

Initializes the component descriptor. This is invoked by the object system after all other entity objects on which the component depends have been initialized. If the descriptor has been initialized already, or if such a previous attempt failed, no further initialization is done. All references to the descriptor object (given by MAXON_DECLARATION) will be initialized, too.

Parameters
[in]causeIdentifier of another entity which caused the initialization of this descriptor. This is only for informative purpose.
Returns
Success of initialization.

◆ NullValue()

static MAXON_ATTRIBUTE_FORCE_INLINE const ComponentDescriptor& NullValue ( )
static

◆ ToString()

String ToString ( const FormatStatement fs = nullptr) const

◆ GetDefinition()

const EntityDefinition& GetDefinition ( ) const

◆ GetClassProxy()

const ComponentDescriptor* GetClassProxy ( ) const

◆ GetInterfaces()

const Block<const InterfaceReference* const>& GetInterfaces ( ) const

◆ GetFlags()

EntityBase::FLAGS GetFlags ( void  ) const

◆ GetSize()

Int GetSize ( void  ) const

◆ Construct()

void Construct ( )
private

Used by the constructors to initialize function pointers and other implementation-specific values from the component implementation class C.

Template Parameters
CImplementation class of the component.

Friends And Related Function Documentation

◆ ObjectModel

friend class ObjectModel
friend

◆ ObjectInterface

friend class ObjectInterface
friend

◆ PrivateSuperCallBase

friend class PrivateSuperCallBase
friend

◆ ClassInfo

friend class ClassInfo
friend

◆ ClassImpl

friend class ClassImpl
friend

◆ VirtualInterfaceInfo

friend class VirtualInterfaceInfo
friend

◆ VirtualInterfaceVersion

friend struct VirtualInterfaceVersion
friend

Member Data Documentation

◆ GetDescribeIO

Result<void>(*)(const DataSerializeInterface&) GetDescribeIO() const

◆ _super

EntityDefinition _super
private

Base definition object.

◆ _construct

void(* _construct) (void *component)
private

Constructor of component.

◆ _destruct

DestructorPointer _destruct
private

Destructor of component.

◆ _init

Result<void>(* _init) (void *component)
private

Pointer for InitComponent function.

◆ _free

void(* _free) (void *component)
private

Pointer for FreeComponent function.

◆ _copyFrom

Result<void>(* _copyFrom) (void *destComp, const void *srcObject)
private

Pointer for CopyFrom function.

◆ _constructMTable

Bool(* _constructMTable) (ClassInfo *info, Int offset, void *supervtable)
private

Pointer for ConstructMTable function of component implementation class.

◆ _initImplementation

Result<void>(* _initImplementation) ()
private

Pointer for InitImplementation function of component implementation class.

◆ _freeImplementation

void(* _freeImplementation) ()
private

Pointer for FreeImplementation function of component implementation class.

◆ _describeIO

Result<void>(* _describeIO) (const DataSerializeInterface &)
private

This function is used to describe the component for I/O operations.

◆ _interfaces

Block<const InterfaceReference* const> _interfaces
private

The list of implemented interfaces (excluding base interfaces).

◆ _size

Int _size
private

Size of component object data.

◆ _alignment

Int _alignment
private

Alignment of component object data.

◆ _superMTableSize

Int _superMTableSize
private

Size of super-vtable of component.

◆ _hashCode

UInt _hashCode
private

Hash code of component descriptor. This will be less than ClassInfo::HASH_TABLE_SIZE.

◆ _selfPtrOffset

Int _selfPtrOffset
private

Offset of the self pointer within the component.

◆ _simpleMTableSize

Int _simpleMTableSize
private

Size of the simple method table if this component implements a simple virtual interface, 0 otherwise.

◆ _registry

Id _registry
private

Id of a registry at which this component descriptor shall be registered.

◆ _classProxy

const ComponentDescriptor* _classProxy
private

For a proxy component, this points to the corresponding class proxy component.

◆ _implementedMethods

void* _implementedMethods
private

Pointer to internal information about the set of implemented methods.

◆ _supercalls

const PrivateSuperCallBase* _supercalls
mutableprivate

Singly-linked list of super calls which are needed by this component.