Skip to main content

Command Introspection

Overview

The command introspection system provides runtime metadata about registered commands. This enables UI components to build command pickers, generate parameter forms, and display command documentation — all without hard-coding knowledge of specific commands.

CommandInfo

CommandInfo is a plain struct that holds static metadata for one registered command:

struct CommandInfo {
    std::string name;                              // "MoveByTimeRange"
    std::string description;                       // Human-readable description
    std::string category;                          // "data_mutation", "meta", etc.
    bool supports_undo = false;                    // Whether the command supports undo
    std::vector<std::string> supported_data_types; // e.g. {"LineData", "PointData"}
    ParameterSchema parameter_schema;              // Full field-level schema
};

Source: src/Commands/Core/CommandInfo.hpp

Factory Query Functions

Two functions in CommandFactory.hpp provide access to command metadata:

/// Return metadata for all registered commands
std::vector<CommandInfo> getAvailableCommands();

/// Return metadata for a single command, or std::nullopt if unknown
std::optional<CommandInfo> getCommandInfo(std::string const & name);

These delegate to CommandRegistry::instance(). Each library’s register_*_commands() function supplies both the creator and CommandInfo when registering a command via registerTypedCommand<>.

ParameterUIHints Specializations

Each command’s parameter struct has a ParameterUIHints<T> specialization in CommandUIHints.hpp that annotates fields with tooltips and UI flags. These are automatically applied by extractParameterSchema<T>().

Source: src/Commands/CommandUIHints.hpp

Current Annotations

Command Fields Annotated
MoveByTimeRangeParams All 4 fields: tooltips for source_key, destination_key, start_frame, end_frame
CopyByTimeRangeParams All 4 fields: same as MoveByTimeRange
AddIntervalParams All 4 fields: tooltips for interval_key, frames, and create_if_missing
ForEachKeyParams All 3 fields: tooltips for items, variable, commands (commands marked advanced)

Usage Example

#include "Commands/Core/CommandFactory.hpp"

// List all commands for a picker UI
auto commands = commands::getAvailableCommands();
for (auto const & cmd : commands) {
    // cmd.name, cmd.description, cmd.category for display
    // cmd.parameter_schema.fields for generating form widgets
}

// Get schema for a specific command
auto info = commands::getCommandInfo("MoveByTimeRange");
if (info) {
    for (auto const & field : info->parameter_schema.fields) {
        // field.name, field.type_name, field.tooltip, etc.
    }
}

Registered Commands

Command Library Category Undo Supported Types Fields
MoveByTimeRange Commands data_mutation Yes LineData, PointData, MaskData, DigitalEventSeries 4
CopyByTimeRange Commands data_mutation No LineData, PointData, MaskData, DigitalEventSeries, DigitalIntervalSeries 4
AddInterval Commands data_mutation No DigitalIntervalSeries 4
SetEventAtTime Commands data_mutation No DigitalIntervalSeries 3
FlipEventAtTime Commands data_mutation No DigitalIntervalSeries 2
ClearLineDataAtTime Commands data_mutation No LineData 2
AdvanceFrame Commands navigation No (none) 1
ForEachKey Commands meta Conditional (any) 3
SaveData Commands persistence No All saver-supported types 6
LoadData Commands persistence Yes All loader-supported types 5
SynthesizeData DataSynthesizer data_creation No Generator-dependent 5

For the latest list, call getAvailableCommands() after all register_*_commands() functions have run.

See Also