HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
gui_api.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/netlist/gate.h"
29 #include "hal_core/netlist/net.h"
32 
33 
34 #include <QObject>
35 #include <QSet>
36 #include <tuple>
37 #include <vector>
38 #include <optional>
39 
40 namespace hal
41 {
45  namespace GuiApiClasses {
46 
50  class View{
51  public:
63  static int isolateInNew(const std::vector<Module*> modules, const std::vector<Gate*> gates);
71  static bool deleteView(int id);
81  static bool addTo(int id, const std::vector<Module*> modules, const std::vector<Gate*> gates);
91  static bool removeFrom(int id, const std::vector<Module*> modules, const std::vector<Gate*> gates);
100  static bool setName(int id, const std::string& name);
108  static int getId(const std::string& name);
116  static std::string getName(int id);
124  static std::vector<Module*> getModules(int id);
132  static std::vector<Gate*> getGates(int id);
141  static std::vector<u32> getIds(const std::vector<Module*> modules, const std::vector<Gate*> gates);
150  static bool foldModule(int view_id, Module* module);
159  static bool unfoldModule(int view_id, Module* module);
160 
167  };
168 
169  static ModuleGateIdPair getValidObjects(int viewId, const std::vector<Module*>, const std::vector<Gate*>);
170  static GridPlacement* getGridPlacement(int viewId);
171  static bool setGridPlacement(int viewId, GridPlacement* gp);
172 
180  static u32 getCurrentDirectory();
188  static void setCurrentDirectory(u32 id);
196  static u32 createNewDirectory(const std::string& name);
202  static void deleteDirectory(u32 id);
211  static void moveView(u32 viewId, std::optional<u32> destinationDirectoryId, std::optional<int> row);
220  static void moveDirectory(u32 directoryId, std::optional<u32> destinationDirectoryId, std::optional<int> row);
221 
230  static std::optional<std::vector<u32>> getChildDirectories(u32 directoryId);
231 
240  static std::optional<std::vector<u32>> getChildViews(u32 directoryId);
241 
250  static int isolateModuleToModulePathInNewView(u32 fromModId, u32 toModId);
251  };
252  }
253 
254 
266  class GuiApi : public QObject
267  {
268  Q_OBJECT
269 
270  public:
274  GuiApi();
275 
281  std::vector<u32> getSelectedGateIds();
282 
288  std::vector<u32> getSelectedNetIds();
289 
296  std::vector<u32> getSelectedModuleIds();
297 
305  std::tuple<std::vector<u32>, std::vector<u32>, std::vector<u32>> getSelectedItemIds();
306 
312  std::vector<Gate*> getSelectedGates();
313 
319  std::vector<Net*> getSelectedNets();
320 
326  std::vector<Module*> getSelectedModules();
327 
334  std::tuple<std::vector<Gate*>, std::vector<Net*>, std::vector<Module*>> getSelectedItems();
335 
347  void selectGate(u32 gate_id, bool clear_current_selection = true, bool navigate_to_selection = true);
348 
360  void selectGate(const std::vector<u32>& gate_ids, bool clear_current_selection = true, bool navigate_to_selection = true);
361 
373  void selectGate(Gate* gate, bool clear_current_selection = true, bool navigate_to_selection = true);
374 
386  void selectGate(const std::vector<Gate*>& gates, bool clear_current_selection = true, bool navigate_to_selection = true);
387 
399  void selectNet(u32 netId, bool clear_current_selection = true, bool navigate_to_selection = true);
400 
412  void selectNet(const std::vector<u32>& net_ids, bool clear_current_selection = true, bool navigate_to_selection = true);
413 
425  void selectNet(Net* net, bool clear_current_selection = true, bool navigate_to_selection = true);
426 
438  void selectNet(const std::vector<Net*>& nets, bool clear_current_selection = true, bool navigate_to_selection = true);
439 
451  void selectModule(u32 module_id, bool clear_current_selection = true, bool navigate_to_selection = true);
452 
464  void selectModule(const std::vector<u32>& module_ids, bool clear_current_selection = true, bool navigate_to_selection = true);
465 
477  void selectModule(Module* module, bool clear_current_selection = true, bool navigate_to_selection = true);
478 
490  void selectModule(const std::vector<Module*>& modules, bool clear_current_selection = true, bool navigate_to_selection = true);
491 
503  void select(Gate* gate, bool clear_current_selection = true, bool navigate_to_selection = true);
504 
516  void select(Net* net, bool clear_current_selection = true, bool navigate_to_selection = true);
517 
529  void select(Module* module, bool clear_current_selection = true, bool navigate_to_selection = true);
530 
542  void select(const std::vector<Gate*>& gates, bool clear_current_selection = true, bool navigate_to_selection = true);
543 
555  void select(const std::vector<Net*>& nets, bool clear_current_selection = true, bool navigate_to_selection = true);
556 
568  void select(const std::vector<Module*>& modules, bool clear_current_selection = true, bool navigate_to_selection = true);
569 
583  void select(const std::vector<u32>& gate_ids, const std::vector<u32>& net_ids, const std::vector<u32>& module_ids, bool clear_current_selection = true, bool navigate_to_selection = true);
584 
598  void select(const std::vector<Gate*>& gates, const std::vector<Net*>& nets, const std::vector<Module*>& modules, bool clear_current_selection = true, bool navigate_to_selection = true);
599 
605  void deselectGate(u32 gate_id);
606 
612  void deselectGate(const std::vector<u32>& gate_ids);
613 
619  void deselectGate(Gate* gate);
620 
626  void deselectGate(const std::vector<Gate*>& gates);
627 
633  void deselectNet(u32 netId);
634 
640  void deselectNet(const std::vector<u32>& net_ids);
641 
647  void deselectNet(Net* net);
648 
654  void deselectNet(const std::vector<Net*>& nets);
655 
661  void deselectModule(u32 module_id);
662 
668  void deselectModule(const std::vector<u32>& module_ids);
669 
676 
682  void deselectModule(const std::vector<Module*>& modules);
683 
687  void deselectAllItems();
688 
694  void deselect(Gate* gate);
695 
701  void deselect(Net* net);
702 
708  void deselect(Module* module);
709 
715  void deselect(const std::vector<Gate*>& gates);
716 
722  void deselect(const std::vector<Net*>& nets);
723 
729  void deselect(const std::vector<Module*>& modules);
730 
738  void deselect(const std::vector<u32>& gate_ids, const std::vector<u32>& net_ids, const std::vector<u32>& module_ids);
739 
747  void deselect(const std::vector<Gate*>& gates, const std::vector<Net*>& nets, const std::vector<Module*>& modules);
748 
749 
750  Q_SIGNALS:
755  };
756 }
Definition: gate.h:58
static bool foldModule(int view_id, Module *module)
Definition: gui_api.cpp:824
static void deleteDirectory(u32 id)
Definition: gui_api.cpp:1022
static bool unfoldModule(int view_id, Module *module)
Definition: gui_api.cpp:805
static void moveDirectory(u32 directoryId, std::optional< u32 > destinationDirectoryId, std::optional< int > row)
Definition: gui_api.cpp:1053
static int getId(const std::string &name)
Definition: gui_api.cpp:689
static bool removeFrom(int id, const std::vector< Module * > modules, const std::vector< Gate * > gates)
Definition: gui_api.cpp:633
static int isolateInNew(const std::vector< Module * > modules, const std::vector< Gate * > gates)
Definition: gui_api.cpp:509
static bool setName(int id, const std::string &name)
Definition: gui_api.cpp:670
static void moveView(u32 viewId, std::optional< u32 > destinationDirectoryId, std::optional< int > row)
Definition: gui_api.cpp:1032
static int isolateModuleToModulePathInNewView(u32 fromModId, u32 toModId)
Definition: gui_api.cpp:449
static std::string getName(int id)
Definition: gui_api.cpp:704
static GridPlacement * getGridPlacement(int viewId)
Definition: gui_api.cpp:981
static bool setGridPlacement(int viewId, GridPlacement *gp)
Definition: gui_api.cpp:988
static u32 createNewDirectory(const std::string &name)
Definition: gui_api.cpp:1014
static std::vector< Gate * > getGates(int id)
Definition: gui_api.cpp:726
static std::optional< std::vector< u32 > > getChildDirectories(u32 directoryId)
Definition: gui_api.cpp:1087
static bool addTo(int id, const std::vector< Module * > modules, const std::vector< Gate * > gates)
Definition: gui_api.cpp:594
static std::optional< std::vector< u32 > > getChildViews(u32 directoryId)
Definition: gui_api.cpp:1096
static bool deleteView(int id)
Definition: gui_api.cpp:579
static std::vector< Module * > getModules(int id)
Definition: gui_api.cpp:713
static void setCurrentDirectory(u32 id)
Definition: gui_api.cpp:1008
static std::vector< u32 > getIds(const std::vector< Module * > modules, const std::vector< Gate * > gates)
Definition: gui_api.cpp:739
static u32 getCurrentDirectory()
Definition: gui_api.cpp:995
static ModuleGateIdPair getValidObjects(int viewId, const std::vector< Module * >, const std::vector< Gate * >)
Definition: gui_api.cpp:855
Interface to interact with the gui itself.
Definition: gui_api.h:267
void deselectNet(u32 netId)
Definition: gui_api.cpp:336
void deselectModule(u32 module_id)
Definition: gui_api.cpp:374
std::vector< u32 > getSelectedNetIds()
Definition: gui_api.cpp:38
std::tuple< std::vector< Gate * >, std::vector< Net * >, std::vector< Module * > > getSelectedItems()
Definition: gui_api.cpp:77
void deselectAllItems()
Definition: gui_api.cpp:444
std::vector< u32 > getSelectedModuleIds()
Definition: gui_api.cpp:43
std::vector< Gate * > getSelectedGates()
Definition: gui_api.cpp:53
std::vector< Net * > getSelectedNets()
Definition: gui_api.cpp:61
void deselect(Gate *gate)
Definition: gui_api.cpp:402
void selectNet(u32 netId, bool clear_current_selection=true, bool navigate_to_selection=true)
Definition: gui_api.cpp:149
void navigationRequested()
void select(Gate *gate, bool clear_current_selection=true, bool navigate_to_selection=true)
Definition: gui_api.cpp:235
std::vector< u32 > getSelectedGateIds()
Definition: gui_api.cpp:33
std::vector< Module * > getSelectedModules()
Definition: gui_api.cpp:69
std::tuple< std::vector< u32 >, std::vector< u32 >, std::vector< u32 > > getSelectedItemIds()
Definition: gui_api.cpp:48
void selectModule(u32 module_id, bool clear_current_selection=true, bool navigate_to_selection=true)
Definition: gui_api.cpp:200
void selectGate(u32 gate_id, bool clear_current_selection=true, bool navigate_to_selection=true)
Definition: gui_api.cpp:98
void deselectGate(u32 gate_id)
Definition: gui_api.cpp:298
Definition: net.h:58
uint32_t u32
Definition: defines.h:41
const Module * module(const Gate *g, const NodeBoxes &boxes)
Definition: defines.h:45
Net * net
std::string name
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS