maxon.ClassInterface¶
Description¶
A
maxon.ClassInterface
object represents an object class at runtime.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
ComponentDescriptor()
).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
ObjectInterface.GetClassInfo()
.After allocation of a class, you have to add the components of which it shall consist via
ClassInterface.AddComponent()
or ClassInterface.AddComponents()
.Afterwards, you can invoke
ClassInterface.Finalize()
to make the class ready for use.From then on, only const methods may be invoked on a class.
If you use
maxon.GenericClass
or maxon.Class
to access a class,
this is automatically guaranteed as those are const references.If you don’t invoke
ClassInterface.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.maxon.ClassInterface
objects are automatically registered in the maxon.Classes
registry.Warning
This function is only there to expose a C++ Object to Python.
As a Python developer you normally don’t have to deal with this function.
Attributes¶
maxon.ClassInterface.R |
Stores the passed reference type if created e.g. |
Methods Signature¶
Create ([type]) |
Constructs a new instance of this class.
|
||
CreateRef () |
Constructs a new instance of this class.
|
||
Finalize () |
Finalizes this class so that it can be used afterwards.
|
||
GetDataType () |
Returns the data type corresponding to the set of implemented interfaces of this class. | ||
GetId () |
|
||
GetKind () |
Returns the identifier of this object class. | ||
IsFinalized () |
Returns True if the class has been finalized successfully before. |
Methods Definition¶
-
ClassInterface.
Create
(type=None)¶ - Constructs a new instance of this class.This will invoke the constructors of each component in the order of addition, and then the ComponentRoot.InitComponent functions of each component.When one of the
ComponentRoot.InitComponent()
functions fails with an error,ComponentRoot.FreeComponent()
will be invoked on the previous (already initialized) components, the component destructors will be invoked, the memory will by freed, andClassInterface.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 raise an error.Parameters: - type – The expected type of object to create.
- type – maxon API type.
Returns: Reference to new instance, or an error if the allocation or initialization failed.
Return type: Any.
-
ClassInterface.
CreateRef
()¶ - Constructs a new instance of this class.This will invoke the constructors of each component in the order of addition, and then the ComponentRoot.InitComponent functions of each component.When one of the
ComponentRoot.InitComponent()
functions fails with an error,ComponentRoot.FreeComponent()
will be invoked on the previous (already initialized) components, the component destructors will be invoked, the memory will by freed, andClassInterface.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 raise an error.Returns: Reference to new instance, or an error if the allocation or initialization failed. Return type: Any.
-
ClassInterface.
Finalize
()¶ - Finalizes this class so that it can be used afterwards.The class has to be built before by
ClassInterface.AddComponent()
.Some internal data will be set-up for the class so that it is ready for use.If you don’t invokeClassInterface.Finalize()
, it will be done implicitly when an object of the class is instantiated for the first time.
-
ClassInterface.
GetDataType
()¶ Returns the data type corresponding to the set of implemented interfaces of this class.
Note
For an abstract class this will return None.
Returns: Data type of this class. Return type: maxon.DataType
-
ClassInterface.
GetId
()¶ Returns:
-
ClassInterface.
GetKind
()¶ Returns the identifier of this object class. Class identifiers are unique.
Returns: maxon.Class
identifier.Return type: maxon.Id
-
ClassInterface.
IsFinalized
()¶ Returns True if the class has been finalized successfully before.
Returns: True if the class is finalized. Return type: bool