OpenASIP  2.0
OperationPropertyDialog.hh
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 OperationPropertyDialog.hh
26  *
27  * Declaration of OperationPropertyDialog class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @author Tero Ryynänen 2008 (tero.ryynanen-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_OPERATION_PROPERTY_DIALOG_HH
35 #define TTA_OPERATION_PROPERTY_DIALOG_HH
36 
37 #include <wx/wx.h>
38 #include <wx/listctrl.h>
39 #include <wx/choice.h>
40 #include <vector>
41 #include <string>
42 
43 class Operation;
44 class Operand;
45 class OperationModule;
46 class ObjectState;
47 
48 /**
49  * Dialog which is used to create or modify an operation.
50  */
51 class OperationPropertyDialog : public wxDialog {
52 public:
54  wxWindow* parent,
55  Operation* op,
56  OperationModule& module,
57  const std::string& path);
58  virtual ~OperationPropertyDialog();
59 
60  Operation* operation() const;
61 
62 private:
63  /// Copying not allowed.
65  /// Assignment not allowed.
67 
68  wxSizer* createContents(wxWindow* parent, bool call_fit, bool set_sizer);
69  wxBitmap createBitmaps(size_t index);
70  virtual bool TransferDataToWindow();
71  void updateOperands();
72  void updateIndex();
73  void updateDAG();
74  void updateAffected();
75  void updateTypes();
76  void onSelection(wxListEvent& event);
77  void onAddAffectedBy(wxCommandEvent& event);
78  void onDeleteAffectedBy(wxCommandEvent& event);
79  void onAddAffects(wxCommandEvent& event);
80  void onDeleteAffects(wxCommandEvent& event);
81  void onAddInputOperand(wxCommandEvent& event);
82  void onModifyInputOperand(wxCommandEvent& event);
83  void onDeleteInputOperand(wxCommandEvent& event);
84  void onAddOutputOperand(wxCommandEvent& event);
85  void onModifyOutputOperand(wxCommandEvent& event);
86  void onDeleteOutputOperand(wxCommandEvent& event);
87  void onMoveInputUp(wxCommandEvent& event);
88  void onMoveInputDown(wxCommandEvent& event);
89  void onMoveOutputUp(wxCommandEvent& event);
90  void onMoveOutputDown(wxCommandEvent& event);
91  void onOpen(wxCommandEvent& event);
92  void onOpenDAG(wxCommandEvent& event);
93 
94  void onSaveDAG(wxCommandEvent& event);
95  void onUndoDAG(wxCommandEvent& event);
96  void onDeleteDAG(wxCommandEvent& event);
97  void onNewDAG(wxCommandEvent& event);
98 
99  void onDAGChange(wxCommandEvent& event);
100  void onComboBoxChange(wxCommandEvent& event);
101 
102  void moveUp(std::vector<Operand*>& ops, int id, wxListCtrl* list);
103  void moveDown(std::vector<Operand*>& ops, int id, wxListCtrl* list);
104  std::vector<std::string> getSelectedItems(wxListCtrl* listCtrl);
105 
106  void onOk(wxCommandEvent& event);
108  void setTexts();
109  void setBehaviorLabel();
110  void launchEditor(const std::string& cmd);
111  void updateSwapLists(std::vector<std::string> deletedOperands);
112 
113  void updateOperation(bool newOpDag);
114 
115  /**
116  * Component ids.
117  */
118  enum {
119  ID_TEXT_NAME = 1000,
152  };
153 
154  /// Input operand sizer.
155  wxStaticBoxSizer* inputSizer_;
156  /// Output operand sizer.
157  wxStaticBoxSizer* outputSizer_;
158  /// Affects sizer.
159  wxStaticBoxSizer* affectsSizer_;
160  /// Affected by sizer.
161  wxStaticBoxSizer* affectedBySizer_;
162 
163  /// List of affected by operations.
164  wxListCtrl* affectedByList_;
165  /// List of affects operations.
166  wxListCtrl* affectsList_;
167  /// List of input operands.
168  wxListCtrl* inputOperandList_;
169  /// List of output operands.
170  wxListCtrl* outputOperandList_;
171  /// Choice box for new affected by operations.
172  wxComboBox* affectedByChoice_;
173  /// Choice box for new affects operations.
174  wxComboBox* affectsChoice_;
175  /// Read memory check box.
176  wxCheckBox* readMemoryCB_;
177  /// Write memory check box.
178  wxCheckBox* writeMemoryCB_;
179  /// Can trap check box.
180  wxCheckBox* canTrapCB_;
181  /// Has side effects check box.
182  wxCheckBox* sideEffectsCB_;
183  /// Clocked check box.
184  wxCheckBox* clockedCB_;
185  /// Operation to be created or to be modified.
187  /// Original operation's ObjectState tree
189 
190  /// Name of the operation.
191  wxString name_;
192  /// Module in which operation belongs to.
194  /// Path in which module belongs to.
195  std::string path_;
196  /// Does operation read memory?
198  /// Does operation write memory?
200  /// Can operation trap?
201  bool canTrap_;
202  /// Does operation has side effects?
204  /// Is operation clocked?
205  bool clocked_;
206  /// Can operation can change program flow.
208  /// Operation performs function call.
209  bool isCall_;
210  /// Operation is branch.
211  bool isBranch_;
212 
213  // Text box for editing operation description
214  wxTextCtrl* editDescription_;
215 
216  /// Input operands.
217  std::vector<Operand*> inputOperands_;
218  /// Output operands.
219  std::vector<Operand*> outputOperands_;
220  /// Operations that affects this operation.
221  std::vector<std::string> affects_;
222  /// Operations that are affected by this operation.
223  std::vector<std::string> affectedBy_;
224 
226  DECLARE_EVENT_TABLE()
227 };
228 
229 #endif
Operand
Definition: Operand.hh:52
OperationPropertyDialog::setBehaviorLabel
void setBehaviorLabel()
Definition: OperationPropertyDialog.cc:393
OperationPropertyDialog::readMemory_
bool readMemory_
Does operation read memory?
Definition: OperationPropertyDialog.hh:197
OperationPropertyDialog::name_
wxString name_
Name of the operation.
Definition: OperationPropertyDialog.hh:191
OperationPropertyDialog::onModifyOutputOperand
void onModifyOutputOperand(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:796
OperationPropertyDialog::onDeleteOutputOperand
void onDeleteOutputOperand(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:812
OperationPropertyDialog::onMoveInputUp
void onMoveInputUp(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:837
OperationPropertyDialog
Definition: OperationPropertyDialog.hh:51
OperationPropertyDialog::operation_
Operation * operation_
Operation to be created or to be modified.
Definition: OperationPropertyDialog.hh:186
OperationPropertyDialog::onDAGChange
void onDAGChange(wxCommandEvent &event)
OperationPropertyDialog::ID_TEXT_NAME
@ ID_TEXT_NAME
Definition: OperationPropertyDialog.hh:119
OperationPropertyDialog::operation
Operation * operation() const
Definition: OperationPropertyDialog.cc:236
OperationPropertyDialog::onAddOutputOperand
void onAddOutputOperand(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:779
OperationPropertyDialog::updateIndex
void updateIndex()
OperationPropertyDialog::onDeleteAffects
void onDeleteAffects(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:697
OperationPropertyDialog::ID_OUTPUT_UP_BUTTON
@ ID_OUTPUT_UP_BUTTON
Definition: OperationPropertyDialog.hh:141
OperationPropertyDialog::onSelection
void onSelection(wxListEvent &event)
Definition: OperationPropertyDialog.cc:556
OperationPropertyDialog::affectsChoice_
wxComboBox * affectsChoice_
Choice box for new affects operations.
Definition: OperationPropertyDialog.hh:174
OperationPropertyDialog::operator=
OperationPropertyDialog & operator=(const OperationPropertyDialog &)
Assignment not allowed.
OperationPropertyDialog::readMemoryCB_
wxCheckBox * readMemoryCB_
Read memory check box.
Definition: OperationPropertyDialog.hh:176
OperationPropertyDialog::ID_WRITES_MEMORY
@ ID_WRITES_MEMORY
Definition: OperationPropertyDialog.hh:122
OperationPropertyDialog::isBranch_
bool isBranch_
Operation is branch.
Definition: OperationPropertyDialog.hh:211
OperationPropertyDialog::ID_OPERATION_AFFECTED_BY
@ ID_OPERATION_AFFECTED_BY
Definition: OperationPropertyDialog.hh:127
OperationPropertyDialog::onModifyInputOperand
void onModifyInputOperand(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:738
OperationPropertyDialog::ID_READS_MEMORY
@ ID_READS_MEMORY
Definition: OperationPropertyDialog.hh:121
OperationPropertyDialog::onDeleteDAG
void onDeleteDAG(wxCommandEvent &event)
OperationPropertyDialog::ID_OUTPUT_DELETE_BUTTON
@ ID_OUTPUT_DELETE_BUTTON
Definition: OperationPropertyDialog.hh:145
OperationPropertyDialog::onOk
void onOk(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:1020
OperationPropertyDialog::controlFlow_
bool controlFlow_
Can operation can change program flow.
Definition: OperationPropertyDialog.hh:207
OperationPropertyDialog::affectedBySizer_
wxStaticBoxSizer * affectedBySizer_
Affected by sizer.
Definition: OperationPropertyDialog.hh:161
OperationPropertyDialog::ID_AFFECTED_BY
@ ID_AFFECTED_BY
Definition: OperationPropertyDialog.hh:126
OperationPropertyDialog::editDescription_
wxTextCtrl * editDescription_
Definition: OperationPropertyDialog.hh:214
OperationPropertyDialog::~OperationPropertyDialog
virtual ~OperationPropertyDialog()
Definition: OperationPropertyDialog.cc:209
OperationPropertyDialog::ID_TEXT_CTRL
@ ID_TEXT_CTRL
Definition: OperationPropertyDialog.hh:149
OperationPropertyDialog::updateOperation
void updateOperation(bool newOpDag)
Definition: OperationPropertyDialog.cc:1025
ObjectState
Definition: ObjectState.hh:59
OperationPropertyDialog::isCall_
bool isCall_
Operation performs function call.
Definition: OperationPropertyDialog.hh:209
OperationPropertyDialog::onMoveInputDown
void onMoveInputDown(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:847
OperationPropertyDialog::ID_OK_BUTTON
@ ID_OK_BUTTON
Definition: OperationPropertyDialog.hh:148
OperationPropertyDialog::canTrap_
bool canTrap_
Can operation trap?
Definition: OperationPropertyDialog.hh:201
OperationPropertyDialog::moveUp
void moveUp(std::vector< Operand * > &ops, int id, wxListCtrl *list)
Definition: OperationPropertyDialog.cc:949
OperationPropertyDialog::onOpen
void onOpen(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:879
OperationPropertyDialog::updateOperands
void updateOperands()
Definition: OperationPropertyDialog.cc:443
OperationPropertyDialog::ID_TEXT_OPEN
@ ID_TEXT_OPEN
Definition: OperationPropertyDialog.hh:150
OperationPropertyDialog::canTrapCB_
wxCheckBox * canTrapCB_
Can trap check box.
Definition: OperationPropertyDialog.hh:180
OperationPropertyDialog::ID_DAG_BUTTON
@ ID_DAG_BUTTON
Definition: OperationPropertyDialog.hh:147
OperationPropertyDialog::onMoveOutputDown
void onMoveOutputDown(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:868
OperationPropertyDialog::setTexts
void setTexts()
Definition: OperationPropertyDialog.cc:244
OperationPropertyDialog::updateDAG
void updateDAG()
OperationPropertyDialog::clockedCB_
wxCheckBox * clockedCB_
Clocked check box.
Definition: OperationPropertyDialog.hh:184
OperationPropertyDialog::updateSwapLists
void updateSwapLists(std::vector< std::string > deletedOperands)
Definition: OperationPropertyDialog.cc:1215
OperationPropertyDialog::affectedByList_
wxListCtrl * affectedByList_
List of affected by operations.
Definition: OperationPropertyDialog.hh:164
OperationPropertyDialog::onComboBoxChange
void onComboBoxChange(wxCommandEvent &event)
OperationPropertyDialog::onMoveOutputUp
void onMoveOutputUp(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:857
OperationPropertyDialog::ID_CLOCKED
@ ID_CLOCKED
Definition: OperationPropertyDialog.hh:125
OperationPropertyDialog::ID_CAN_TRAP
@ ID_CAN_TRAP
Definition: OperationPropertyDialog.hh:123
OperationPropertyDialog::affectsSizer_
wxStaticBoxSizer * affectsSizer_
Affects sizer.
Definition: OperationPropertyDialog.hh:159
OperationPropertyDialog::writeMemoryCB_
wxCheckBox * writeMemoryCB_
Write memory check box.
Definition: OperationPropertyDialog.hh:178
OperationPropertyDialog::affectedByChoice_
wxComboBox * affectedByChoice_
Choice box for new affected by operations.
Definition: OperationPropertyDialog.hh:172
OperationPropertyDialog::onDeleteInputOperand
void onDeleteInputOperand(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:753
OperationPropertyDialog::inputOperandList_
wxListCtrl * inputOperandList_
List of input operands.
Definition: OperationPropertyDialog.hh:168
OperationPropertyDialog::ID_OUTPUT_MODIFY_BUTTON
@ ID_OUTPUT_MODIFY_BUTTON
Definition: OperationPropertyDialog.hh:144
OperationPropertyDialog::path_
std::string path_
Path in which module belongs to.
Definition: OperationPropertyDialog.hh:195
OperationPropertyDialog::inputSizer_
wxStaticBoxSizer * inputSizer_
Input operand sizer.
Definition: OperationPropertyDialog.hh:155
OperationPropertyDialog::ID_INPUT_MODIFY_BUTTON
@ ID_INPUT_MODIFY_BUTTON
Definition: OperationPropertyDialog.hh:134
OperationPropertyDialog::updateTypes
void updateTypes()
OperationPropertyDialog::getSelectedItems
std::vector< std::string > getSelectedItems(wxListCtrl *listCtrl)
Definition: OperationPropertyDialog.cc:998
OperationPropertyDialog::clocked_
bool clocked_
Is operation clocked?
Definition: OperationPropertyDialog.hh:205
OperationPropertyDialog::createBitmaps
wxBitmap createBitmaps(size_t index)
Definition: OperationPropertyDialog.cc:1507
OperationPropertyDialog::sideEffectsCB_
wxCheckBox * sideEffectsCB_
Has side effects check box.
Definition: OperationPropertyDialog.hh:182
OperationPropertyDialog::onOpenDAG
void onOpenDAG(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:931
OperationPropertyDialog::onUndoDAG
void onUndoDAG(wxCommandEvent &event)
OperationPropertyDialog::ID_AFFECTS
@ ID_AFFECTS
Definition: OperationPropertyDialog.hh:136
OperationPropertyDialog::affects_
std::vector< std::string > affects_
Operations that affects this operation.
Definition: OperationPropertyDialog.hh:221
OperationPropertyDialog::outputSizer_
wxStaticBoxSizer * outputSizer_
Output operand sizer.
Definition: OperationPropertyDialog.hh:157
OperationPropertyDialog::onAddInputOperand
void onAddInputOperand(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:718
OperationPropertyDialog::launchEditor
void launchEditor(const std::string &cmd)
Definition: OperationPropertyDialog.cc:1203
OperationPropertyDialog::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: OperationPropertyDialog.cc:410
OperationPropertyDialog::ID_OUTPUT_DOWN_BUTTON
@ ID_OUTPUT_DOWN_BUTTON
Definition: OperationPropertyDialog.hh:142
Operation
Definition: Operation.hh:59
OperationPropertyDialog::ID_OPEN_BUTTON
@ ID_OPEN_BUTTON
Definition: OperationPropertyDialog.hh:146
OperationPropertyDialog::ID_AFFECTED_DELETE_BUTTON
@ ID_AFFECTED_DELETE_BUTTON
Definition: OperationPropertyDialog.hh:129
OperationPropertyDialog::affectedBy_
std::vector< std::string > affectedBy_
Operations that are affected by this operation.
Definition: OperationPropertyDialog.hh:223
OperationPropertyDialog::ID_OUTPUT_OPERANDS
@ ID_OUTPUT_OPERANDS
Definition: OperationPropertyDialog.hh:140
OperationPropertyDialog::affectsList_
wxListCtrl * affectsList_
List of affects operations.
Definition: OperationPropertyDialog.hh:166
OperationPropertyDialog::ID_EDIT_DESCRIPTION
@ ID_EDIT_DESCRIPTION
Definition: OperationPropertyDialog.hh:151
OperationPropertyDialog::ID_AFFECTS_DELETE_BUTTON
@ ID_AFFECTS_DELETE_BUTTON
Definition: OperationPropertyDialog.hh:139
OperationModule
Definition: OperationModule.hh:46
OperationPropertyDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: OperationPropertyDialog.cc:1271
OperationPropertyDialog::operationWasCreatedHere_
bool operationWasCreatedHere_
Definition: OperationPropertyDialog.hh:225
OperationPropertyDialog::ID_HAS_SIDE_EFFECTS
@ ID_HAS_SIDE_EFFECTS
Definition: OperationPropertyDialog.hh:124
OperationPropertyDialog::ID_OUTPUT_ADD_BUTTON
@ ID_OUTPUT_ADD_BUTTON
Definition: OperationPropertyDialog.hh:143
OperationPropertyDialog::OperationPropertyDialog
OperationPropertyDialog(wxWindow *parent, Operation *op, OperationModule &module, const std::string &path)
Definition: OperationPropertyDialog.cc:122
OperationPropertyDialog::module_
OperationModule & module_
Module in which operation belongs to.
Definition: OperationPropertyDialog.hh:193
OperationPropertyDialog::ID_OPERATION_AFFECTS
@ ID_OPERATION_AFFECTS
Definition: OperationPropertyDialog.hh:137
OperationPropertyDialog::ID_INPUT_DOWN_BUTTON
@ ID_INPUT_DOWN_BUTTON
Definition: OperationPropertyDialog.hh:132
OperationPropertyDialog::ID_INPUT_UP_BUTTON
@ ID_INPUT_UP_BUTTON
Definition: OperationPropertyDialog.hh:131
OperationPropertyDialog::onAddAffects
void onAddAffects(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:676
OperationPropertyDialog::ID_INPUT_DELETE_BUTTON
@ ID_INPUT_DELETE_BUTTON
Definition: OperationPropertyDialog.hh:135
OperationPropertyDialog::ID_AFFECTED_ADD_BUTTON
@ ID_AFFECTED_ADD_BUTTON
Definition: OperationPropertyDialog.hh:128
OperationPropertyDialog::outputOperands_
std::vector< Operand * > outputOperands_
Output operands.
Definition: OperationPropertyDialog.hh:219
OperationPropertyDialog::ID_AFFECTS_ADD_BUTTON
@ ID_AFFECTS_ADD_BUTTON
Definition: OperationPropertyDialog.hh:138
OperationPropertyDialog::onSaveDAG
void onSaveDAG(wxCommandEvent &event)
OperationPropertyDialog::inputOperands_
std::vector< Operand * > inputOperands_
Input operands.
Definition: OperationPropertyDialog.hh:217
OperationPropertyDialog::hasSideEffects_
bool hasSideEffects_
Does operation has side effects?
Definition: OperationPropertyDialog.hh:203
OperationPropertyDialog::outputOperandList_
wxListCtrl * outputOperandList_
List of output operands.
Definition: OperationPropertyDialog.hh:170
OperationPropertyDialog::onDeleteAffectedBy
void onDeleteAffectedBy(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:655
OperationPropertyDialog::ID_INPUT_ADD_BUTTON
@ ID_INPUT_ADD_BUTTON
Definition: OperationPropertyDialog.hh:133
OperationPropertyDialog::onAddAffectedBy
void onAddAffectedBy(wxCommandEvent &event)
Definition: OperationPropertyDialog.cc:634
OperationPropertyDialog::ID_INPUT_OPERANDS
@ ID_INPUT_OPERANDS
Definition: OperationPropertyDialog.hh:130
OperationPropertyDialog::updateAffected
void updateAffected()
Definition: OperationPropertyDialog.cc:485
OperationPropertyDialog::writeMemory_
bool writeMemory_
Does operation write memory?
Definition: OperationPropertyDialog.hh:199
OperationPropertyDialog::ID_NAME
@ ID_NAME
Definition: OperationPropertyDialog.hh:120
OperationPropertyDialog::moveDown
void moveDown(std::vector< Operand * > &ops, int id, wxListCtrl *list)
Definition: OperationPropertyDialog.cc:974
OperationPropertyDialog::saveOperation
ObjectState * saveOperation()
Definition: OperationPropertyDialog.cc:1105
OperationPropertyDialog::onNewDAG
void onNewDAG(wxCommandEvent &event)
OperationPropertyDialog::orig_
ObjectState * orig_
Original operation's ObjectState tree.
Definition: OperationPropertyDialog.hh:188