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:
  MAXON_METHOD Result<void> SetData(ForwardingDataPtr&& key, Data&& data)
 
  {
    return super.SetData(std::move(key), std::move(data));
  }
 
  MAXON_METHOD Result<Data> GetData(
const ConstDataPtr& key)
 const 
  {
    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 
  {
 
 
    
 
    
 
    
 
  }
};
 
SKIP
Definition: asset_browser.h:0
ENABLED
The command asset is enabled.
Definition: asset_command.h:1
int32_t Int32
32 bit signed integer datatype.
Definition: apibase.h:175
ComponentWithBase< C, ComponentRoot, INTERFACES... > Component
Definition: objectbase.h:2815
#define MAXON_COMPONENT(KIND,...)
Definition: objectbase.h:2229
#define MAXON_COMPONENT_CLASS_REGISTER(C,...)
Definition: objectbase.h:2427
#define MAXON_METHOD
Definition: interfacebase.h:1020
#define MAXON_COMPONENT_OBJECT_REGISTER(C,...)
Definition: objectbase.h:2490
NORMAL
Definition: lib_birender.h:2
@ 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:1396
#define iferr_return
Definition: resultbase.h:1531
  
LegacyCommandClassInterface
Some Cinema API 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
{
  {
    _doc = other._doc;
    _cloner = other._cloner;
    _object = other._object;
  }
 
  BaseDocument* _doc = nullptr;     
  BaseObject*   _cloner = nullptr;  
  BaseObject*   _object = nullptr;  
};
return OK
Definition: apibase.h:2771
  
 
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);
  }
 
  MAXON_METHOD Result<void> SetData(ForwardingDataPtr&& key, Data&& data)
 
  {
    return super.SetData(std::move(key), std::move(data));
  }
 
  MAXON_METHOD Result<Data> GetData(
const ConstDataPtr& key)
 const 
  {
    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;
    }
 
    
    BaseObject* const cloner = BaseObject::Alloc(1018544);
    if (cloner == nullptr)
 
    moData._doc->InsertObject(cloner, nullptr, nullptr);
    
    moData._object->Remove();
    moData._doc->InsertObject(moData._object, cloner, nullptr);
 
    
    moData._cloner = cloner;
 
  }
};
 
OK
User has selected a font.
Definition: customgui_fontchooser.h:0
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:187
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
maxon::Int Int
Definition: ge_sys_math.h:55
  
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:939
    
 
  
  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._doc = doc;
  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);
Further Reading