HAL  v4.5.0-124-g47ab54673
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 {
42  class UIPluginInterface;
43 
49  namespace plugin_manager
50  {
56  void add_existing_options_description(const ProgramOptions& existing_options);
57 
63  std::set<std::string> get_plugin_names();
64 
70  std::filesystem::path get_plugin_path(std::string plugin_name);
71 
77  std::unordered_map<std::string, std::string> get_cli_plugin_flags();
78 
84  std::unordered_map<std::string, std::string> get_ui_plugin_flags();
85 
92 
100  bool load_all_plugins(const std::vector<std::filesystem::path>& directory_names = {});
101 
109  bool load(const std::string& plugin_name, const std::filesystem::path& file_path = std::filesystem::path());
110 
116  bool unload_all_plugins();
117 
124  bool unload(const std::string& plugin_name);
125 
135  BasePluginInterface* get_plugin_instance(const std::string& plugin_name, bool initialize = true, bool silent = false);
136 
145  template<typename T>
146  T* get_plugin_instance(const std::string& plugin_name, bool initialize = true)
147  {
148  return dynamic_cast<T*>(get_plugin_instance(plugin_name, initialize));
149  }
150 
160 
168  template<typename T>
169  T* get_first_extension(const std::string& plugin_name, bool initialize = true)
170  {
171  BasePluginInterface* bpif = get_plugin_instance(plugin_name, initialize);
172  if (!bpif)
173  return nullptr;
174  return bpif->get_first_extension<T>();
175  }
176 
186  u64 add_model_changed_callback(std::function<void(bool, std::string const&, std::string const&)> callback);
187 
194 
199  {
201  std::vector<std::string> args;
202  std::string description;
203  };
204 
210  bool has_valid_file_extension(std::filesystem::path file_name);
211 
217  std::vector<PluginFeature> get_plugin_features(std::string name);
218 
219  } // namespace plugin_manager
220 } // 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)
UIPluginInterface * get_ui_plugin()
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