About
maxon::CommandClassInterface is a base interface for standardized commands. Such a command operates solely on the given input data and can be used in various situations.
CommandClassInterface
A custom command must implement these two methods:
An implementation for such a data object must be based on maxon::CommandDataInterface which in return in based on maxon::DataDictionaryObjectInterface.
- Note
- All data related to the execution of the command must be stored in the maxon::CommandDataRef object.
Interactive commands (e.g. tools) can also implement maxon::CommandInteractionClassInterface:
class ExampleDataImpl :
public Component<ExampleDataImpl, CommandDataInterface>
{
public:
{
return super.SetData(std::move(
key), std::move(data));
}
{
return super.GetData(std::move(
key));
}
};
class ExampleCommandImpl :
public Component<ExampleCommandImpl, CommandClassInterface>
{
public:
MAXON_METHOD Result<COMMANDSTATE> GetState(CommandDataRef& data)
const
{
}
MAXON_METHOD Result<COMMANDRESULT> Execute(CommandDataRef& data)
const
{
}
};
PyObject * key
Definition: abstract.h:289
SKIP
Definition: asset_browser.h:0
ENABLED
The command asset is enabled.
Definition: asset_command.h:1
Py_UCS4 * res
Definition: unicodeobject.h:1113
@ NORMAL
Normal Tag morphing.
int32_t Int32
32 bit signed integer datatype.
Definition: apibase.h:190
ComponentWithBase< C, ComponentRoot, INTERFACES... > Component
Definition: objectbase.h:2798
#define MAXON_COMPONENT(KIND,...)
Definition: objectbase.h:2212
#define MAXON_COMPONENT_CLASS_REGISTER(C,...)
Definition: objectbase.h:2410
#define MAXON_METHOD
Definition: interfacebase.h:1012
#define MAXON_COMPONENT_OBJECT_REGISTER(C,...)
Definition: objectbase.h:2473
@ OK
The command was executed properly.
COMMANDSTATE
Defines if a command can be executed or not.
Definition: commandbase.h:28
@ ENABLED
The command can be executed.
#define iferr_scope
Definition: resultbase.h:1389
#define iferr_return
Definition: resultbase.h:1524
LegacyCommandClassInterface
Some classic data types like BaseContainer cannot be stored in a maxon::DataDictionary. Therefore a custom data class is needed to store specific custom data. Such a data class can be implemented based on maxon::LegacyCommandDataInterface:
maxon::LegacyCommandClassInterface is based on maxon::CommandClassInterface. It can be implemented if custom data should be handled.
struct MoGraphSetupData
{
{
}
};
Definition: c4d_basedocument.h:497
Definition: c4d_baseobject.h:248
PyObject * other
Definition: dictobject.h:70
return OK
Definition: apibase.h:2735
class MoGraphSetupDataImpl :
public Component<MoGraphSetupDataImpl, LegacyCommandDataInterface>
{
public:
{
return 1;
}
{
Generic* const dtaPtr = reinterpret_cast<Generic*>(&_data);
return dtaPtr;
}
{
if (data == nullptr)
const MoGraphSetupData* const moGraphData = reinterpret_cast<const MoGraphSetupData*>(data);
}
{
return super.SetData(std::move(
key), std::move(data));
}
{
return super.GetData(std::move(
key));
}
private:
MoGraphSetupData _data;
};
class MoGraphSetupCommandImpl :
public Component<MoGraphSetupCommandImpl, CommandClassInterface>
{
public:
MAXON_METHOD Result<COMMANDSTATE> GetState(CommandDataRef& data)
const
{
}
MAXON_METHOD Result<COMMANDRESULT> Execute(CommandDataRef& data)
const
{
LegacyCommandDataRef legacyData = Cast<LegacyCommandDataRef>(data);
MoGraphSetupData& moData = legacyData.GetLegacyData<MoGraphSetupData>(dataIndex)
iferr_return;
if (moData._doc == nullptr)
if (moData._object == nullptr)
{
BaseObject*
const activeObject = moData._doc->GetActiveObject();
if (activeObject == nullptr)
moData._object = activeObject;
}
if (cloner == nullptr)
moData._doc->InsertObject(cloner, nullptr, nullptr);
moData._object->Remove();
moData._doc->InsertObject(moData._object, cloner, nullptr);
moData._cloner = cloner;
}
};
static BaseObject * Alloc(Int32 type)
Py_ssize_t * index
Definition: abstract.h:374
@ OK
User has selected a font.
maxon::Int Int
Definition: ge_sys_math.h:60
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:202
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
Data
The data a command operates on is stored in a data object. A default data implementation is stored at maxon::CommandDataClasses::BASE. A custom data class can be implemented based on:
Calling Commands
A given command can be executed by calling the "Invoke" of the data object.
namespace CommandDataClasses
{
MAXON_DECLARATION(CommandDataClasses::EntryType, EXAMPLEDATA,
"net.maxonexample.commanddata.exampledata");
}
namespace CommandClasses
{
MAXON_DECLARATION(CommandClasses::EntryType, EXAMPLE,
"net.maxonexample.command.addition");
MAXON_DECLARATION(CommandClasses::EntryType, MOGRAPHSETUP,
"net.maxonexample.command.mographsetup");
}
namespace LegacyCommandDataClasses
{
MAXON_DECLARATION(LegacyCommandDataClasses::EntryType, MOGRAPHSETUPDATA,
"net.maxonexample.legacycommanddata.mographsetup");
}
#define MAXON_DECLARATION(T, Name, id,...)
Definition: module.h:937
maxon::CommandDataRef data = maxon::CommandDataClasses::EXAMPLEDATA().Create()
iferr_return;
const auto command = maxon::CommandClasses::EXAMPLE();
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:170
COMMANDRESULT
Defines the result of the command after execution.
Definition: commandbase.h:37
MoGraphSetupData data;
data._object = nullptr;
maxon::LegacyCommandDataRef legacyData = maxon::LegacyCommandDataClasses::MOGRAPHSETUPDATA().Create()
iferr_return;
legacyData.SetLegacyData<MoGraphSetupData>(data, dataIndex)
iferr_return;
const auto command = maxon::CommandClasses::MOGRAPHSETUP();
const MoGraphSetupData
result = legacyData.GetLegacyData<MoGraphSetupData>(dataIndex)
iferr_return;
result._cloner->SetName(
"The New Cloner"_s);
PyObject PyObject * result
Definition: abstract.h:43
const char * doc
Definition: pyerrors.h:226
Further Reading