OpenASIP  2.0
ProximFindCmd.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2017 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file ProximFindCmd.cc
26  *
27  * Implementation of ProximFindCmd class.
28  *
29  * @author Alex Hirvonen 2017 (alex.hirvonen-no.spam-gmail.com)
30  * @note rating: red
31  */
32 
33 #include "ProximFindCmd.hh"
34 #include "ProximConstants.hh"
35 #include "FindWindow.hh"
37 #include "ProximToolbox.hh"
38 #include "ErrorDialog.hh"
39 #include "ProximMainFrame.hh"
40 
41 
43  GUICommand(ProximConstants::COMMAND_NAME_FIND, NULL) {
44 }
45 
46 
48 }
49 
50 
51 /**
52  * Executes the command.
53  */
54 bool
56 
58 
59  if (simulation->isSimulationInitialized() ||
60  simulation->isSimulationRunning() ||
61  simulation->isSimulationStopped()) {
62 
63  FindWindow* findWindow = dynamic_cast<FindWindow*>(
65  FindWindowById(ProximConstants::ID_FIND_WINDOW));
66 
67  if (findWindow == NULL) {
68  findWindow = new FindWindow(ProximToolbox::mainFrame(),
70 
72  findWindow, _T("Find pattern in disassembly"), false,
73  wxSize(300, 160));
74  findWindow->GetParent()->Center();
75 
76  findWindow->GetParent()->SetSize(300, 160);
77  }
78  } else {
79  ErrorDialog error(parentWindow(), _T("Simulation not initialized."));
80  error.ShowModal();
81  }
82 
83  return true;
84 }
85 
86 
87 /**
88  * Returns full path to the command icon file.
89  *
90  * @return Full path to the command icon file.
91  */
92 std::string
94  return "find.png";
95 }
96 
97 
98 /**
99  * Returns ID of this command.
100  */
101 int
104 }
105 
106 
107 /**
108  * Creates and returns a new instance of this command.
109  *
110  * @return Newly created instance of this command.
111  */
114  return new ProximFindCmd();
115 }
116 
117 
118 /**
119  * Returns true if the command is enabled, false otherwise.
120  *
121  * @return Always true.
122  */
123 bool
125  return true;
126 }
ProximToolbox::frontend
static TracedSimulatorFrontend * frontend()
Definition: ProximToolbox.cc:223
ProximToolbox::mainFrame
static ProximMainFrame * mainFrame()
Definition: ProximToolbox.cc:105
ProximConstants::ID_FIND_WINDOW
@ ID_FIND_WINDOW
Definition: ProximConstants.hh:98
ProximFindCmd.hh
ProximFindCmd::ProximFindCmd
ProximFindCmd()
Definition: ProximFindCmd.cc:42
SimulatorFrontend::isSimulationStopped
bool isSimulationStopped() const
Definition: SimulatorFrontend.cc:1271
ProximFindCmd::icon
virtual std::string icon() const
Definition: ProximFindCmd.cc:93
FindWindow
Definition: FindWindow.hh:49
ProximToolbox.hh
GUICommand
Definition: GUICommand.hh:43
ErrorDialog
Definition: ErrorDialog.hh:42
ProximFindCmd::id
virtual int id() const
Definition: ProximFindCmd.cc:102
ErrorDialog.hh
ProximFindCmd::isEnabled
virtual bool isEnabled()
Definition: ProximFindCmd.cc:124
ProximFindCmd::~ProximFindCmd
virtual ~ProximFindCmd()
Definition: ProximFindCmd.cc:47
ProximToolbox::addFramedWindow
static void addFramedWindow(wxWindow *window, const wxString &title, bool stayOnTop=false, const wxSize &minSize=wxSize(100, 100))
Definition: ProximToolbox.cc:176
ProximFindCmd::create
virtual ProximFindCmd * create() const
Definition: ProximFindCmd.cc:113
SimulatorFrontend::isSimulationRunning
bool isSimulationRunning() const
Definition: SimulatorFrontend.cc:1260
TracedSimulatorFrontend.hh
ProximConstants
Definition: ProximConstants.hh:46
ProximConstants.hh
ProximMainFrame.hh
ProximConstants::COMMAND_FIND
@ COMMAND_FIND
Definition: ProximConstants.hh:71
ProximFindCmd::Do
virtual bool Do()
Definition: ProximFindCmd.cc:55
SimulatorFrontend
Definition: SimulatorFrontend.hh:89
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
SimulatorFrontend::isSimulationInitialized
bool isSimulationInitialized() const
Definition: SimulatorFrontend.cc:1228
FindWindow.hh
ProximFindCmd
Definition: ProximFindCmd.hh:42