#include <objectbase.h>
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 ObjectInterface * | Alloc (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 ObjectInterface * | Alloc (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 |
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 |
|
protected |
|
private |
|
private |
|
explicitprivate |
|
static |
|
static |
Ptr GetPtr | ( | ) |
ConstPtr GetPtr | ( | ) | const |
|
static |
|
static |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
staticconstexpr |
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.
MAXON_FUNCTION const ClassInfo* GetClassInfo | ( | ) | const |
Returns the class information of this object.
const ComponentInfo& GetComponentInfoOfSuper | ( | const REF * | sptr, |
OverloadRank0 | |||
) | const |
const ComponentInfo& GetComponentInfoOfSuper | ( | const REF * | sptr, |
OverloadRank1 | |||
) | const |
MAXON_FUNCTION Bool HasSameClass | ( | const ObjectInterface * | obj | ) | const |
Tests if this object has the same class as another object obj.
[in] | obj | Another object. |
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.
[in] | src | Source object. |
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).
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).
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
.
I | The interface to check. |
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.
[in] | type | The data type to check. |
MAXON_METHOD String ToString | ( | const FormatStatement * | formatStatement = nullptr | ) | const |
Returns a readable string of the content.
[in] | formatStatement | Nullptr or additional formatting instruction. Currently no additional formatting instructions are supported. |
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.
[in] | argument | Unused for now. |
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.
[in] | message | The message identifier. |
[in] | argument | A message-specific argument. |
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.
[in] | message | The message identifier. |
[in] | argument | A message-specific argument. |
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.
[in] | other | Another object. |
MAXON_METHOD COMPARERESULT Compare | ( | const maxon::ObjectInterface * | other | ) | const |
MAXON_FUNCTION HashInt GetHashCode | ( | ) | const |
Returns the hash code of this @CLASS.
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.
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.
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.
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;} | ) |
|
static |
|
protected |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
static |
|
static |
maxon::ObjectInterface::ReferenceFunctions MAXON_ENUM_LIST_CLASS |
|
static |
|
static |