About
An interface defines a class that is the base for both the implementation and the automatically created reference class. It is possible to add annotations to the interface to change the behaviour of the Source Processor when creating the reference class.
Annotations are added as comments in this form:
Interface Annotations
Annotations can be added to the interface itself. These annotations define the overall creation of the reference class.
- refclass: Defines how the reference class is created. Valid settings are:
- false: No reference class is created.
- refprefix: Defines a prefix that is added to the reference class name.
Method Annotations
Annotations can also be added to single functions of the interface.
- refclass: If set to false the function is not added to the reference class.
- default: Defines the default return value in case of an error (e.g. no implementation was found).
- refclassParameter: Set to the name of a function template parameter that should be replaced with the actual reference class.
Special annotations for COW interfaces are:
- cowName: Changes the name of the generated function of the COW reference class.
Usage
Annotations are used on the definition of the interface.
{
public:
{
Element* e = GetElement(index);
if (e == nullptr)
return e;
}
{
return REFCLASS(static_cast<typename REFCLASS::ReferencedType*>(o));
}
};
The behaviour of the created reference class is defined by the annotations.
GenericElementArrayRef nullValue;
const maxon::Int index = nullValue.FindIndex(
nullptr);
const GenericElementArrayRef elementArray = componentClass.Create()
iferr_return;
GenericElementArrayRef elements = elementArray.CloneArray()
iferr_return;
Element*
const e = elementArray.GetElementResult(-1)
iferr_return;
Further Reading