OpenASIP  2.0
HDBBrowserWindow.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 HDBBrowserWindow.cc
26  *
27  * Implementation of HDBBrowserWindow class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <set>
34 #include <wx/splitter.h>
35 #include <wx/progdlg.h>
36 #include "HDBBrowserWindow.hh"
37 #include "CachedHDBManager.hh"
38 #include "WxConversion.hh"
39 #include "FUImplementation.hh"
40 #include "FUArchitecture.hh"
41 #include "RFArchitecture.hh"
42 #include "FunctionUnit.hh"
43 #include "FUEntry.hh"
44 #include "RFEntry.hh"
45 #include "DBTypes.hh"
46 #include "HDBBrowserInfoPanel.hh"
47 #include "RFImplementation.hh"
48 #include "MapTools.hh"
49 #include "HDBEditorConstants.hh"
50 #include "HWOperation.hh"
51 #include "CostFunctionPlugin.hh"
52 #include "HDBToHtml.hh"
53 #include "Conversion.hh"
54 
55 using namespace HDB;
56 using namespace TTAMachine;
57 
58 BEGIN_EVENT_TABLE(HDBBrowserWindow, wxPanel)
59  EVT_TREE_SEL_CHANGED(ID_TREE_VIEW, HDBBrowserWindow::onItemSelected)
60  EVT_TREE_ITEM_ACTIVATED(ID_TREE_VIEW, HDBBrowserWindow::onItemSelected)
61  EVT_TREE_ITEM_RIGHT_CLICK(ID_TREE_VIEW, HDBBrowserWindow::onRMBClick)
63 
64 /**
65  * The Constructor.
66  *
67  * @param parent Parent window of the browser panel.
68  * @param id Window identifier.
69  */
70 HDBBrowserWindow::HDBBrowserWindow(wxWindow* parent, wxWindowID id) :
71  wxPanel(parent, id), manager_(NULL) {
72 
73  wxSplitterWindow* splitter = new wxSplitterWindow(this, wxVERTICAL);
74 
75  wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
76  tree_ = new wxTreeCtrl(splitter, ID_TREE_VIEW);
77  infoPanel_ = new HDBBrowserInfoPanel(splitter, -1);
78  splitter->SetMinimumPaneSize(150);
79  splitter->SplitVertically(tree_, infoPanel_);
80  sizer->Add(splitter, 1, wxGROW);
81  Fit();
82  SetSizer(sizer);
83 }
84 
85 
86 /**
87  * The destructor.
88  */
90 }
91 
92 
93 /**
94  * Sets the HDB which is displayed in the browser.
95  *
96  * @param manager HDBManager managing the HDB to display.
97  */
98 void
100  manager_ = &manager;
101  infoPanel_->setHDB(manager);
102  update();
103 }
104 
105 /**
106  * Updates the treeview of the HDB.
107  */
108 void
110 
111  fuArchitectures_.clear();
112  rfArchitectures_.clear();
113  fuImplementations_.clear();
114  rfImplementations_.clear();
115  fuEntries_.clear();
116  rfEntries_.clear();
117  busEntries_.clear();
118  socketEntries_.clear();
119  costPlugins_.clear();
120 
121  tree_->DeleteAllItems();
122  wxTreeItemId root = tree_->AddRoot(_T("HDB"));
123 
124  wxTreeItemId fus = tree_->AppendItem(
126 
127  wxTreeItemId rfs = tree_->AppendItem(
129 
130  wxTreeItemId fuEntries = tree_->AppendItem(
132 
133  wxTreeItemId rfEntries = tree_->AppendItem(
135 
136  wxTreeItemId busEntries = tree_->AppendItem(
138 
139  wxTreeItemId socketEntries = tree_->AppendItem(
141 
142  wxTreeItemId costPlugins = tree_->AppendItem(
144 
145  wxTreeItemId operationImplementations = tree_->AppendItem(
147 
148  wxTreeItemId operationImplementationResources = tree_->AppendItem(
150 
151  std::set<RowID>::iterator iter;
152 
153 
154  std::set<RowID> fuArchIds = manager_->fuArchitectureIDs();
155  std::set<RowID> rfArchIds = manager_->rfArchitectureIDs();
156  std::set<RowID> fuIDs = manager_->fuEntryIDs();
157  std::set<RowID> rfIDs = manager_->rfEntryIDs();
158  std::set<RowID> busIDs = manager_->busEntryIDs();
159  std::set<RowID> socketIDs = manager_->socketEntryIDs();
160  std::set<RowID> pluginIDs = manager_->costFunctionPluginIDs();
161  std::set<RowID> operationImplementationIDs = manager_->OperationImplementationIDs();
162  std::set<RowID> operationImplementationResourceIDs = manager_->OperationImplementationResourceIDs();
163 
164  int entries = fuArchIds.size() + rfArchIds.size() + fuIDs.size() +
165  rfIDs.size() + busIDs.size() + socketIDs.size() + pluginIDs.size();
166 
167  int c = 0;
168 
169  wxProgressDialog dialog(
170  _T("Loading HDB"), _T("Loading HDB"), entries, this,
171  wxPD_APP_MODAL|wxPD_AUTO_HIDE);
172 
173  dialog.SetSize(300,100);
174 
175  int ids = fuArchIds.size();
176  int cur = 0;
177  wxString message;
178 
179  // FU architectures
180  for (iter = fuArchIds.begin(); iter != fuArchIds.end(); iter++) {
181 
182  const FUArchitecture& arch = manager_->fuArchitectureByIDConst(*iter);
183  const FunctionUnit& fu = arch.architecture();
184 
185  wxTreeItemId id = tree_->AppendItem(fus, fuArchLabel(fu));
186  fuArchitectures_[*iter] = id;
187  c++;
188  cur++;
189  message.Printf(wxT("Loading FU Architectures... (%04d / %04d)"),cur,ids);
190  dialog.Update(c, message);
191  dialog.SetSize(300,100);
192  }
193  tree_->SortChildren(fus);
194 
195  cur = 0;
196  ids = rfArchIds.size();
197  // RF architectures
198  for (iter = rfArchIds.begin(); iter != rfArchIds.end(); iter++) {
199  wxString archLabel = WxConversion::toWxString(*iter);
200  wxTreeItemId id = tree_->AppendItem(rfs, archLabel);
201  rfArchitectures_[*iter] = id;
202  c++;
203  cur++;
204  message.Printf(wxT("Loading RF Architectures... (%04d / %04d)"),cur,ids);
205  dialog.Update(c, message);
206  dialog.SetSize(300,100);
207  }
208 
209  // FU Entries
210  cur = 0;
211  ids = fuIDs.size();
212  for (iter = fuIDs.begin(); iter != fuIDs.end(); iter++) {
213  const FUEntry* fuEntry = manager_->fuByEntryID(*iter);
214  wxString fuEntryLabel = WxConversion::toWxString(*iter);
215  wxTreeItemId entryTreeID = tree_->AppendItem(fuEntries, fuEntryLabel);
216  fuEntries_[*iter] = entryTreeID;
217 
218  if (fuEntry->hasArchitecture()) {
219  const FUArchitecture& arch = fuEntry->architecture();
220 
221  int archID = arch.id();
222  wxTreeItemId archTreeID = fuArchitectures_[archID];
223 
224  if (fuEntry->hasImplementation()) {
225  const FUImplementation& imp = fuEntry->implementation();
226  wxString impName = WxConversion::toWxString(imp.moduleName());
227  wxTreeItemId id = tree_->AppendItem(archTreeID, impName);
228  fuImplementations_[imp.id()] = id;
229  }
230  }
231 
232  delete fuEntry;
233  c++;
234  cur++;
235  message.Printf(wxT("Loading FU entries... (%04d / %04d)"),cur,ids);
236  dialog.Update(c, message);
237  dialog.SetSize(300,100);
238  }
239 
240  // RF Entries
241  cur = 0;
242  ids = rfIDs.size();
243  for (iter = rfIDs.begin(); iter != rfIDs.end(); iter++) {
244  const RFEntry* rfEntry = manager_->rfByEntryID(*iter);
245  wxString rfEntryLabel = WxConversion::toWxString(*iter);
246  wxTreeItemId entryTreeID = tree_->AppendItem(rfEntries, rfEntryLabel);
247  rfEntries_[*iter] = entryTreeID;
248 
249  if (rfEntry->hasArchitecture()) {
250  const RFArchitecture& arch = rfEntry->architecture();
251  int archID = arch.id();
252  wxTreeItemId archTreeID = rfArchitectures_[archID];
253 
254  if (rfEntry->hasImplementation()) {
255  const RFImplementation& imp = rfEntry->implementation();
256  wxString impName = WxConversion::toWxString(imp.moduleName());
257  wxTreeItemId id = tree_->AppendItem(archTreeID, impName);
258  rfImplementations_[imp.id()] = id;
259  }
260  }
261  delete rfEntry;
262  c++;
263  cur++;
264  message.Printf(wxT("Loading RF entries... (%04d / %04d)"),cur,ids);
265  dialog.Update(c, message);
266  dialog.SetSize(300,100);
267  }
268 
269  // Bus Entries
270  cur = 0;
271  ids = busIDs.size();
272  for (iter = busIDs.begin(); iter != busIDs.end(); iter++) {
273  wxString busEntryLabel = WxConversion::toWxString(*iter);
274  wxTreeItemId entryTreeID =
275  tree_->AppendItem(busEntries, busEntryLabel);
276 
277  busEntries_[*iter] = entryTreeID;
278  c++;
279  cur++;
280  message.Printf(wxT("Loading bus entries... (%04d / %04d)"),cur,ids);
281  dialog.Update(c, message);
282  dialog.SetSize(300,100);
283  }
284 
285  // Socket Entries
286  cur = 0;
287  ids = socketIDs.size();
288  for (iter = socketIDs.begin(); iter != socketIDs.end(); iter++) {
289  wxString socketEntryLabel = WxConversion::toWxString(*iter);
290  wxTreeItemId entryTreeID =
291  tree_->AppendItem(socketEntries, socketEntryLabel);
292 
293  socketEntries_[*iter] = entryTreeID;
294  cur++;
295  message.Printf(wxT("Loading socket entries... (%04d / %04d)"),cur,ids);
296  dialog.Update(c, message);
297  dialog.SetSize(300,100);
298  }
299 
300  // Cost estimation plugin data
301  cur = 0;
302  ids = pluginIDs.size();
303  for (iter = pluginIDs.begin(); iter != pluginIDs.end(); iter++) {
304 
305  const CostFunctionPlugin* plugin =
306  manager_->costFunctionPluginByID(*iter);
307 
308  wxString pluginName = WxConversion::toWxString(plugin->name());
309  wxTreeItemId id = tree_->AppendItem(costPlugins, pluginName);
310  costPlugins_[*iter] = id;
311  delete plugin;
312  c++;
313  cur++;
314  message.Printf(wxT("Loading cost estimation plugins... (%04d / %04d)"),cur,ids);
315  dialog.Update(c, message);
316  dialog.SetSize(300,100);
317  }
318 
319  // fugenOperations
320  for (auto &id : operationImplementationIDs) {
321  auto op = manager_->OperationImplementationByID(id);
322  std::string label = std::to_string(id) + " : " + op.name;
323  tree_->AppendItem(operationImplementations, label);
324  }
325 
326  // fugenResources
327  for (auto &id : operationImplementationResourceIDs) {
328  auto res = manager_->OperationImplementationResourceByID(id);
329  std::string label = std::to_string(id) + " : " + res.name;
330  tree_->AppendItem(operationImplementationResources, label);
331  }
332 
333  tree_->Expand(root);
334  infoPanel_->clear();
335 }
336 
337 /**
338  * Function for checking if a FU architecture is selected in the tree view.
339  *
340  * @return True, if a FU architecture is selected.
341  */
342 bool
344  return MapTools::containsValue(fuArchitectures_, tree_->GetSelection());
345 }
346 
347 /**
348  * Function for checking if a RF architecture is selected in the tree view.
349  *
350  * @return True, if a RF architecture is selected.
351  */
352 bool
354  return MapTools::containsValue(rfArchitectures_, tree_->GetSelection());
355 }
356 
357 
358 /**
359  * Function for checking if a FU implementation is selected in the tree view.
360  *
361  * @return True, if a FU implementation is selected.
362  */
363 bool
366  fuImplementations_, tree_->GetSelection());
367 }
368 
369 
370 /**
371  * Function for checking if a RF implementation is selected in the tree view.
372  *
373  * @return True, if a RF implementation is selected.
374  */
375 bool
378  rfImplementations_, tree_->GetSelection());
379 }
380 
381 /**
382  * Function for checking if a FU entry is selected in the tree view.
383  *
384  * @return True, if a FU entry is selected.
385  */
386 bool
388  return MapTools::containsValue(fuEntries_, tree_->GetSelection());
389 }
390 
391 /**
392  * Function for checking if a RF entry is selected in the tree view.
393  *
394  * @return True, if a RF entry is selected.
395  */
396 bool
398  return MapTools::containsValue(rfEntries_, tree_->GetSelection());
399 }
400 
401 /**
402  * Function for checking if a Bus entry is selected in the tree view.
403  *
404  * @return True, if a bus entry is selected.
405  */
406 bool
408  return MapTools::containsValue(busEntries_, tree_->GetSelection());
409 }
410 
411 /**
412  * Function for checking if a socket entry is selected in the tree view.
413  *
414  * @return True, if a socket entry is selected.
415  */
416 bool
418  return MapTools::containsValue(socketEntries_, tree_->GetSelection());
419 }
420 
421 /**
422  * Function for checking if a cost function plugin is selected in the tree
423  * view.
424  *
425  * @return True, if a cost function plugin is selected.
426  */
427 bool
429  return MapTools::containsValue(costPlugins_, tree_->GetSelection());
430 }
431 
432 /**
433  * Function for checking if a operation implementation resource
434  * is selected in the tree view.
435  *
436  * @return True, if selected.
437  */
438 bool
440  std::string parent = tree_->GetItemParent(tree_->GetSelection()).IsOk() ?
441  tree_->GetItemText(tree_->GetItemParent(tree_->GetSelection()))
442  .ToStdString() : "none";
443  return parent == "Operation Implementation Resources";
444 }
445 
446 /**
447  * Function for checking if a operation implementation
448  * is selected in the tree view.
449  *
450  * @return True, if selected.
451  */
452 bool
454  std::string parent = tree_->GetItemParent(tree_->GetSelection()).IsOk() ?
455  tree_->GetItemText(tree_->GetItemParent(tree_->GetSelection()))
456  .ToStdString() : "none";
457  return parent == "Operation Implementations";
458 }
459 
460 /**
461  * Returns rowID of the FU architecture selected in the treeview.
462  *
463  * @return ID of the selected FU architecture, or -1 if none is selected.
464  */
465 RowID
467  if (!isFUArchitectureSelected()) {
468  return -1;
469  }
470 
471  RowID id = MapTools::keyForValue<RowID>(
472  fuArchitectures_, tree_->GetSelection());
473 
474  return id;
475 }
476 
477 /**
478  * Returns rowID of the RF architecture selected in the treeview.
479  *
480  * @return ID of the selected RF architecture, or -1 if none is selected.
481  */
482 RowID
484  if (!isRFArchitectureSelected()) {
485  return -1;
486  }
487  RowID id = MapTools::keyForValue<RowID>(
488  rfArchitectures_, tree_->GetSelection());
489 
490  return id;
491 }
492 
493 
494 /**
495  * Returns rowID of the FU implementation selected in the treeview.
496  *
497  * @return ID of the selected FU implementation, or -1 if none is selected.
498  */
499 RowID
501  if (!isFUImplementationSelected()) {
502  return -1;
503  }
504  RowID id = MapTools::keyForValue<RowID>(
505  fuImplementations_, tree_->GetSelection());
506 
507  return id;
508 }
509 
510 
511 /**
512  * Returns rowID of the RF implementation selected in the treeview.
513  *
514  * @return ID of the selected RF implementation, or -1 if none is selected.
515  */
516 RowID
518  if (!isRFImplementationSelected()) {
519  return -1;
520  }
521  RowID id = MapTools::keyForValue<RowID>(
522  rfImplementations_, tree_->GetSelection());
523 
524  return id;
525 }
526 
527 /**
528  * Returns rowID of the FU entry selected in the tree view.
529  *
530  * @return ID of the selected FU entry, or -1 if none is selected.
531  */
532 RowID
534  if (!isFUEntrySelected()) {
535  return -1;
536  }
537  RowID id = MapTools::keyForValue<RowID>(
538  fuEntries_, tree_->GetSelection());
539 
540  return id;
541 }
542 
543 /**
544  * Returns rowID of the RF entry selected in the tree view.
545  *
546  * @return ID of the selected RF entry, or -1 if none is selected.
547  */
548 RowID
550  if (!isRFEntrySelected()) {
551  return -1;
552  }
553  RowID id = MapTools::keyForValue<RowID>(
554  rfEntries_, tree_->GetSelection());
555 
556  return id;
557 }
558 
559 /**
560  * Returns rowID of the bus entry selected in the tree view.
561  *
562  * @return ID of the selected bus entry, or -1 if none is selected.
563  */
564 RowID
566  if (!isBusEntrySelected()) {
567  return -1;
568  }
569  RowID id = MapTools::keyForValue<RowID>(
570  busEntries_, tree_->GetSelection());
571 
572  return id;
573 }
574 
575 /**
576  * Returns rowID of the socket entry selected in the tree view.
577  *
578  * @return ID of the selected socket entry, or -1 if none is selected.
579  */
580 RowID
582  if (!isSocketEntrySelected()) {
583  return -1;
584  }
585  RowID id = MapTools::keyForValue<RowID>(
586  socketEntries_, tree_->GetSelection());
587 
588  return id;
589 }
590 
591 
592 /**
593  * Returns rowID of the cost function plugin selected in the treeview.
594  *
595  * @return ID of the selected cost function plugin, or -1 if none is selected.
596  */
597 RowID
599  if (!isCostFunctionPluginSelected()) {
600  return -1;
601  }
602  RowID id = MapTools::keyForValue<RowID>(
603  costPlugins_, tree_->GetSelection());
604 
605  return id;
606 }
607 
608 /**
609  * Returns rowID of the operation implementation selected in the treeview.
610  *
611  * @return ID of the selection, or -1 if none is selected.
612  */
613 RowID
615  if (!isOperationImplementationSelected()) {
616  return -1;
617  }
618  std::istringstream iss(tree_->GetItemText(tree_->GetSelection())
619  .ToStdString());
620  RowID id;
621  iss >> id;
622  return id;
623 }
624 
625 /**
626  * Returns rowID of the operation implementation resource
627  * selected in the treeview.
628  *
629  * @return ID of the selection, or -1 if none is selected.
630  */
631 RowID
633  if (!isOperationImplementationResourceSelected()) {
634  return -1;
635  }
636  std::istringstream iss(tree_->GetItemText(tree_->GetSelection())
637  .ToStdString());
638  RowID id;
639  iss >> id;
640  return id;
641 }
642 
643 /**
644  * Selects the given FU Entry.
645  *
646  * @param id RowID of the
647  */
648 void
650 
651  if (!MapTools::containsKey(fuEntries_, id)) {
652  return;
653  }
654 
655  tree_->SelectItem(fuEntries_[id]);
656 }
657 
658 /**
659  * Selects the given RF Entry.
660  *
661  * @param id RowID of the RF entry to select.
662  */
663 void
665 
666  if (!MapTools::containsKey(rfEntries_, id)) {
667  return;
668  }
669 
670  tree_->SelectItem(rfEntries_[id]);
671 }
672 
673 /**
674  * Selects the given Bus Entry.
675  *
676  * @param id RowID of the bus entry to select.
677  */
678 void
680 
681  if (!MapTools::containsKey(busEntries_, id)) {
682  return;
683  }
684 
685  tree_->SelectItem(busEntries_[id]);
686 }
687 
688 /**
689  * Selects the given Socket Entry.
690  *
691  * @param id RowID of the socket entry to select.
692  */
693 void
695 
696  if (!MapTools::containsKey(socketEntries_, id)) {
697  return;
698  }
699 
700  tree_->SelectItem(socketEntries_[id]);
701 }
702 
703 /**
704  * Selects the given FU architecture.
705  *
706  * @param id RowID of the
707  */
708 void
710 
711  if (!MapTools::containsKey(fuArchitectures_, id)) {
712  return;
713  }
714 
715  tree_->SelectItem(fuArchitectures_[id]);
716 }
717 
718 /**
719  * Selects the given RF architecture.
720  *
721  * @param id RowID of the
722  */
723 void
725 
726  if (!MapTools::containsKey(rfArchitectures_, id)) {
727  return;
728  }
729 
730  tree_->SelectItem(rfArchitectures_[id]);
731 }
732 
733 /**
734  * Selects the given FU implementation.
735  *
736  * @param id RowID of the FU implementation.
737  */
738 void
740 
741  if (!MapTools::containsKey(fuImplementations_, id)) {
742  return;
743  }
744 
745  tree_->SelectItem(fuImplementations_[id]);
746 }
747 
748 /**
749  * Selects the given RF implementation.
750  *
751  * @param id RowID of the RF implementation.
752  */
753 void
755 
756  if (!MapTools::containsKey(rfImplementations_, id)) {
757  return;
758  }
759 
760  tree_->SelectItem(rfImplementations_[id]);
761 }
762 
763 /**
764  * Selects the given cost function plugin.
765  *
766  * @param id RowID of the cost function plugin.
767  */
768 void
770 
771  if (!MapTools::containsKey(costPlugins_, id)) {
772  return;
773  }
774 
775  tree_->SelectItem(costPlugins_[id]);
776 }
777 
778 /**
779  * Event handler for the tree-view selection changes.
780  */
781 void
783 
784  wxTreeCtrl* ctrl = new wxTreeCtrl();
785  std::string current = ctrl->GetItemText(e.GetItem().GetID()).ToStdString();
786  std::string parent = ctrl->GetItemParent(e.GetItem().GetID()).IsOk() ?
787  ctrl->GetItemText(ctrl->GetItemParent(e.GetItem().GetID())).ToStdString() :
788  "none";
789 
790  infoPanel_->clear();
791 
792  if (isFUArchitectureSelected()) {
793  infoPanel_->displayFUArchitecture(selectedFUArchitecture());
794  } else if (isRFArchitectureSelected()) {
795  infoPanel_->displayRFArchitecture(selectedRFArchitecture());
796  } else if (isFUImplementationSelected()) {
797  infoPanel_->displayFUImplementation(selectedFUImplementation());
798  } else if (isRFImplementationSelected()) {
799  infoPanel_->displayRFImplementation(selectedRFImplementation());
800  } else if (isFUEntrySelected()) {
801  infoPanel_->displayFUEntry(selectedFUEntry());
802  } else if (isRFEntrySelected()) {
803  infoPanel_->displayRFEntry(selectedRFEntry());
804  } else if (isBusEntrySelected()) {
805  infoPanel_->displayBusEntry(selectedBusEntry());
806  } else if (isSocketEntrySelected()) {
807  infoPanel_->displaySocketEntry(selectedSocketEntry());
808  } else if (isCostFunctionPluginSelected()) {
809  infoPanel_->displayCostFunctionPlugin(selectedCostFunctionPlugin());
810  } else if (parent == HDBToHtml::OPERATION_IMPLEMENTATIONS) {
811  std::istringstream iss(current);
812  int id;
813  iss >> id;
814  infoPanel_->displayOperationImplementation(id);
815  } else if (parent == HDBToHtml::OPERATION_IMPLEMENTATION_RESOURCES) {
816  std::istringstream iss(current);
817  int id;
818  iss >> id;
819  infoPanel_->displayOperationImplementationResource(id);
820  }
821 
822  delete ctrl;
823 }
824 
825 
826 /**
827  * Event handler for right mouse button clicks in the treeview.
828  *
829  * Pops up a context menu.
830  */
831 void
832 HDBBrowserWindow::onRMBClick(wxTreeEvent& event) {
833  tree_->SelectItem(event.GetItem());
834  wxMenu* popupMenu = new wxMenu();
835  if (isFUArchitectureSelected()) {
836  popupMenu->Append(
838  _T("Add &Implementation..."));
839  }
840  if (isRFArchitectureSelected()) {
841  popupMenu->Append(
843  _T("Add &Implementation..."));
844  }
845  if (isFUEntrySelected() || isRFEntrySelected()) {
846  popupMenu->Append(
848  _T("Set Cost Function Plugin"));
849  }
850 
851  popupMenu->AppendSeparator();
852  popupMenu->Append(HDBEditorConstants::COMMAND_MODIFY, _T("&Modify..."));
853  popupMenu->Append(HDBEditorConstants::COMMAND_DELETE, _T("&Delete"));
854  PopupMenu(popupMenu, event.GetPoint());
855 }
856 
857 /**
858  * Returns label string for an function unit architecture.
859  *
860  * @param fu Function unit object to create the label from.
861  * @return Label for the fu architecture.
862  */
863 wxString
865 
866  // Operation names are put in a set which sorts them alphbetically.
867  std::set<std::string> opNames;
868  for (int i = 0; i < fu.operationCount(); i++) {
869  const HWOperation* op = fu.operation(i);
870  std::string opName =
871  op->name() + "(" + Conversion::toString(op->latency()) + ")";
872 
873  opNames.insert(opName);
874  }
875 
876  wxString archName;
877  std::set<std::string>::const_iterator oIter = opNames.begin();
878  for (; oIter != opNames.end(); oIter++) {
879  archName.Append(WxConversion::toWxString(*oIter));
880  archName.Append(_T(" "));
881  }
882 
883  return archName;
884 }
885 
886 /**
887  * Opens a link generated by HDBToHtml in the browser window.
888  *
889  * @param link Link to open.
890  */
891 void
892 HDBBrowserWindow::openLink(const wxString& link) {
893 
894  const wxString fuArchPrefix =
896  _T("/");
897 
898  const wxString rfArchPrefix =
900  _T("/");
901 
902  const wxString fuEntryPrefix =
903  _T("/") + WxConversion::toWxString(HDBToHtml::FU_ENTRIES) + _T("/");
904 
905  const wxString rfEntryPrefix =
906  _T("/") + WxConversion::toWxString(HDBToHtml::RF_ENTRIES) + _T("/");
907 
908  const wxString busEntryPrefix =
910 
911  const wxString socketEntryPrefix =
913  _T("/");
914 
915  const wxString fuImplPrefix =
917  _T("/");
918 
919  const wxString rfImplPrefix =
921  _T("/");
922 
923  const wxString costPluginPrefix =
925 
926  wxString rest;
927  if (link.StartsWith(fuArchPrefix, &rest)) {
929  selectFUArchitecture(id);
930  } else if (link.StartsWith(rfArchPrefix, &rest)) {
932  selectRFArchitecture(id);
933  } else if (link.StartsWith(fuEntryPrefix, &rest)) {
935  selectFUEntry(id);
936  } else if (link.StartsWith(rfEntryPrefix, &rest)) {
938  selectRFEntry(id);
939  } else if (link.StartsWith(busEntryPrefix, &rest)) {
941  selectBusEntry(id);
942  } else if (link.StartsWith(socketEntryPrefix, &rest)) {
944  selectSocketEntry(id);
945  } else if (link.StartsWith(fuImplPrefix, &rest)) {
947  selectFUImplementation(id);
948  } else if (link.StartsWith(rfImplPrefix, &rest)) {
950  selectRFImplementation(id);
951  } else if (link.StartsWith(costPluginPrefix, &rest)) {
953  selectCostFunctionPlugin(id);
954  }
955 }
HDB::FUArchitecture
Definition: FUArchitecture.hh:55
HDBBrowserWindow::update
void update()
Definition: HDBBrowserWindow.cc:109
HDB::FUEntry
Definition: FUEntry.hh:49
HDBToHtml::RF_IMPLEMENTATIONS
static const std::string RF_IMPLEMENTATIONS
Definition: HDBToHtml.hh:73
HDBBrowserWindow::fuArchLabel
wxString fuArchLabel(const TTAMachine::FunctionUnit &fu) const
Definition: HDBBrowserWindow.cc:864
WxConversion::toWxString
static wxString toWxString(const std::string &source)
HDB::RFEntry::hasImplementation
virtual bool hasImplementation() const
Definition: RFEntry.cc:74
HDBEditorConstants::COMMAND_SET_COST_PLUGIN
@ COMMAND_SET_COST_PLUGIN
Definition: HDBEditorConstants.hh:58
HDBBrowserWindow.hh
HDB
Definition: CostDatabase.hh:49
HDBBrowserWindow
Definition: HDBBrowserWindow.hh:59
HDBBrowserWindow::selectRFArchitecture
void selectRFArchitecture(int id)
Definition: HDBBrowserWindow.cc:724
TTAMachine::HWOperation
Definition: HWOperation.hh:52
HDBBrowserWindow::isRFArchitectureSelected
bool isRFArchitectureSelected()
Definition: HDBBrowserWindow.cc:353
FUArchitecture.hh
HDBBrowserWindow::selectBusEntry
void selectBusEntry(int id)
Definition: HDBBrowserWindow.cc:679
HDBToHtml.hh
MapTools.hh
HDBEditorConstants.hh
HDB::RFEntry
Definition: RFEntry.hh:47
HDBBrowserWindow::isRFImplementationSelected
bool isRFImplementationSelected()
Definition: HDBBrowserWindow.cc:376
HDB::FUArchitecture::architecture
TTAMachine::FunctionUnit & architecture() const
Definition: FUArchitecture.cc:131
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
HDBToHtml::FU_IMPLEMENTATIONS
static const std::string FU_IMPLEMENTATIONS
Definition: HDBToHtml.hh:72
Conversion::toString
static std::string toString(const T &source)
HDBBrowserWindow::selectFUImplementation
void selectFUImplementation(int id)
Definition: HDBBrowserWindow.cc:739
HDBBrowserWindow::selectRFImplementation
void selectRFImplementation(int id)
Definition: HDBBrowserWindow.cc:754
HDB::CachedHDBManager
Definition: CachedHDBManager.hh:63
HDB::RFEntry::architecture
RFArchitecture & architecture() const
Definition: RFEntry.cc:145
HDBBrowserWindow::isSocketEntrySelected
bool isSocketEntrySelected()
Definition: HDBBrowserWindow.cc:417
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
HDBBrowserWindow::selectFUEntry
void selectFUEntry(int id)
Definition: HDBBrowserWindow.cc:649
DBTypes.hh
HDBBrowserWindow::selectedOperationImplementationResource
RowID selectedOperationImplementationResource()
Definition: HDBBrowserWindow.cc:632
HDBToHtml::OPERATION_IMPLEMENTATIONS
static const std::string OPERATION_IMPLEMENTATIONS
Definition: HDBToHtml.hh:75
HDBBrowserWindow::isBusEntrySelected
bool isBusEntrySelected()
Definition: HDBBrowserWindow.cc:407
HDBEditorConstants::COMMAND_MODIFY
@ COMMAND_MODIFY
Definition: HDBEditorConstants.hh:59
HDB::RFImplementation
Definition: RFImplementation.hh:50
HDBToHtml::FU_ENTRIES
static const std::string FU_ENTRIES
Definition: HDBToHtml.hh:65
HDB::FUEntry::hasArchitecture
virtual bool hasArchitecture() const
Definition: FUEntry.cc:117
HDBBrowserWindow::onItemSelected
void onItemSelected(wxTreeEvent &event)
Definition: HDBBrowserWindow.cc:782
HWOperation.hh
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
HDBBrowserWindow::isFUEntrySelected
bool isFUEntrySelected()
Definition: HDBBrowserWindow.cc:387
HDBToHtml::COST_PLUGINS
static const std::string COST_PLUGINS
Definition: HDBToHtml.hh:74
RFImplementation.hh
HDBBrowserWindow::selectCostFunctionPlugin
void selectCostFunctionPlugin(int id)
Definition: HDBBrowserWindow.cc:769
Conversion.hh
HDBBrowserWindow::selectedFUArchitecture
RowID selectedFUArchitecture()
Definition: HDBBrowserWindow.cc:466
HDBBrowserWindow::isOperationImplementationResourceSelected
bool isOperationImplementationResourceSelected()
Definition: HDBBrowserWindow.cc:439
HDBEditorConstants::COMMAND_ADD_FU_IMPLEMENTATION
@ COMMAND_ADD_FU_IMPLEMENTATION
Definition: HDBEditorConstants.hh:51
HDB::FUEntry::architecture
FUArchitecture & architecture() const
Definition: FUEntry.cc:129
FUEntry.hh
HDBToHtml::BUS_ENTRIES
static const std::string BUS_ENTRIES
Definition: HDBToHtml.hh:68
HDBBrowserWindow::selectedCostFunctionPlugin
RowID selectedCostFunctionPlugin()
Definition: HDBBrowserWindow.cc:598
HDBEditorConstants::COMMAND_ADD_RF_IMPLEMENTATION
@ COMMAND_ADD_RF_IMPLEMENTATION
Definition: HDBEditorConstants.hh:52
HDBToHtml::RF_IU_ENTRIES
static const std::string RF_IU_ENTRIES
Definition: HDBToHtml.hh:67
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
HDBToHtml::OPERATION_IMPLEMENTATION_RESOURCES
static const std::string OPERATION_IMPLEMENTATION_RESOURCES
Definition: HDBToHtml.hh:76
HDBBrowserWindow::~HDBBrowserWindow
virtual ~HDBBrowserWindow()
Definition: HDBBrowserWindow.cc:89
RFArchitecture.hh
HDBToHtml::RF_ENTRIES
static const std::string RF_ENTRIES
Definition: HDBToHtml.hh:66
HDBBrowserInfoPanel
Definition: HDBBrowserInfoPanel.hh:49
HDB::RFEntry::implementation
RFImplementation & implementation() const
Definition: RFEntry.cc:102
HDBBrowserWindow::selectedRFImplementation
RowID selectedRFImplementation()
Definition: HDBBrowserWindow.cc:517
FUImplementation.hh
HDBBrowserInfoPanel.hh
HWBlockArchitecture::id
RowID id() const
Definition: HWBlockArchitecture.cc:79
HDBBrowserWindow::selectedOperationImplementation
RowID selectedOperationImplementation()
Definition: HDBBrowserWindow.cc:614
HDB::FUImplementation
Definition: FUImplementation.hh:53
HDB::RFArchitecture
Definition: RFArchitecture.hh:50
CachedHDBManager.hh
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
HDBBrowserWindow::selectedFUImplementation
RowID selectedFUImplementation()
Definition: HDBBrowserWindow.cc:500
HDBBrowserWindow::selectSocketEntry
void selectSocketEntry(int id)
Definition: HDBBrowserWindow.cc:694
HDB::HWBlockImplementation::id
RowID id() const
Definition: HWBlockImplementation.cc:128
MapTools::containsValue
static bool containsValue(const MapType &aMap, const ValueType &aValue)
HDBToHtml::SOCKET_ENTRIES
static const std::string SOCKET_ENTRIES
Definition: HDBToHtml.hh:69
HDBBrowserWindow::selectRFEntry
void selectRFEntry(int id)
Definition: HDBBrowserWindow.cc:664
HDBBrowserWindow::selectedRFEntry
RowID selectedRFEntry()
Definition: HDBBrowserWindow.cc:549
HDBBrowserWindow::openLink
void openLink(const wxString &link)
Definition: HDBBrowserWindow.cc:892
HDBEditorConstants::COMMAND_DELETE
@ COMMAND_DELETE
Definition: HDBEditorConstants.hh:60
HDBBrowserWindow::selectedBusEntry
RowID selectedBusEntry()
Definition: HDBBrowserWindow.cc:565
HDBBrowserWindow::isFUArchitectureSelected
bool isFUArchitectureSelected()
Definition: HDBBrowserWindow.cc:343
CostFunctionPlugin.hh
RFEntry.hh
WxConversion.hh
HDB::HWBlockImplementation::moduleName
std::string moduleName() const
Definition: HWBlockImplementation.cc:153
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
HDBBrowserWindow::selectFUArchitecture
void selectFUArchitecture(int id)
Definition: HDBBrowserWindow.cc:709
TTAMachine::HWOperation::latency
int latency() const
Definition: HWOperation.cc:216
Conversion::toInt
static int toInt(const T &source)
HDBBrowserWindow::selectedSocketEntry
RowID selectedSocketEntry()
Definition: HDBBrowserWindow.cc:581
HDBBrowserWindow::isOperationImplementationSelected
bool isOperationImplementationSelected()
Definition: HDBBrowserWindow.cc:453
HDBBrowserWindow::onRMBClick
void onRMBClick(wxTreeEvent &event)
Definition: HDBBrowserWindow.cc:832
HDB::FUEntry::hasImplementation
virtual bool hasImplementation() const
Definition: FUEntry.cc:74
TTAMachine
Definition: Assembler.hh:48
HDB::FUEntry::implementation
FUImplementation & implementation() const
Definition: FUEntry.cc:86
HDBBrowserWindow::setHDBManager
void setHDBManager(HDB::CachedHDBManager &manager)
Definition: HDBBrowserWindow.cc:99
WxConversion::toString
static std::string toString(const wxString &source)
HDBBrowserWindow::isFUImplementationSelected
bool isFUImplementationSelected()
Definition: HDBBrowserWindow.cc:364
HDBBrowserWindow::isCostFunctionPluginSelected
bool isCostFunctionPluginSelected()
Definition: HDBBrowserWindow.cc:428
HDB::CostFunctionPlugin::name
std::string name() const
Definition: CostFunctionPlugin.cc:84
HDBToHtml::FU_ARCHITECTURES
static const std::string FU_ARCHITECTURES
Definition: HDBToHtml.hh:70
HDB::RFEntry::hasArchitecture
virtual bool hasArchitecture() const
Definition: RFEntry.cc:117
HDB::CostFunctionPlugin
Definition: CostFunctionPlugin.hh:43
HDBToHtml::RF_ARCHITECTURES
static const std::string RF_ARCHITECTURES
Definition: HDBToHtml.hh:71
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
HDBBrowserWindow::selectedFUEntry
RowID selectedFUEntry()
Definition: HDBBrowserWindow.cc:533
HDBBrowserWindow::isRFEntrySelected
bool isRFEntrySelected()
Definition: HDBBrowserWindow.cc:397
FunctionUnit.hh
HDBBrowserWindow::selectedRFArchitecture
RowID selectedRFArchitecture()
Definition: HDBBrowserWindow.cc:483