OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HDBEditorMainFrame Class Reference

#include <HDBEditorMainFrame.hh>

Inheritance diagram for HDBEditorMainFrame:
Inheritance graph
Collaboration diagram for HDBEditorMainFrame:
Collaboration graph

Public Member Functions

 HDBEditorMainFrame (const wxString &title, const wxPoint &position, const wxSize &size)
 
virtual ~HDBEditorMainFrame ()
 
bool setHDB (const std::string &hdbFile)
 
bool createHDB (const std::string &filePath)
 
HDB::HDBManagerhdbManager ()
 
HDBBrowserWindowbrowser () const
 
void update ()
 

Private Member Functions

void onCommandEvent (wxCommandEvent &event)
 
void onUpdateUI (wxUpdateUIEvent &event)
 

Private Attributes

CommandRegistrycommandRegistry_
 Command registry.
 
HDB::CachedHDBManagerhdb_
 
HDBBrowserWindowbrowser_
 

Detailed Description

Main window of the editor.

Definition at line 50 of file HDBEditorMainFrame.hh.

Constructor & Destructor Documentation

◆ HDBEditorMainFrame()

HDBEditorMainFrame::HDBEditorMainFrame ( const wxString &  title,
const wxPoint &  position,
const wxSize &  size 
)

The Constructor.

Parameters
titleTitle of the MainFrame.
positionPosition of the MainFrame on the screen.
sizeSize of the MainFrame on the screen.

Definition at line 83 of file HDBEditorMainFrame.cc.

