-
首页
-
C4D R23.110 C++ SDK
ClassInterface Class Reference
系统
#include <objectbase.h>
详细描述
A
ClassInterface
object represents an object class at runtime, see vinterfaces. Such an object class can be published by MAXON_DECLARATION, and it is then typically defined by MAXON_COMPONENT_CLASS_REGISTER.
A class consists of several components (see
ComponentDescriptor
), each of which may implement several virtual interfaces (declared by MAXON_INTERFACE). The class itself then implements all interfaces of all of its components. Information about components and interfaces can be obtained from the ClassInfo object returned by GetClassInfo().
After allocation of a class, you have to add the components of which it shall consist via
AddComponent()
or
AddComponents()
. Afterwards, you can invoke
Finalize()
to make the class ready for use. From then on, only const methods may be invoked on a class. If you use GenericClass or
Class
to access a class, this is automatically guaranteed as those are const references. If you don't invoke
Finalize()
, this will be done implicitly when the first instance of the class is allocated.
The MAXON_COMPONENT_CLASS_REGISTER and MAXON_COMPONENT_OBJECT_REGISTER macros greatly simplify the setup of a class.
ClassInterface
objects are automatically registered at the
Classes
registry, so with
Class<MyType> cls = Classes::Get<MyType>(
"com.foo.class.bar"
);
you can look for the class with identifier "com.foo.class.bar".
MyType
is the expected reference type of instances of the class.
Member Enumeration Documentation
◆
KIND
An object class is of one of the kinds defined by this enum.
Enumerator
|
NORMAL
|
A normal object class.
|
SINGLETON
|
A singleton object class, i.e., a class with exactly one instance. The instance can be obtained with
Create()
.
|
ABSTRACT
|
An abstract object class.
Create()
will return an UnsupportedOperationError.
|
成员函数文档编制
◆
MAXON_INTERFACE_NONVIRTUAL()
◆
MAXON_GENERIC()
MAXON_GENERIC
|
(
|
(
Out
) typename
|
REF
=
ObjectRef
|
)
|
|
|
private
|
◆
MAXON_ENUM_LIST_CLASS()
◆
Alloc()
Allocates a new
ClassInterface
object with a given identifier. The new class doesn't contain any components, you have to add them afterwards by
AddComponent()
or
AddComponents()
, and to finally invoke Finalize to complete the class.
-
参数
-
-
返回
-
Pointer to a new
ClassInterface
对象。
◆
GetId()
Returns the identifier of this object class.
Class
identifiers are unique and should follow the naming convention TODO: (Ole).
-
返回
-
Class
identifier.
◆
GetKind()
Returns the kind of this object class, see KIND.
-
返回
-
Kind of this object class.
◆
GetComponents()
Returns a list of all class components. The components are in order of registration.
-
返回
-
Reference to the list of components.
◆
AddComponent()
Adds a component to this class. The class must not yet have been finalized (by invocation of
Finalize()
). The added component will overwrite the vtables of the interfaces it implements (see InterfaceInfo), but the previous values are stored (in the _supervtable member of ComponentInfo) and used by the Super function of the component implementation.
-
参数
-
[in]
|
component
|
Component to add.
|
-
返回
-
OK on success. In the case of an error, the class hasn't been changed.
-
另请参阅
-
AddComponents
◆
RemoveLastComponent()
@MAXON_ANNOTATION{refclass=false}
◆
AddComponents()
Adds all components of class cls to this class. This class must not yet have been finalized (by invocation of
Finalize()
). The addition is done in the same order as for the original class. Afterwards, cls can be seen as a base class of this class.
-
参数
-
[in]
|
cls
|
Implementation class of the component to add.
|
-
返回
-
OK on success. In the case of an error, the class shouldn't be used.
-
另请参阅
-
AddComponent
◆
Finalize()
Finalizes this class so that it can be used afterwards. The class has to be built before by
AddComponent()
. Some internal data will be set-up for the class so that it is ready for use. If you don't invoke
Finalize()
, it will be done implicitly when an object of the class is instantiated for the first time.
-
返回
-
OK on success. If an error occurred, the class shouldn't be used.
-
另请参阅
-
AddComponent
◆
IsFinalized()
Returns true if the class has been finalized successfully before.
-
返回
-
True if the class is finalized.
-
另请参阅
-
Finalize
◆
GetImplementedInterfaces()
const
MAXON_METHOD
Block
<const InterfaceReference* const>& GetImplementedInterfaces
|
(
|
|
)
|
const
|
Returns a block of all interfaces which this class implements. For each interface, the block will also contain its base interfaces. The interfaces will be sorted according to their depth and, at second level, to their ids.
-
返回
-
Block
of all implemented interfaces.
◆
GetDataType()
Returns the data type corresponding to the set of implemented interfaces of this class. For an abstract class this will return nullptr.
-
返回
-
数据
type of this class.
◆
Create()
Constructs a new instance of this class. This will invoke the constructors of each component in the order of addition, and then the InitComponent functions of each component. When one of the InitComponent functions fails with an error, FreeComponent will be invoked on the previous (already initialized) components, the component destructors will be invoked, the memory will by freed, and
Create()
returns the error.
For a singleton class, this doesn't create a new instance, but returns the singleton instance of this class. This instance is automatically created on finalization of the class.
For an abstract class, this will always return an UnsupportedOperationError.
-
返回
-
Reference to new instance, or an error if the allocation or initialization failed.
◆
CreatePointer()
Constructs a new instance of this class. This will invoke the constructors of each component in the order of addition, and then the InitComponent functions of each component. When one of the InitComponent functions fails with an error, FreeComponent will be invoked on the previous (already initialized) components, the component destructors will be invoked, the memory will by freed, and
CreatePointer()
returns the error.
For an abstract class, this will always return an UnsupportedOperationError.
The reference counter of the returned object will be zero.
-
返回
-
Pointer to the new instance, or an error if the allocation or initialization failed.
-
警告
-
This function must not be used for a singleton class, use
Create()
instead.
@MAXON_ANNOTATION{refclass=false}
◆
Implements()
[1/2]
Checks if the class implements the interface iref. This means that this class contains a component implementing the interface.
-
参数
-
-
返回
-
True if this class implements the interface, false otherwise.
◆
Implements()
[2/2]
Checks if the class implements the interface I. This means that this class contains a component implementing the interface.
-
Template Parameters
-
-
返回
-
True if this class implements the interface I, false otherwise.
◆
IsSubclassOf()
Checks if this class is a subclass of #other, i.e., if this class has all components of #other.
-
参数
-
[in]
|
other
|
Another class.
|
-
返回
-
True if this class is a subclass of #other, false otherwise.
◆
ToString()
Returns a readable string of the content.
-
参数
-
[in]
|
formatStatement
|
Nullptr or additional formatting instruction. Currently no additional formatting instructions are supported.
|
-
返回
-
The converted result. The representation consists of the class identifier prefixed by "class ".
◆
DeleteInstance()
Deletes an instance of a class. This is automatically invoked if the reference count of the instance reaches zero.
-
参数
-
[in]
|
object
|
Instance to delete, must not be nullptr.
|
◆
DestructInstance()
Destructs an instance of a class. This is automatically invoked if the reference count of the instance reaches zero.
-
参数
-
[in]
|
object
|
Instance to destruct, must not be nullptr.
|
◆
CopyInstance()
Copies the component data of objects. This is invoked by
ObjectInterface::CopyFrom
.
-
参数
-
[out]
|
dest
|
Destination object, may be nullptr.
|
[in]
|
src
|
Source object, may be nullptr.
|
-
返回
-
OK on success. This will report a NullptrError if any of the arguments is nullptr.
◆
GetInfo()
Returns the ClassInfo object of this class. This is only needed internally.
-
返回
-
ClassInfo object of this class. Will never be nullptr.
◆
GetOrCreateMTable()
static
MAXON_METHOD
void* GetOrCreateMTable
|
(
|
ClassInfo *
|
info
,
|
|
|
const InterfaceReference &
|
i
|
|
)
|
|
|
|
static
protected
|
Returns a pointer to the MTable for the interface having the specified offset. The memory for the MTable is allocated if necessary.
-
参数
-
[in]
|
info
|
ClassInfo object.
|
[in]
|
i
|
The interface for which the method table shall be obtained.
|
-
返回
-
Pointer to the MTable of the interface, or nullptr if the MTable allocation failed.
◆
GetValidInterfaceInfo()
static const InterfaceInfo* GetValidInterfaceInfo
|
(
|
const ClassInfo *
|
info
,
|
|
|
Int
|
offset
|
|
)
|
|
|
|
static
protected
|
Returns the InterfaceInfo for the interface having the specified offset.
-
参数
-
[in]
|
info
|
ClassInfo object of the class in question.
|
[in]
|
offset
|
Offset of the interface within the interface table.
|
-
返回
-
InterfaceInfo object, or nullptr if the class doesn't implement the interface.
◆
AddProxyComponent()
Friends And Related Function Documentation
◆
ObjectInterface
◆
ObjectModel
friend class ObjectModel
|
friend
|
◆
ComponentDescriptor
◆
reflection::ProxyImpl
friend class reflection::ProxyImpl
|
friend
|
◆
CombinedMTableBase
friend struct CombinedMTableBase
|
friend
|
◆
ComponentWithBase