OpenASIP  2.0
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. More...
 
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 }

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 }

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 }

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 }

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 }

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:
HDBBrowserWindow::update
void update()
Definition: HDBBrowserWindow.cc:109
GUICommand::setParentWindow
void setParentWindow(wxWindow *view)
Definition: GUICommand.cc:64
WxConversion::toWxString
static wxString toWxString(const std::string &source)
GUICommand::isEnabled
virtual bool isEnabled()=0
HDBEditorConstants::COMMAND_SET_COST_PLUGIN
@ COMMAND_SET_COST_PLUGIN
Definition: HDBEditorConstants.hh:58
AddSocketEntryCmd
Definition: AddSocketEntryCmd.hh:41
HDBBrowserWindow
Definition: HDBBrowserWindow.hh:59
HDBEditorConstants::COMMAND_ADD_RF_ENTRY
@ COMMAND_ADD_RF_ENTRY
Definition: HDBEditorConstants.hh:54
OpenHDBCmd
Definition: OpenHDBCmd.hh:43
AddRFArchitectureCmd
Definition: AddRFArchitectureCmd.hh:41
HDBEditorModifyCmd
Definition: HDBEditorModifyCmd.hh:41
AddRFImplementationCmd
Definition: AddRFImplementationCmd.hh:41
HDBEditorConstants::COMMAND_OPEN_HDB
@ COMMAND_OPEN_HDB
Definition: HDBEditorConstants.hh:45
AddFUArchFromADFCmd
Definition: AddFUArchFromADFCmd.hh:41
HDBEditorConstants::COMMAND_ADD_OPERATION_IMPLEMENTATION_RESOURCE
@ COMMAND_ADD_OPERATION_IMPLEMENTATION_RESOURCE
Definition: HDBEditorConstants.hh:63
HDBEditorConstants::COMMAND_CREATE_HDB
@ COMMAND_CREATE_HDB
Definition: HDBEditorConstants.hh:46
HDB::HDBRegistry::hdb
CachedHDBManager & hdb(const std::string fileName)
Definition: HDBRegistry.cc:80
HDB::CachedHDBManager::createNew
static CachedHDBManager & createNew(const std::string &fileName)
Definition: CachedHDBManager.cc:105
FileSystem::fileOfPath
static std::string fileOfPath(const std::string pathName)
Definition: FileSystem.cc:101
GUICommand::Do
virtual bool Do()=0
CommandRegistry::createCommand
GUICommand * createCommand(const int id)
Definition: CommandRegistry.cc:69
AddFUEntryCmd
Definition: AddFUEntryCmd.hh:41
AddFUImplementationCmd
Definition: AddFUImplementationCmd.hh:41
HDBEditorConstants::COMMAND_ADD_BUS_ENTRY
@ COMMAND_ADD_BUS_ENTRY
Definition: HDBEditorConstants.hh:55
GUICommand
Definition: GUICommand.hh:43
HDBEditorConstants::COMMAND_MODIFY
@ COMMAND_MODIFY
Definition: HDBEditorConstants.hh:59
ErrorDialog
Definition: ErrorDialog.hh:42
HDBEditorConstants::COMMAND_ADD_FU_IMPLEMENTATION
@ COMMAND_ADD_FU_IMPLEMENTATION
Definition: HDBEditorConstants.hh:51
HDBEditorConstants::COMMAND_ABOUT
@ COMMAND_ABOUT
Definition: HDBEditorConstants.hh:62
CommandRegistry
Definition: CommandRegistry.hh:47
HDBEditorDeleteCmd
Definition: HDBEditorDeleteCmd.hh:41
HDBEditorConstants::COMMAND_ADD_RF_IMPLEMENTATION
@ COMMAND_ADD_RF_IMPLEMENTATION
Definition: HDBEditorConstants.hh:52
HDBEditorConstants::COMMAND_ADD_COST_PLUGIN
@ COMMAND_ADD_COST_PLUGIN
Definition: HDBEditorConstants.hh:57
AddOperationImplementationCmd
Definition: AddOperationImplementationCmd.hh:35
UserManualCmd
Definition: UserManualCmd.hh:40
Exception
Definition: Exception.hh:54
SetCostFunctionPluginCmd
Definition: SetCostFunctionPluginCmd.hh:41
HDBEditorMainFrame::commandRegistry_
CommandRegistry * commandRegistry_
Command registry.
Definition: HDBEditorMainFrame.hh:69
CreateHDBCmd
Definition: CreateHDBCmd.hh:43
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
AddBusEntryCmd
Definition: AddBusEntryCmd.hh:41
HDBEditorAboutCmd
Definition: HDBEditorAboutCmd.hh:42
HDBEditorConstants::COMMAND_ADD_FU_FROM_ADF
@ COMMAND_ADD_FU_FROM_ADF
Definition: HDBEditorConstants.hh:47
UserManualCmd::COMMAND_ID
static const int COMMAND_ID
Command ID.
Definition: UserManualCmd.hh:58
HDBEditorConstants::COMMAND_ADD_RF_ARCHITECTURE
@ COMMAND_ADD_RF_ARCHITECTURE
Definition: HDBEditorConstants.hh:48
HDBEditorMainFrame::browser_
HDBBrowserWindow * browser_
Definition: HDBEditorMainFrame.hh:72
HDBEditorConstants::COMMAND_ADD_OPERATION_IMPLEMENTATION
@ COMMAND_ADD_OPERATION_IMPLEMENTATION
Definition: HDBEditorConstants.hh:64
AddOperationImplementationResourceCmd
Definition: AddOperationImplementationResourceCmd.hh:35
HDBEditorConstants::COMMAND_DELETE
@ COMMAND_DELETE
Definition: HDBEditorConstants.hh:60
HDBEditorQuitCmd
Definition: HDBEditorQuitCmd.hh:41
HDBEditorConstants::COMMAND_ADD_FU_ENTRY
@ COMMAND_ADD_FU_ENTRY
Definition: HDBEditorConstants.hh:53
AddRFEntryCmd
Definition: AddRFEntryCmd.hh:41
HDBEditorConstants::COMMAND_QUIT
@ COMMAND_QUIT
Definition: HDBEditorConstants.hh:61
HDBEditorConstants::COMMAND_ADD_SOCKET_ENTRY
@ COMMAND_ADD_SOCKET_ENTRY
Definition: HDBEditorConstants.hh:56
HDBBrowserWindow::setHDBManager
void setHDBManager(HDB::CachedHDBManager &manager)
Definition: HDBBrowserWindow.cc:99
CommandRegistry::addCommand
void addCommand(GUICommand *command)
AddCostFunctionPluginCmd
Definition: AddCostFunctionPluginCmd.hh:41
HDB::HDBRegistry::instance
static HDBRegistry & instance()
Definition: HDBRegistry.cc:62
HDBEditorMainFrame::hdb_
HDB::CachedHDBManager * hdb_
Definition: HDBEditorMainFrame.hh:71