OpenASIP  2.0
EditMachineCmd.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2015 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 EditMachineCmd.cc
26  *
27  * Implementation of EditMachine class.
28  *
29  * Created on: 6.2.2015
30  * @author: Henry Linjamäki (henry.linjamaki-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #include "EditMachineCmd.hh"
35 
36 #include "ProDeConstants.hh"
37 #include "MachineDialog.hh"
38 #include "ProDe.hh"
39 #include "Model.hh"
40 #include "MDFDocument.hh"
41 #include "Machine.hh"
42 #include "ModelConstants.hh"
43 
44 /**
45  * The Constructor.
46  */
48  EditorCommand(ProDeConstants::CMD_NAME_EDIT_MACHINE) {
49 }
50 
51 
52 /**
53  * The Destructor.
54  */
56 
57 }
58 
59 
60 /**
61  * Executes the command.
62  *
63  * @return True, if the command was succesfully executed, false otherwise.
64  */
65 bool
67  assert(parentWindow() != NULL);
68  assert(view() != NULL);
69 
70  Model* model = dynamic_cast<MDFDocument*>(
71  view()->GetDocument())->getModel();
72 
73  model->pushToStack();
74 
75  MachineDialog dialog(parentWindow(), *model->getMachine());
76 
77  if (dialog.ShowModal() == wxID_OK) {
78  model->notifyObservers();
79  return true;
80  } else {
81  // Cancel button was pressed, templates are not modified.
82  model->popFromStack();
83  return false;
84  }
85 }
86 
87 
88 /**
89  * Returns id of this command.
90  *
91  * @return Id of this command.
92  */
93 int
96 }
97 
98 
99 /**
100  * Creates and returns a new instance of this command.
101  *
102  * @return A new instance of this command.
103  */
106  return new EditMachineCmd();
107 }
108 
109 
110 /**
111  * Returns path to the command's icon file.
112  *
113  * @return path to the command's icon file.
114  */
115 std::string
118 }
119 
120 
121 /**
122  * Returns short version of the command name.
123  *
124  * @return Short version of the command name.
125  */
126 std::string
129 }
130 
131 
132 /**
133  * Returns true when the command is executable, false when not.
134  *
135  * This command is executable when a document is open.
136  *
137  * @return True, if a document is open.
138  */
139 bool
141  wxDocManager* manager = wxGetApp().docManager();
142  if (manager->GetCurrentView() != NULL) {
143  return true;
144  }
145  return false;
146 }
EditMachineCmd::id
virtual int id() const
Definition: EditMachineCmd.cc:94
MachineDialog
Definition: MachineDialog.hh:48
ProDe.hh
MDFDocument.hh
ProDeConstants::CMD_ICON_EDIT_MACHINE
static const std::string CMD_ICON_EDIT_MACHINE
Icon location for the "Processor Configurations" command.
Definition: ProDeConstants.hh:346
EditMachineCmd
Definition: EditMachineCmd.hh:39
Model::pushToStack
void pushToStack()
Definition: Model.cc:167
EditMachineCmd::shortName
virtual std::string shortName() const
Definition: EditMachineCmd.cc:127
Model::notifyObservers
void notifyObservers(bool modified=true)
Definition: Model.cc:152
assert
#define assert(condition)
Definition: Application.hh:86
ProDeConstants::CMD_SNAME_EDIT_MACHINE
static const std::string CMD_SNAME_EDIT_MACHINE
Command name for the "Processor Configurations" command.
Definition: ProDeConstants.hh:235
ProDeConstants::COMMAND_EDIT_MACHINE
@ COMMAND_EDIT_MACHINE
Definition: ProDeConstants.hh:445
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
EditMachineCmd::~EditMachineCmd
virtual ~EditMachineCmd()
Definition: EditMachineCmd.cc:55
Model.hh
EditMachineCmd::isEnabled
virtual bool isEnabled()
Definition: EditMachineCmd.cc:140
EditMachineCmd::Do
virtual bool Do()
Definition: EditMachineCmd.cc:66
ModelConstants.hh
Machine.hh
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
MDFDocument
Definition: MDFDocument.hh:51
ProDeConstants.hh
MachineDialog.hh
Model
Definition: Model.hh:50
EditMachineCmd::EditMachineCmd
EditMachineCmd()
Definition: EditMachineCmd.cc:47
EditMachineCmd::icon
virtual std::string icon() const
Definition: EditMachineCmd.cc:116
EditorCommand
Definition: EditorCommand.hh:46
EditMachineCmd::create
virtual EditMachineCmd * create() const
Definition: EditMachineCmd.cc:105
ProDeConstants
Definition: ProDeConstants.hh:43
EditMachineCmd.hh
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88