An interface declares various methods. These methods must either be defined in an implementation of that interface or in the interface itself. Depending on the type of function, a method will also be part of the generated reference class.
The attribute MAXON_METHOD declares a function that must be defined in an implementation of the given interface.
A declaration of a MAXON_METHOD looks like this:
The implementation of this MAXON_METHOD is defined as:
Finally this method can be used with the generated reference class:
If a MAXON_METHOD marked function is private
or protected
, it can still be defined in an implementation. But it will not be added to the reference class.
The attribute MAXON_FUNCTION defines a method that cannot be defined in a component. Instead it must be defined in the interface declaration. The method is added to the generated reference class.
The method can be used with the reference class.
A function that is added to an interface without any attribute cannot be defined in a component and will not be part of the generated reference class. It can only act as an (internal) utility function that is used within other functions.
With these attributes it is possible to add any additional code (e.g. simple functions) to the generated reference class.
typedefs
, using
, etc. The function that was defined this way is simply used with the reference class:
Often interfaces contain both const and non-const functions to access internal data. This can easily be implemented with MAXON_NONCONST_COUNTERPART. See Generic Macros.