MCPcopy Create free account
hub / github.com/audacity/audacity / GetCommandDefinition

Method GetCommandDefinition

src/EffectAndCommandPluginManager.cpp:100–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100void EffectAndCommandPluginManager::GetCommandDefinition(
101 const PluginID& ID, const CommandContext& context, int flags)
102{
103 const EffectSettingsManager* effect = nullptr;
104 const EffectSettings* settings;
105 AudacityCommand* command = nullptr;
106
107 if (auto [edi, pSettings] =
108 EffectManager::Get().GetEffectAndDefaultSettings(ID);
109 edi)
110 {
111 effect = &edi->GetDefinition();
112 assert(pSettings); // postcondition
113 settings = pSettings;
114 }
115 else
116 command = GetAudacityCommand(ID);
117 if (!effect && !command)
118 return;
119
120 ConstSettingsVisitor NullShuttle;
121
122 // Test if it defines any parameters at all.
123 bool bHasParams = command ? command->VisitSettings(NullShuttle) :
124 effect->VisitSettings(NullShuttle, *settings);
125 if ((flags == 0) && !bHasParams)
126 return;
127
128 // This is capturing the output context into the shuttle.
129 ShuttleGetDefinition S(*context.pOutput.get()->mStatusTarget.get());
130 S.StartStruct();
131 // using GET to expose a CommandID to the user!
132 // Macro command details are one place that we do expose Identifier
133 // to (more sophisticated) users
134 const auto& pm = PluginManager::Get();
135 S.AddItem(pm.GetCommandIdentifier(ID).GET(), "id");
136 S.AddItem(pm.GetName(ID).Translation(), "name");
137 if (bHasParams)
138 {
139 S.StartField("params");
140 S.StartArray();
141 command ? command->VisitSettings(S) : effect->VisitSettings(S, *settings);
142 S.EndArray();
143 S.EndField();
144 }
145 // use GET() to expose some details to macro programming users
146 S.AddItem(GetCommandUrl(ID).GET(), "url");
147 // The tip is a translated string!
148 S.AddItem(GetCommandTip(ID).Translation(), "tip");
149 S.EndStruct();
150}
151
152void EffectAndCommandPluginManager::BatchProcessingOn(const PluginID& ID)
153{

Callers 2

ApplyInnerMethod · 0.80
SendCommandsMethod · 0.80

Calls 14

GetFunction · 0.85
GetCommandIdentifierMethod · 0.80
TranslationMethod · 0.80
VisitSettingsMethod · 0.45
getMethod · 0.45
StartStructMethod · 0.45
AddItemMethod · 0.45
GetNameMethod · 0.45
StartFieldMethod · 0.45
StartArrayMethod · 0.45
EndArrayMethod · 0.45

Tested by

no test coverage detected