Open Search
    ObjectInterface Class Reference

    #include <objectbase.h>

    Inheritance diagram for ObjectInterface:

    Detailed Description

    ObjectInterface is the root of the interface hierarchy of the MAXON API. As a C++ class, each virtual interface is directly derived from ObjectInterface, but as an interface a virtual interface may have an arbitrary number of base interfaces, all of which have ObjectInterface as direct or indirect base interface. The interface hierarchy is reflected by the Ptr, ConstPtr and reference classes of the interfaces: They have conversion operators to all base interfaces, and they contain functions for all methods of the interface and its base interfaces.

    ObjectInterface provides some general inheritance-related functions such as GetClass() and IsInstanceOf(), data-related functions such as Clone() and CopyFrom(), and virtual methods such as ToString() which are required for each object.

    All ObjectInterface instances are reference-counted. Within the declaration of an interface you may choose the reference behaviour on invocation of a non-const method (normal, const, copy-on-write).

    Classes

    struct  PrivateSuperMTable
     
    struct  ReferenceFunctions
     

    Public Types

    using Interface = ObjectInterface
     
    using IsAllocType = std::true_type
     
    using Ptr = maxon::RefBase< ReferenceFunctions< maxon::RefBaseFn< maxon::DirectRef< ObjectInterface, maxon::PointerHandler, void > >> >
     
    using ConstPtr = maxon::RefBase< ReferenceFunctions< maxon::RefBaseFn< maxon::DirectRef< const ObjectInterface, maxon::PointerHandler, void > >> >
     
    using BaseInterface = ObjectInterface
     

    Public Member Functions

    Ptr GetPtr ()
     
    ConstPtr GetPtr () const
     
    template<typename REFSUPERCLASS = ObjectRef>
    MAXON_FUNCTION const maxon::Class< typename REFSUPERCLASS::PrivateErasedReferencedType::Hxx1::ReferenceClass > & GetClass () const
     
    MAXON_FUNCTION const ClassInfo * GetClassInfo () const
     
    template<typename REF >
    const ComponentInfo & GetComponentInfoOfSuper (const REF *sptr, OverloadRank0) const MAXON_IF_TARGET_DEBUG(
     
    template<typename REF , typename = typename REF::Component::ComponentClass>
    const ComponentInfo & GetComponentInfoOfSuper (const REF *sptr, OverloadRank1) const
     
    MAXON_FUNCTION Bool HasSameClass (const ObjectInterface *obj) const
     
    Result< void > CopyFrom (const ObjectInterface *src)
     
    Result< ObjectInterface * > Clone () const
     
    template<typename REFCLASS >
    MAXON_FUNCTION Result< REFCLASS > Clone () const
     
    template<typename I >
    MAXON_FUNCTION Bool IsInstanceOf () const
     
    MAXON_FUNCTION Bool IsInstanceOf (const DataType &type) const
     
    MAXON_METHOD String ToString (const FormatStatement *formatStatement=nullptr) const
     
    MAXON_METHOD Result< void > InitObject (const void *argument)
     
    MAXON_METHOD Result< void > HandleMessage (const InternedId &message, void *argument)
     
    MAXON_METHOD Result< void > HandleConstMessage (const InternedId &message, void *argument) const
     
    MAXON_METHOD Bool IsEqual (const maxon::ObjectInterface *other) const
     
    MAXON_METHOD COMPARERESULT Compare (const maxon::ObjectInterface *other) const
     
    MAXON_FUNCTION HashInt GetHashCode () const
     
    MAXON_FUNCTION UniqueHash GetUniqueHashCode () const
     
    MAXON_METHOD HashInt GetHashCodeImpl () const
     
    MAXON_METHOD UniqueHash GetUniqueHashCodeImpl () const
     
     MAXON_ADD_TO_CONST_REFERENCE_CLASS (Bool operator==(std::nullptr_t) const { return RefCompare< MAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), nullptr);} Bool operator!=(std::nullptr_t) const { return !RefCompare< MAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), nullptr);} Bool operator==(const ObjectInterface *ref) const { return RefCompare< MAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} Bool operator!=(const ObjectInterface *ref) const { return !RefCompare< MAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} Bool operator==(ObjectInterface *ref) const { return RefCompare< MAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} Bool operator!=(ObjectInterface *ref) const { return !RefCompare< MAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} template< typename T > Bool operator==(T *ref) const { return RefCompare< MAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} template< typename T > Bool operator!=(T *ref) const { return !RefCompare< MAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} template< typename R, typename=typename maxon::details::DisableComparison< typename S::PrivateReferencedType, typename R::ReferencedType >::type > Bool operator==(const R &ref) const { static_assert(AlwaysFalse< R >::value, "Can't compare unrelated reference classes.");return false;} template< typename R, typename=typename maxon::details::DisableComparison< typename S::PrivateReferencedType, typename R::ReferencedType >::type > Bool operator!=(const R &ref) const { static_assert(AlwaysFalse< R >::value, "Can't compare unrelated reference classes.");return false;})
     
    Bool PrivateIsInstanceOf (const DataType &type) const
     

    Static Public Member Functions

    static maxon::Id GetInterfaceId ()
     
    static ObjectInterfaceAlloc (MAXON_SOURCE_LOCATION_DECLARATION, const ObjectInterface &src)
     
    template<typename DUMMY >
    static maxon::Int PrivateInstantiateNullValueHelper ()
     
    static maxon::InterfaceReference * PrivateGetInterface ()
     
    static constexpr MAXON_ATTRIBUTE_FORCE_INLINE std::nullptr_t NullValuePtr ()
     
    static void PrivateFreeInstance (const ObjectInterface *o)
     

    Public Attributes

    maxon::ObjectInterface::ReferenceFunctions MAXON_ENUM_LIST_CLASS
     

    Static Public Attributes

    static maxon::InterfaceReference _interface
     
    static maxon::NonvirtualInterfaceReference _staticInterface
     
    static const maxon::EntityBase::FLAGS REFERENCE_KIND
     
    static const EntityBase::FLAGS INTERFACE_FLAGS
     

    Protected Member Functions

     ~ ObjectInterface ()
     
    void RemoveReference () const
     

    Private Member Functions

     ObjectInterface ()
     
     ObjectInterface (const ObjectInterface &)
     
    void operator= (const ObjectInterface &)
     
    void PrivateCheckClass ()
     
     ObjectInterface (const ClassInfo *tbl)
     

    Static Private Member Functions

    static ObjectInterfaceAlloc (MAXON_SOURCE_LOCATION_DECLARATION)
     
    static maxon::Int GetInfoOffset ()
     

    Friends

    class maxon::ClassInterface
     
    class maxon::ComponentDescriptor
     
    class maxon::StrongCOWRefHandler
     
    template<typename >
    class ComponentWrapper
     
    class StrongRefHandler
     
    class ClassImpl
     

    Member Typedef Documentation

    ◆ Interface

    ◆ IsAllocType

    using IsAllocType = std::true_type

    ◆ Ptr

    using Ptr = maxon::RefBase<ReferenceFunctions<maxon::RefBaseFn<maxon::DirectRef< ObjectInterface , maxon::PointerHandler, void> >> >

    ◆ ConstPtr

    using ConstPtr = maxon::RefBase<ReferenceFunctions<maxon::RefBaseFn<maxon::DirectRef<const ObjectInterface , maxon::PointerHandler, void> >> >

    ◆ BaseInterface

    Constructor & Destructor Documentation

    ◆ ~ ObjectInterface()

    ~ ObjectInterface ( )
    protected

    ◆ ObjectInterface() [1/3]

    ObjectInterface ( )
    private

    ◆ ObjectInterface() [2/3]

    ObjectInterface ( const ObjectInterface )
    private

    ◆ ObjectInterface() [3/3]

    ObjectInterface ( const ClassInfo *  tbl)
    explicitprivate

    Member Function Documentation

    ◆ GetInterfaceId()

    static maxon::Id GetInterfaceId ( )
    static

    ◆ Alloc() [1/2]

    static ObjectInterface* Alloc ( MAXON_SOURCE_LOCATION_DECLARATION  ,
    const ObjectInterface src 
    )
    static

    ◆ GetPtr() [1/2]

    Ptr GetPtr ( )

    ◆ GetPtr() [2/2]

    ConstPtr GetPtr ( ) const

    ◆ PrivateInstantiateNullValueHelper()

    static maxon::Int PrivateInstantiateNullValueHelper ( )
    static

    ◆ PrivateGetInterface()

    static maxon::InterfaceReference* PrivateGetInterface ( )
    static

    ◆ Alloc() [2/2]

    static ObjectInterface* Alloc ( MAXON_SOURCE_LOCATION_DECLARATION  )
    staticprivate

    ◆ GetInfoOffset()

    static maxon::Int GetInfoOffset ( )
    staticprivate

    ◆ operator=()

    void operator= ( const ObjectInterface )
    private

    ◆ PrivateCheckClass()

    void PrivateCheckClass ( )
    private

    ◆ NullValuePtr()

    static constexpr MAXON_ATTRIBUTE_FORCE_INLINE std::nullptr_t NullValuePtr ( )
    staticconstexpr

    ◆ GetClass()

    MAXON_FUNCTION const maxon::Class<typename REFSUPERCLASS::PrivateErasedReferencedType::Hxx1::ReferenceClass>& GetClass ( ) const

    Returns the class of this object. Each object holds a strong reference on its class.

    Returns
    Class of this object. @MAXON_ANNOTATION{refsuperclassParameter=REFSUPERCLASS}

    ◆ GetClassInfo()

    MAXON_FUNCTION const ClassInfo* GetClassInfo ( ) const

    Returns the class information of this object.

    Returns
    Class information of this object.

    ◆ GetComponentInfoOfSuper() [1/2]

    const ComponentInfo& GetComponentInfoOfSuper ( const REF *  sptr,
    OverloadRank0   
    ) const

    ◆ GetComponentInfoOfSuper() [2/2]

    const ComponentInfo& GetComponentInfoOfSuper ( const REF *  sptr,
    OverloadRank1   
    ) const

    ◆ HasSameClass()

    MAXON_FUNCTION Bool HasSameClass ( const ObjectInterface obj) const

    Tests if this object has the same class as another object obj.

    Parameters
    [in]objAnother object.
    Returns
    True if both objects have the same class.

    ◆ CopyFrom()

    Result<void> CopyFrom ( const ObjectInterface src)

    Copies the data from a source object to this object. This object needs to have a matching component for each component of the source (there may be additional components). Copying is done per component by the CopyFrom function of components.

    Parameters
    [in]srcSource object.
    Returns
    OK on success (for each component of src there is a matching component in this object, and copying the component data succeeded).

    ◆ Clone() [1/2]

    Result<ObjectInterface*> Clone ( ) const

    Clones this object. The result is a new object of the same class where each component is a copy of the corresponding component of this object (as implemented by the CopyFrom function of components).

    Returns
    Clone of this object.

    ◆ Clone() [2/2]

    MAXON_FUNCTION Result<REFCLASS> Clone ( ) const

    Clones this object. The result is a reference to a new object of the same class where each component is a copy of the corresponding component of this object (as implemented by the CopyFrom function of components).

    Returns
    Clone of this object. @MAXON_ANNOTATION{refclassParameter=REFCLASS}

    ◆ IsInstanceOf() [1/2]

    MAXON_FUNCTION Bool IsInstanceOf ( ) const

    Checks if this object is an instance of the given interface I. This is the case if the class of this object has a component which implements I.

    Template Parameters
    IThe interface to check.
    Returns
    True if this object is an instance of #I, false otherwise.

    ◆ IsInstanceOf() [2/2]

    MAXON_FUNCTION Bool IsInstanceOf ( const DataType type) const

    Checks if this object is an instance of the given data type. This is the case if the type is an object type and if the class of this object implements each interface of the object type.

    Parameters
    [in]typeThe data type to check.
    Returns
    True if this object is an instance of type, false otherwise.

    ◆ ToString()

    MAXON_METHOD String ToString ( const FormatStatement formatStatement = nullptr) const

    Returns a readable string of the content.

    Parameters
    [in]formatStatementNullptr or additional formatting instruction. Currently no additional formatting instructions are supported.
    Returns
    The converted result. By default, this is the name of the class, followed by @, followed by the hexadecimal memory address of this object.

    ◆ InitObject()

    MAXON_METHOD Result<void> InitObject ( const void *  argument)

    Initializes the object. This method is invoked implicitly when a new object is created (after InitComponent has been invoked for each component). When the initialization fails, the new object is deleted immediately.

    Parameters
    [in]argumentUnused for now.
    Returns
    Success of initialization.

    ◆ HandleMessage()

    MAXON_METHOD Result<void> HandleMessage ( const InternedId message,
    void *  argument 
    )

    Handles a generic message. The supported messages are defined by the class of the object. The default implementation returns UnsupportedOperationError.

    Parameters
    [in]messageThe message identifier.
    [in]argumentA message-specific argument.
    Returns
    Success of message handling.

    ◆ HandleConstMessage()

    MAXON_METHOD Result<void> HandleConstMessage ( const InternedId message,
    void *  argument 
    ) const

    Handles a generic message. The supported messages are defined by the class of the object. The default implementation returns UnsupportedOperationError.

    Parameters
    [in]messageThe message identifier.
    [in]argumentA message-specific argument.
    Returns
    Success of message handling.

    ◆ IsEqual()

    MAXON_METHOD Bool IsEqual ( const maxon::ObjectInterface other) const

    Compares this and other for equality. If you implement this method in a component, make sure to incorporate the result of the super implementation in the result.

    Parameters
    [in]otherAnother object.
    Returns
    True if both object are equal, false otherwise.

    ◆ Compare()

    MAXON_METHOD COMPARERESULT Compare ( const maxon::ObjectInterface other) const

    Compares this and other. If you implement this method in a component, make sure to incorporate the result of the super implementation in the result.

    Parameters
    [in]otherAnother object.
    Returns
    Result of the comparison.

    ◆ GetHashCode()

    MAXON_FUNCTION HashInt GetHashCode ( ) const

    Returns the hash code of this @CLASS.

    Returns
    Hash code of this @CLASS.

    ◆ GetUniqueHashCode()

    MAXON_FUNCTION UniqueHash GetUniqueHashCode ( ) const

    Returns the 128-bit hash value of this @CLASS. The implementation ensures uniform distribution, so for practical purposes you can safely assume that two objects are equal if their hash values are equal.

    Returns
    Hash value of this @CLASS.

    ◆ GetHashCodeImpl()

    MAXON_METHOD HashInt GetHashCodeImpl ( ) const

    Returns a hash code for this object. If you implement this method in a component, make sure to incorporate the result of the super implementation in the result.

    Returns
    Hash code for this object.

    ◆ GetUniqueHashCodeImpl()

    MAXON_METHOD UniqueHash GetUniqueHashCodeImpl ( ) const

    Returns a 128-bit hash value for this object. The implementation has to ensure uniform distribution, so that one can safely assume that two objects are equal if their hash values are equal. If you implement this method in a component, make sure to incorporate the result of the super implementation in the result.

    Returns
    Hash value for this object.

    ◆ MAXON_ADD_TO_CONST_REFERENCE_CLASS()

    MAXON_ADD_TO_CONST_REFERENCE_CLASS ( Bool  operator = =(std::nullptr_t) const { return RefCompareMAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), nullptr);} Bool operator!=(std::nullptr_t) const { return !RefCompareMAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), nullptr);} Bool operator==(const ObjectInterface *ref) const { return RefCompareMAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} Bool operator!=(const ObjectInterface *ref) const { return !RefCompareMAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} Bool operator==(ObjectInterface *ref) const { return RefCompareMAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} Bool operator!=(ObjectInterface *ref) const { return !RefCompareMAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} template< typename T > Bool operator==(T *ref) const { return RefCompareMAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} template< typename T > Bool operator!=(T *ref) const { return !RefCompareMAXON_IS_COW_KIND(S::Handler::KIND), true >::template IsEqual< const ObjectInterface *, const ObjectInterface * >(this->GetPointer(), ref);} template< typename R, typename=typename maxon::details::DisableComparison< typename S::PrivateReferencedType, typename R::ReferencedType >::type > Bool operator==(const R &ref) const { static_assert(AlwaysFalse< R >::value, "Can't compare unrelated reference classes.");return false;} template< typename R, typename=typename maxon::details::DisableComparison< typename S::PrivateReferencedType, typename R::ReferencedType >::type > Bool operator!=(const R &ref) const { static_assert(AlwaysFalse< R >::value, "Can't compare unrelated reference classes.");return false;})

    ◆ PrivateIsInstanceOf()

    Bool PrivateIsInstanceOf ( const DataType type) const

    ◆ PrivateFreeInstance()

    static void PrivateFreeInstance ( const ObjectInterface o)
    static

    ◆ RemoveReference()

    void RemoveReference ( ) const
    protected

    Friends And Related Function Documentation

    ◆ maxon::ClassInterface

    friend class maxon::ClassInterface
    friend

    ◆ maxon::ComponentDescriptor

    friend class maxon::ComponentDescriptor
    friend

    ◆ maxon::StrongCOWRefHandler

    friend class maxon::StrongCOWRefHandler
    friend

    ◆ ComponentWrapper

    friend class ComponentWrapper
    friend

    ◆ StrongRefHandler

    friend class StrongRefHandler
    friend

    ◆ ClassImpl

    friend class ClassImpl
    friend

    Member Data Documentation

    ◆ _interface

    maxon::InterfaceReference _interface
    static

    ◆ _staticInterface

    maxon::NonvirtualInterfaceReference _staticInterface
    static

    ◆ MAXON_ENUM_LIST_CLASS

    ◆ REFERENCE_KIND

    const maxon::EntityBase::FLAGS REFERENCE_KIND
    static

    ◆ INTERFACE_FLAGS

    const EntityBase::FLAGS INTERFACE_FLAGS
    static