About
The functionality presented by an interface is used by creating an instance of the reference class. The definition of that reference class is created automatically based on the interface class by the Source Processor and is stored in the automatically generated
.hxx files.
A reference object gives access to a component or just contains a maxon::NullValue. Reference objects are typically reference counted (depending on the Reference Type).
Reference Objects
A simple interface can be defined like this:
{
public:
};
#include "simpleclass1.hxx"
MAXON_DECLARATION(SimpleClassRef, OtherSimpleClass,
"net.maxonexample.othersimpleclass");
#include "simpleclass2.hxx"
[interfaces_basic_virtual_interface]
Definition: simpleclass.h:15
MAXON_METHOD void SetNumber(maxon::Int number)
MAXON_INTERFACE(SimpleClassInterface, MAXON_REFERENCE_NORMAL, "net.maxonexample.interfaces.simpleclass")
MAXON_METHOD maxon::Int GetNumber() const
Definition: objectbase.h:709
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
#define MAXON_REFERENCE_NORMAL(FREEIMPL)
Definition: interfacebase.h:1173
#define MAXON_DECLARATION(T, Name, id,...)
Definition: module.h:857
#define MAXON_METHOD
Definition: interfacebase.h:1001
#define MAXON_INTERFACE_BASES(...)
Definition: objectbase.h:1062
There are multiple ways to create a reference object. One way is to access the component class of the desired implementation. This component class is identified with a maxon::Id.
The direct way to obtain the component class is to get it from the global registry maxon::Classes with maxon::Classes::Get().
const maxon::Id id {
"net.maxonexample.class.somesimpleclass" };
const SimpleClassRef simpleClass = componentClass.Create()
iferr_return;
simpleClass.SetNumber(123);
const maxon::Int number = simpleClass.GetNumber();
Definition: apibaseid.h:253
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
#define iferr_return
Definition: resultbase.h:1519
Alternatively a reference object can be created from an implementation that is exposed as a published object with MAXON_DECLARATION. See also Published Objects.
const SimpleClassRef simpleClass = SomeSimpleClass().Create()
iferr_return;
simpleClass.SetNumber(456);
const maxon::Int number = simpleClass.GetNumber();
It is also possible to obtain components from a registry. See Registry Usage.
const maxon::Id redID {
"net.maxonexample.class.colors.red" };
if (componentClass == nullptr)
const ColorRef color = componentClass->Create()
iferr_return;
Definition: string.h:1235
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
A color consisting of three components R, G and B.
Definition: col.h:16
ClassInterface
Component classes are based on maxon::ClassInterface. This base class provides basic functionality to create instances.
Functions for instance creation (behaviour depends on the Reference Types):
Information on the component class can be obtained with:
The components of the class are accessed with these functions. It is typically not needed to use these functions:
Object Class
Most interfaces (and objects) are based on the maxon::ObjectInterface interface. For details see Object Interface.
Further Reading