Skip to main content

commands::ICommand

commands::ICommand

Base class for all commands operating on DataManager. More…

#include <ICommand.hpp>

Inherited by commands::AddInterval, commands::AdvanceFrame, commands::ClearLineDataAtTime, commands::CopyByTimeRange, commands::FlipEventAtTime, commands::ForEachKey, commands::LoadData, commands::MoveByTimeRange, commands::RunTransformsV2Pipeline, commands::RunTransformsV2PipelineAtTime, commands::SaveData, commands::SetEventAtTime, commands::SynthesizeData, commands::UpsampleTimeFrame

Public Functions

Name
virtual ~ICommand() =default
virtual CommandResult execute(CommandContext const & ctx) =0
Execute the command against the DataManager in ctx.
virtual std::string commandName() const =0
Return the human-readable command name.
virtual std::string toJson() const =0
Serialize command parameters to JSON.
virtual bool isUndoable() const
Report whether this command supports undo.
virtual CommandResult undo(CommandContext const & ctx)
Revert the effects of a prior execute() call.
virtual int mergeId() const
Return an identifier used for undo merging.
virtual bool mergeWith(ICommand const & other)
Attempt to merge this command with a subsequent command of the same type.

Detailed Description

class commands::ICommand;

Base class for all commands operating on DataManager.

Each command holds its own parameters, implements execute(), and optionally implements undo(). There is one interface for both execution and undo — no separate IUndoableCommand hierarchy.

Public Functions Documentation

function ~ICommand

virtual ~ICommand() =default

function execute

virtual CommandResult execute(
    CommandContext const & ctx
) =0

Execute the command against the DataManager in ctx.

Parameters:

  • ctx Runtime execution context (DataManager, time controller, etc.).

Return: Success or failure result, including affected data keys on success.

Reimplemented by: commands::AddInterval::execute, commands::AdvanceFrame::execute, commands::ClearLineDataAtTime::execute, commands::CopyByTimeRange::execute, commands::FlipEventAtTime::execute, commands::ForEachKey::execute, commands::LoadData::execute, commands::MoveByTimeRange::execute, commands::RunTransformsV2Pipeline::execute, commands::RunTransformsV2PipelineAtTime::execute, commands::SaveData::execute, commands::SetEventAtTime::execute, commands::SynthesizeData::execute, commands::UpsampleTimeFrame::execute

function commandName

virtual std::string commandName() const =0

Return the human-readable command name.

Return: Stable command name string.

Reimplemented by: commands::AddInterval::commandName, commands::AdvanceFrame::commandName, commands::ClearLineDataAtTime::commandName, commands::CopyByTimeRange::commandName, commands::FlipEventAtTime::commandName, commands::ForEachKey::commandName, commands::LoadData::commandName, commands::MoveByTimeRange::commandName, commands::RunTransformsV2Pipeline::commandName, commands::RunTransformsV2PipelineAtTime::commandName, commands::SaveData::commandName, commands::SetEventAtTime::commandName, commands::SynthesizeData::commandName, commands::UpsampleTimeFrame::commandName

Used for journal entries and UI display. Must match the name registered in CommandRegistry.

function toJson

virtual std::string toJson() const =0

Serialize command parameters to JSON.

Return: JSON string representing the command parameters.

Reimplemented by: commands::AddInterval::toJson, commands::AdvanceFrame::toJson, commands::ClearLineDataAtTime::toJson, commands::CopyByTimeRange::toJson, commands::FlipEventAtTime::toJson, commands::ForEachKey::toJson, commands::LoadData::toJson, commands::MoveByTimeRange::toJson, commands::RunTransformsV2Pipeline::toJson, commands::RunTransformsV2PipelineAtTime::toJson, commands::SaveData::toJson, commands::SetEventAtTime::toJson, commands::SynthesizeData::toJson, commands::UpsampleTimeFrame::toJson

Typically implemented via rfl::json::write on the command’s params struct.

function isUndoable

inline virtual bool isUndoable() const

Report whether this command supports undo.

Return: True if undo() is implemented; false by default.

Reimplemented by: commands::ForEachKey::isUndoable, commands::LoadData::isUndoable, commands::MoveByTimeRange::isUndoable

function undo

inline virtual CommandResult undo(
    CommandContext const & ctx
)

Revert the effects of a prior execute() call.

Parameters:

  • ctx Runtime execution context (DataManager, time controller, etc.).

Return: Success or failure result. Default implementation returns an error indicating undo is not supported.

Reimplemented by: commands::ForEachKey::undo, commands::LoadData::undo, commands::MoveByTimeRange::undo

function mergeId

inline virtual int mergeId() const

Return an identifier used for undo merging.

Return: Merge identifier, or -1 if not mergeable.

Commands with the same non-negative merge id may be coalesced into a single undo step. A value of -1 means the command is never mergeable.

function mergeWith

inline virtual bool mergeWith(
    ICommand const & other
)

Attempt to merge this command with a subsequent command of the same type.

Parameters:

  • other The subsequent command candidate for merging.

Return: True if other was absorbed into this command; false by default.

Called when two consecutive executed commands share the same mergeId(). If merge succeeds, only one undo step is retained.


Updated on 2026-11-13 at 20:25:42 +0000