HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
plugin_manager.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 #include "hal_core/defines.h"
33 
34 #include <functional>
35 #include <map>
36 #include <memory>
37 #include <string>
38 #include <tuple>
39 
40 namespace hal
41 {
47  namespace plugin_manager
48  {
54  void add_existing_options_description(const ProgramOptions& existing_options);
55 
61  std::set<std::string> get_plugin_names();
62 
68  std::filesystem::path get_plugin_path(std::string plugin_name);
69 
75  std::unordered_map<std::string, std::string> get_cli_plugin_flags();
76 
82  std::unordered_map<std::string, std::string> get_ui_plugin_flags();
83 
90 
98  bool load_all_plugins(const std::vector<std::filesystem::path>& directory_names = {});
99 
107  bool load(const std::string& plugin_name, const std::filesystem::path& file_path = std::filesystem::path());
108 
114  bool unload_all_plugins();
115 
122  bool unload(const std::string& plugin_name);
123 
133  BasePluginInterface* get_plugin_instance(const std::string& plugin_name, bool initialize = true, bool silent = false);
134 
143  template<typename T>
144  T* get_plugin_instance(const std::string& plugin_name, bool initialize = true)
145  {
146  return dynamic_cast<T*>(get_plugin_instance(plugin_name, initialize));
147  }
148 
156  template<typename T>
157  T* get_first_extension(const std::string& plugin_name, bool initialize = true)
158  {
159  BasePluginInterface* bpif = get_plugin_instance(plugin_name, initialize);
160  if (!bpif)
161  return nullptr;
162  return bpif->get_first_extension<T>();
163  }
164 
174  u64 add_model_changed_callback(std::function<void(bool, std::string const&, std::string const&)> callback);
175 
182 
187  {
189  std::vector<std::string> args;
190  std::string description;
191  };
192 
198  bool has_valid_file_extension(std::filesystem::path file_name);
199 
205  std::vector<PluginFeature> get_plugin_features(std::string name);
206 
207  } // namespace plugin_manager
208 } // namespace hal
uint64_t u64
Definition: defines.h:42
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)
T * get_first_extension(const std::string &plugin_name, bool initialize=true)
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()
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)
Definition: defines.h:45
void initialize()
Definition: event_log.cpp:302
std::string name
std::vector< std::string > args
FacExtensionInterface::Feature feature