86 :
87 wxFrame(NULL, -1, title, position, size),
88 hdb_(NULL) {
89
91
92 wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
93 browser_ = new HDBBrowserWindow(this, -1);
94 sizer->Add(browser_, 1, wxGROW);
95 Fit();
96
97 // Create the default menubar.
98 wxMenu* fileMenu = new wxMenu;
99 fileMenu->Append(HDBEditorConstants::COMMAND_OPEN_HDB, _T("&Open HDB..."));
100 fileMenu->Append(
101 HDBEditorConstants::COMMAND_CREATE_HDB, _T("&Create HDB..."));
102 fileMenu->AppendSeparator();
103 fileMenu->Append(HDBEditorConstants::COMMAND_QUIT, _T("&Quit"));
104
105 wxMenu* editMenu = new wxMenu;
106 wxMenu* addSubMenu = new wxMenu;
107
108 addSubMenu->Append(
110 _T("FU Architecture From ADF..."));
111 addSubMenu->Append(
113 _T("RF Architecture..."));
114 addSubMenu->AppendSeparator();
115
116 addSubMenu->Append(
118 _T("Operation Implementation Resource..."));
119 addSubMenu->Append(
121 _T("Operation Implementation..."));
122 addSubMenu->AppendSeparator();
123
124 addSubMenu->Append(
126 _T("FU Entry Implementation..."));
127 addSubMenu->Append(
129 _T("RF Entry Implementation..."));
130
131 addSubMenu->AppendSeparator();
132 addSubMenu->Append(
134
135 addSubMenu->Append(
137 addSubMenu->Append(
139
140 addSubMenu->Append(
142
143 addSubMenu->AppendSeparator();
144 addSubMenu->Append(
146 _T("Cost Function Plugin..."));
147 editMenu->Append(-1, _T("Add"), addSubMenu);
148 editMenu->AppendSeparator();
149 editMenu->Append(
151 _T("Set Cost Function Plugin"));
152
153 editMenu->AppendSeparator();
154 editMenu->Append(HDBEditorConstants::COMMAND_DELETE, _T("Delete"));
155 editMenu->Append(HDBEditorConstants::COMMAND_MODIFY, _T("Modify..."));
156
157 wxMenu* helpMenu = new wxMenu;
158
159 helpMenu->Append(UserManualCmd::COMMAND_ID, _T("User Manual..."));
160 helpMenu->Append(HDBEditorConstants::COMMAND_ABOUT, _T("About..."));
161
162 wxMenuBar* menuBar = new wxMenuBar;
163 menuBar->Append(fileMenu, _T("&File"));
164 menuBar->Append(editMenu, _T("&Edit"));
165 menuBar->Append(helpMenu, _T("&Help"));
166 SetMenuBar(menuBar);
167
168 CreateStatusBar();
169 SetSizer(sizer);
170
190
191 SetSizeHints(400,300);
192 SetSize(600, 400);
193}
void addCommand(GUICommand *command)
CommandRegistry * commandRegistry_
Command registry.
HDB::CachedHDBManager * hdb_
HDBBrowserWindow * browser_
static const int COMMAND_ID
Command ID.

References HDBEditorConstants::COMMAND_ABOUT, HDBEditorConstants::COMMAND_ADD_BUS_ENTRY, HDBEditorConstants::COMMAND_ADD_COST_PLUGIN, HDBEditorConstants::COMMAND_ADD_FU_ENTRY, HDBEditorConstants::COMMAND_ADD_FU_FROM_ADF, HDBEditorConstants::COMMAND_ADD_FU_IMPLEMENTATION, HDBEditorConstants::COMMAND_ADD_OPERATION_IMPLEMENTATION, HDBEditorConstants::COMMAND_ADD_OPERATION_IMPLEMENTATION_RESOURCE, HDBEditorConstants::COMMAND_ADD_RF_ARCHITECTURE, HDBEditorConstants::COMMAND_ADD_RF_ENTRY, HDBEditorConstants::COMMAND_ADD_RF_IMPLEMENTATION, HDBEditorConstants::COMMAND_ADD_SOCKET_ENTRY, HDBEditorConstants::COMMAND_CREATE_HDB, HDBEditorConstants::COMMAND_DELETE, UserManualCmd::COMMAND_ID, HDBEditorConstants::COMMAND_MODIFY, HDBEditorConstants::COMMAND_OPEN_HDB, HDBEditorConstants::COMMAND_QUIT, and HDBEditorConstants::COMMAND_SET_COST_PLUGIN.

◆ ~HDBEditorMainFrame()

HDBEditorMainFrame::~HDBEditorMainFrame ( )
virtual

The Destructor.

Definition at line 199 of file HDBEditorMainFrame.cc.

199 {
200}

Member Function Documentation

◆ browser()

HDBBrowserWindow * HDBEditorMainFrame::browser ( ) const

Returns pointer to the HDB browser window.

Returns
HDB Browser window of the application.

Definition at line 335 of file HDBEditorMainFrame.cc.

335 {
336 return browser_;
337}

References browser_.

Referenced by HDBEditor::browser().

◆ createHDB()

bool HDBEditorMainFrame::createHDB ( const std::string &  filePath)

Creates a new HDB and opens it in the main frame.

Parameters
filePathFull path of the HDB to be created.
Returns
True, if the HDB was succesfully created and opened, false if not.

Definition at line 283 of file HDBEditorMainFrame.cc.

283 {
284
285 if (hdb_ != NULL) {
286 hdb_ = NULL;
287 }
288
289 try {
291 } catch (Exception& e) {
292 wxString message = _T("Error creating HDB ");
293 message.Append(WxConversion::toWxString(filePath));
294 message.Append(_T(":\n\n"));
295 message.Append(WxConversion::toWxString(e.errorMessage()));
296 ErrorDialog dialog(this, message);
297 dialog.ShowModal();
298 return false;
299 }
300
302 std::string title = "HDB Editor - " + FileSystem::fileOfPath(filePath);
303 SetTitle(WxConversion::toWxString(title));
304
305 return true;
306
307}
std::string errorMessage() const
Definition Exception.cc:123
static std::string fileOfPath(const std::string pathName)
void setHDBManager(HDB::CachedHDBManager &manager)
static CachedHDBManager & createNew(const std::string &fileName)
static wxString toWxString(const std::string &source)

References browser_, HDB::CachedHDBManager::createNew(), Exception::errorMessage(), FileSystem::fileOfPath(), hdb_, HDBBrowserWindow::setHDBManager(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ hdbManager()

HDB::HDBManager * HDBEditorMainFrame::hdbManager ( )

Returns pointer to the HDBManager managing the current HDB.

Returns
Pointer to the HDBManager of the main frame.

Definition at line 315 of file HDBEditorMainFrame.cc.

315 {
316 return hdb_;
317}

References hdb_.

◆ onCommandEvent()

void HDBEditorMainFrame::onCommandEvent ( wxCommandEvent &  event)
private

Handles menu and toolbar events.

Parameters
eventEvent to handle.

Definition at line 210 of file HDBEditorMainFrame.cc.

210 {
211
212 GUICommand* command = commandRegistry_->createCommand(event.GetId());
213
214 if (command == NULL) {
215 ErrorDialog dialog(
216 this, _T("No handler found for the command event!"));
217 dialog.ShowModal();
218 return;
219 }
220
221 command->setParentWindow(this);
222 command->Do();
223}
GUICommand * createCommand(const int id)
virtual bool Do()=0
void setParentWindow(wxWindow *view)
Definition GUICommand.cc:64

References commandRegistry_, CommandRegistry::createCommand(), GUICommand::Do(), and GUICommand::setParentWindow().

Here is the call graph for this function:

◆ onUpdateUI()

void HDBEditorMainFrame::onUpdateUI ( wxUpdateUIEvent &  event)
private

Updates toolbar and menubar item enabled/disabled states.

Parameters
eventUpdate event for the menu or toolbar item to be updated.

Definition at line 231 of file HDBEditorMainFrame.cc.

231 {
232
233 GUICommand* command = commandRegistry_->createCommand(event.GetId());
234
235 if (command == NULL || command->isEnabled()) {
236 event.Enable(true);
237 } else {
238 event.Enable(false);
239 }
240
241 delete command;
242}
virtual bool isEnabled()=0

References commandRegistry_, CommandRegistry::createCommand(), and GUICommand::isEnabled().

Here is the call graph for this function:

◆ setHDB()

bool HDBEditorMainFrame::setHDB ( const std::string &  hdbFile)

Sets the HDB to be displayed and modified with the main frame.

Parameters
HDBto be opened in the main frame.
Returns
True, if the HDB was succesfully opened, false if not.

Definition at line 252 of file HDBEditorMainFrame.cc.

252 {
253
254 if (hdb_ != NULL) {
255 hdb_ = NULL;
256 }
257
258 try {
259 hdb_ = &HDB::HDBRegistry::instance().hdb(hdbFile);
260 } catch (Exception& e) {
261 wxString message = _T("Error opening HDB ");
262 message.Append(WxConversion::toWxString(hdbFile));
263 message.Append(_T(":\n\n"));
264 message.Append(WxConversion::toWxString(e.errorMessage()));
265 ErrorDialog dialog(this, message);
266 dialog.ShowModal();
267 return false;
268 }
269
271 std::string title = "HDB Editor - " + FileSystem::fileOfPath(hdbFile);
272 SetTitle(WxConversion::toWxString(title));
273 return true;
274}
static HDBRegistry & instance()
CachedHDBManager & hdb(const std::string fileName)

References browser_, Exception::errorMessage(), FileSystem::fileOfPath(), HDB::HDBRegistry::hdb(), hdb_, HDB::HDBRegistry::instance(), HDBBrowserWindow::setHDBManager(), and WxConversion::toWxString().

Referenced by HDBEditor::OnInit().

Here is the call graph for this function:

◆ update()

void HDBEditorMainFrame::update ( )

Updates the HDB window.

Definition at line 324 of file HDBEditorMainFrame.cc.

324 {
325 browser_->update();
326}

References browser_, and HDBBrowserWindow::update().

Here is the call graph for this function:

Member Data Documentation

◆ browser_

HDBBrowserWindow* HDBEditorMainFrame::browser_
private

Definition at line 72 of file HDBEditorMainFrame.hh.

Referenced by browser(), createHDB(), setHDB(), and update().

◆ commandRegistry_

CommandRegistry* HDBEditorMainFrame::commandRegistry_
private

Command registry.

Definition at line 69 of file HDBEditorMainFrame.hh.

Referenced by onCommandEvent(), and onUpdateUI().

◆ hdb_

HDB::CachedHDBManager* HDBEditorMainFrame::hdb_
private

Definition at line 71 of file HDBEditorMainFrame.hh.

Referenced by createHDB(), hdbManager(), and setHDB().


The documentation for this class was generated from the following files: