bool PluginManagerImpl::check_input_for_plugin(const app_PluginRef &plugin, const grt::BaseListRef &args) { if (args.count() != plugin->inputValues().count()) return false; for (size_t c= plugin->inputValues().count(), i= 0; i < c; i++) { if (!check_plugin_input(plugin->inputValues()[i], args[i])) return false; } return true; }
app_PluginFileInputRef ArgumentPool::needs_file_input(const app_PluginRef &plugin) { const size_t c= plugin->inputValues().count(); for (size_t i= 0; i < c; i++) { app_PluginInputDefinitionRef pdef(plugin->inputValues().get(i)); if (pdef.is_instance(app_PluginFileInput::static_class_name())) return app_PluginFileInputRef::cast_from(pdef); } return app_PluginFileInputRef(); }
bool ArgumentPool::needs_simple_input(const app_PluginRef &plugin, const std::string &name) { const size_t c= plugin->inputValues().count(); for (size_t i= 0; i < c; i++) { app_PluginInputDefinitionRef pdef(plugin->inputValues().get(i)); if (pdef.class_name() == app_PluginInputDefinition::static_class_name()) { if (pdef->name() == name) return true; } } return false; }
static void set_object_argument(app_PluginRef &plugin, const std::string &struct_name) { app_PluginObjectInputRef pdef(plugin.get_grt()); pdef->objectStructName(struct_name); pdef->owner(plugin); plugin->inputValues().insert(pdef); }
grt::BaseListRef ArgumentPool::build_argument_list(const app_PluginRef &plugin) { // build the argument list grt::BaseListRef fargs(plugin->get_grt()); const size_t c= plugin->inputValues().count(); for (size_t i= 0; i < c; i++) { app_PluginInputDefinitionRef pdef(plugin->inputValues().get(i)); std::string searched_key; grt::ValueRef argument= find_match(pdef, searched_key); if (!argument.is_valid()) { log_warning("Cannot satisfy plugin input for %s: %s", plugin->name().c_str(), searched_key.c_str()); log_warning("Missing input: %s", pdef.repr().c_str()); throw grt::grt_runtime_error("Cannot execute "+*plugin->name(), "Plugin requires unavailable argument value."); } fargs.ginsert(argument); } return fargs; }
bool GRTManager::check_plugin_runnable(const app_PluginRef &plugin, const bec::ArgumentPool &argpool, bool debug_output) { bool debug_args = strstr(plugin->name().c_str(), "-debugargs-") != 0 || debug_output; for (size_t c= plugin->inputValues().count(), i= 0; i < c; i++) { app_PluginInputDefinitionRef pdef(plugin->inputValues()[i]); std::string searched_key; if (!argpool.find_match(pdef, searched_key, false).is_valid()) { if (debug_args) { _grt->send_output(base::strfmt("Debug: Plugin %s cannot execute because argument %s is not available\n", plugin->name().c_str(), searched_key.c_str())); _grt->send_output("Debug: Available arguments:\n"); argpool.dump_keys(boost::bind(&grt::GRT::send_output, _grt, _1, (void*)0)); } return false; } } return true; }