7 py::class_<FacExtensionInterface> py_fac_extension_interface(m,
"FacExtensionInterface", R
"(
8 An extension interface that lets a plugin provide a parser or writer for a file type.
11 py::enum_<FacExtensionInterface::Feature>(py_fac_extension_interface, "Feature", R
"(
12 The feature that is provided by the extension.
14 .value("FacUnknown", FacExtensionInterface::Feature::FacUnknown, R
"(No known feature.)")
15 .value("FacNetlistParser", FacExtensionInterface::Feature::FacNetlistParser, R
"(A netlist parser.)")
16 .value("FacNetlistWriter", FacExtensionInterface::Feature::FacNetlistWriter, R
"(A netlist writer.)")
17 .value("FacGatelibParser", FacExtensionInterface::Feature::FacGatelibParser, R
"(A gate library parser.)")
18 .value("FacGatelibWriter", FacExtensionInterface::Feature::FacGatelibWriter, R
"(A gate library writer.)")
22 Get the feature provided by the extension.
24 :returns: The feature.
25 :rtype: hal_py.FacExtensionInterface.Feature
29 Get the description of the extension.
31 :returns: The description.
36 Get the file extensions supported by the extension.
38 :returns: A list of file extensions.
42 auto py_plugin_manager = m.def_submodule(
"plugin_manager");
44 py::class_<plugin_manager::PluginFeature> py_plugin_feature(py_plugin_manager,
"PluginFeature", R
"(
45 A feature provided by a plugin, such as a parser or a writer.
49 The kind of feature that is provided.
51 :type: hal_py.FacExtensionInterface.Feature
55 Additional arguments of the feature, holding the supported file extensions if a parser or writer is registered.
61 The description of the feature.
67 Get the names of all loaded plugins.
69 :returns: The set of plugin names.
74 Load all plugins in the specified directories.
75 If ``directory_names`` is empty, the default directories will be searched.
77 :param list[pathlib.Path] directory_names: A list of directory paths.
78 :returns: ``True`` on success, ``False`` otherwise.
82 py_plugin_manager.def("load", &
plugin_manager::load, py::arg(
"plugin_name"), py::arg(
"file_path"), R
"(
83 Load a single plugin by specifying its name and file path.
85 :param str plugin_name: The desired name that is unique in the framework.
86 :param pathlib.Path file_path: The path to the plugin file.
87 :returns: ``True`` on success, ``False`` otherwise.
92 Releases all plugins and their associated resources.
94 :returns: ``True`` on success, ``False`` otherwise.
99 Releases a single plugin and its associated ressources.
101 :param str plugin_name: The name of the plugin to unload.
102 :returns: ``True`` on success, ``False`` otherwise.
107 Get a mapping of flags pointing to their corresponding CLI plugin.
109 :returns: A dict from flag to plugin name.
110 :rtype: dict[str,str]
114 Get a mapping of flags pointing to their corresponding UI plugin.
116 :returns: A dict from flag to plugin name.
117 :rtype: dict[str,str]
120 py_plugin_manager.def(
121 "get_plugin_instance",
123 py::arg(
"plugin_name"),
124 py::arg(
"initialize") =
true,
125 py::arg(
"silent") =
false,
127 Gets the interface for a plugin specified by name.
128 By default calls the initialize() function of the plugin.
129 The returned object is of the plugin's own type as soon as the Python module of that plugin has been imported, and of type ``hal_py.BasePluginInterface`` otherwise.
131 :param str plugin_name: The name of the plugin.
132 :param bool initialize: Set to ``False`` to not call the initialize function of the plugin. Defaults to ``True``.
133 :param bool silent: Set to ``True`` to omit the error message if the plugin is not found. Defaults to ``False``.
134 :returns: The plugin interface on success, ``None`` otherwise.
135 :rtype: hal_py.BasePluginInterface or None
139 Add a callback to notify the GUI about loaded or unloaded plugins.
140 The callback takes a bool that is ``True`` on load and ``False`` on unload, the plugin name, and the plugin path.
142 :param callback: The callback function.
143 :type callback: lambda(bool, str, str) -> None
144 :returns: The ID of the registered callback.
149 Remove a registered callback.
151 :param int id: The ID of the registered callback.
155 Register existing program options to avoid reuse by plugins.
157 :param hal_py.ProgramOptions existing_options: The program options.
161 Get the command line interface options of all plugins.
163 :returns: The program options.
164 :rtype: hal_py.ProgramOptions
168 Get the full path of a plugin.
169 On macOS, several possible file extensions are probed.
171 :param str plugin_name: The name of the plugin.
172 :returns: The full path to the plugin within the HAL build directory.
177 Check whether a file has an extension that is legal for a plugin on the current operating system.
179 :param pathlib.Path file_name: The path to the file.
180 :returns: ``False`` if the extension indicates that the file cannot be a plugin, ``True`` otherwise.
185 Get the features of a plugin identified by the stem of its file name.
187 :param str name: The stem of the file name of the plugin.
188 :returns: A list of features such as parsers or writers.
189 :rtype: list[hal_py.plugin_manager.PluginFeature]
std::vector< std::string > get_supported_file_extensions() const
std::string get_description() const
Feature get_feature() const
void plugin_manager_init(py::module &m)
const Module * module(const Gate *g, const NodeBoxes &boxes)
void add_existing_options_description(const ProgramOptions &existing_options)
u64 add_model_changed_callback(std::function< void(bool, std::string const &, std::string const &)> callback)
bool has_valid_file_extension(std::filesystem::path file_name)
bool unload(const std::string &plugin_name)
bool load_all_plugins(const std::vector< std::filesystem::path > &directory_names={})
bool load(const std::string &plugin_name, const std::filesystem::path &file_path=std::filesystem::path())
std::set< std::string > get_plugin_names()
std::unordered_map< std::string, std::string > get_cli_plugin_flags()
std::unordered_map< std::string, std::string > get_ui_plugin_flags()
bool unload_all_plugins()
std::filesystem::path get_plugin_path(std::string plugin_name)
ProgramOptions get_cli_plugin_options()
void remove_model_changed_callback(u64 id)
BasePluginInterface * get_plugin_instance(const std::string &plugin_name, bool initialize=true, bool silent=false)
std::vector< PluginFeature > get_plugin_features(std::string name)
std::vector< std::string > args
FacExtensionInterface::Feature feature