OpenASIP  2.0
EditAddressSpacesCmd.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 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 EditAddressSpacesCmd.cc
26  *
27  * Definition of EditAddressSpacesCmd class.
28  *
29  * @author Tommi Rantanen 2004 (tommi.rantanen-no.spam-tut.fi)
30  */
31 
32 #include <vector>
33 #include <wx/docview.h>
34 
35 #include "EditAddressSpacesCmd.hh"
36 #include "ProDeConstants.hh"
37 #include "AddressSpacesDialog.hh"
38 #include "ProDe.hh"
39 #include "Model.hh"
40 #include "MDFDocument.hh"
41 #include "Machine.hh"
42 #include "ModelConstants.hh"
43 #include "AddressSpace.hh"
44 
45 using std::string;
46 using std::vector;
47 
48 
49 /**
50  * The Constructor.
51  */
53  EditorCommand(ProDeConstants::CMD_NAME_EDIT_ADDRESS_SPACES) {
54 }
55 
56 
57 /**
58  * The Destructor.
59  */
61 
62 
63 /**
64  * Executes the command.
65  *
66  * @return True, if the command was succesfully executed, false otherwise.
67  */
68 bool
70 
71  assert(parentWindow() != NULL);
72  assert(view() != NULL);
73 
74  Model* model = dynamic_cast<MDFDocument*>(
75  view()->GetDocument())->getModel();
76 
77  model->pushToStack();
78 
79  AddressSpacesDialog dialog(parentWindow(), model->getMachine());
80 
81  if (dialog.ShowModal() == wxID_OK) {
82  model->notifyObservers();
83  return true;
84  } else {
85  // Cancel button was pressed, address spaces are not modified.
86  model->popFromStack();
87  return false;
88  }
89 }
90 
91 
92 /**
93  * Returns id of this command.
94  */
95 int
98 }
99 
100 
101 /**
102  * Creates and returns a new instance of this command.
103  */
106  return new EditAddressSpacesCmd();
107 }
108 
109 
110 
111 /**
112  * Returns path to the command's icon file.
113  */
114 string
117 }
118 
119 
120 /**
121  * Returns short version of the command name.
122  */
123 string
126 }
127 
128 
129 /**
130  * Returns true when the command is executable, false when not.
131  *
132  * This command is executable when a document is open.
133  *
134  * @return True, if a document is open.
135  */
136 bool
138  wxDocManager* manager = wxGetApp().docManager();
139  if (manager->GetCurrentView() != NULL) {
140  return true;
141  }
142  return false;
143 }
ProDe.hh
EditAddressSpacesCmd::shortName
virtual std::string shortName() const
Definition: EditAddressSpacesCmd.cc:124
EditAddressSpacesCmd::icon
virtual std::string icon() const
Definition: EditAddressSpacesCmd.cc:115
MDFDocument.hh
ProDeConstants::COMMAND_EDIT_ADDRESS_SPACES
@ COMMAND_EDIT_ADDRESS_SPACES
Definition: ProDeConstants.hh:440
AddressSpace.hh
ProDeConstants::CMD_SNAME_EDIT_ADDRESS_SPACES
static const std::string CMD_SNAME_EDIT_ADDRESS_SPACES
Command name for the "Edit Address Space" command.
Definition: ProDeConstants.hh:229
EditAddressSpacesCmd::~EditAddressSpacesCmd
virtual ~EditAddressSpacesCmd()
Definition: EditAddressSpacesCmd.cc:60
AddressSpacesDialog.hh
Model::pushToStack
void pushToStack()
Definition: Model.cc:167
EditAddressSpacesCmd::create
virtual EditAddressSpacesCmd * create() const
Definition: EditAddressSpacesCmd.cc:105
Model::notifyObservers
void notifyObservers(bool modified=true)
Definition: Model.cc:152
assert
#define assert(condition)
Definition: Application.hh:86
EditAddressSpacesCmd
Definition: EditAddressSpacesCmd.hh:40
AddressSpacesDialog
Definition: AddressSpacesDialog.hh:48
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
Model.hh
EditAddressSpacesCmd.hh
ModelConstants.hh
Machine.hh
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
EditAddressSpacesCmd::EditAddressSpacesCmd
EditAddressSpacesCmd()
Definition: EditAddressSpacesCmd.cc:52
MDFDocument
Definition: MDFDocument.hh:51
ProDeConstants.hh
EditAddressSpacesCmd::Do
virtual bool Do()
Definition: EditAddressSpacesCmd.cc:69
Model
Definition: Model.hh:50
EditorCommand
Definition: EditorCommand.hh:46
ProDeConstants
Definition: ProDeConstants.hh:43
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88
EditAddressSpacesCmd::isEnabled
virtual bool isEnabled()
Definition: EditAddressSpacesCmd.cc:137
ProDeConstants::CMD_ICON_EDIT_ADDRESS_SPACES
static const std::string CMD_ICON_EDIT_ADDRESS_SPACES
Icon location for the "Edit Address Space" command.
Definition: ProDeConstants.hh:338
EditAddressSpacesCmd::id
virtual int id() const
Definition: EditAddressSpacesCmd.cc:96