ExecutionInterface Manual

Table of Contents

About

maxon::ExecutionInterface is a template for a job that is executed on Cinema 4D startup.

Note
A maxon::ExecutionInterface is often used together with Configuration Variables to perform a task based on a given command line argument.
Warning
The jobs defined with the ExecutionInterface are started as soon as all components of the MAXON API are loaded. At this point Cinema 4D itself and the classic API may not yet be available. So it is not advised to use any component of the classic API in this context.

Usage

A new class is created based on the maxon::ExecutionInterface template. In this new class one must implement the function call operator "()" to define the code that should be executed.

// This example shows a simple implementation of a custom class based on ExecutionInterface.
class RegisterHelloWorldExecution : public maxon::ExecutionInterface<RegisterHelloWorldExecution>
{
public:
maxon::Result<void> operator ()()
{
// after Cinema has started, this text is printed to the console
DiagnosticOutput("Hello World!");
return maxon::OK;
}
};

The new class must then be added to the maxon::ExecutionJobs registry:

// This example shows how a custom class based on ExecutionInterface is added to the ExecutionJobs registry.
MAXON_DECLARATION_REGISTER(maxon::ExecutionJobs, "net.maxonexample.execution.helloworld")
{
return NewObj(RegisterHelloWorldExecution);
}

The code defined in the function call operator will then be executed after Cinema 4D has started and loaded all resources.

Note
The jobs registered at ExecutionJobs are executed in alphanumerical order based on their IDs.

Further Reading

MAXON_DECLARATION_REGISTER
#define MAXON_DECLARATION_REGISTER(...)
Definition: module.h:866
maxon::OK
return OK
Definition: apibase.h:2490
DiagnosticOutput
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:168
maxon::JobInterfaceTemplate
Definition: job.h:1053
maxon::Result< void >
iferr_scope
#define iferr_scope
Definition: resultbase.h:1343
NewObj
#define NewObj(T,...)
Definition: newobj.h:108