OpenASIP  2.0
Public Member Functions | List of all members
BlocksConnectICCmd Class Reference

#include <BlocksConnectICCmd.hh>

Inheritance diagram for BlocksConnectICCmd:
Inheritance graph
Collaboration diagram for BlocksConnectICCmd:
Collaboration graph

Public Member Functions

 BlocksConnectICCmd ()
 
virtual ~BlocksConnectICCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual BlocksConnectICCmdcreate () const
 
virtual bool isEnabled ()
 
virtual std::string shortName () const
 
- Public Member Functions inherited from EditorCommand
 EditorCommand (std::string name, wxWindow *parent=NULL)
 
virtual ~EditorCommand ()
 
void setView (wxView *view)
 
wxView * view () const
 
virtual std::string icon () const
 
- Public Member Functions inherited from GUICommand
 GUICommand (std::string name, wxWindow *parent)
 
virtual ~GUICommand ()
 
virtual bool isChecked () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Detailed Description

Command for calling BlocksConnectIC explorer plugin.

Definition at line 41 of file BlocksConnectICCmd.hh.

Constructor & Destructor Documentation

◆ BlocksConnectICCmd()

BlocksConnectICCmd::BlocksConnectICCmd ( )

Definition at line 50 of file BlocksConnectICCmd.cc.

Referenced by create().

◆ ~BlocksConnectICCmd()

BlocksConnectICCmd::~BlocksConnectICCmd ( )
virtual

Definition at line 53 of file BlocksConnectICCmd.cc.

53 {}

Member Function Documentation

◆ create()

BlocksConnectICCmd * BlocksConnectICCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Implements GUICommand.

Definition at line 119 of file BlocksConnectICCmd.cc.

119  {
120  return new BlocksConnectICCmd();
121 }

References BlocksConnectICCmd().

Here is the call graph for this function:

◆ Do()

bool BlocksConnectICCmd::Do ( )
virtual

Executes the command.

Returns
True, if the command was succesfully executed, false otherwise.

Implements GUICommand.

Definition at line 61 of file BlocksConnectICCmd.cc.

61  {
62  assert(view() != NULL);
63 
65  dynamic_cast<MDFDocument*>(view()->GetDocument())
66  ->getModel()
67  ->getMachine();
68 
69  Model* model =
70  dynamic_cast<MDFDocument*>(view()->GetDocument())->getModel();
71 
72  model->pushToStack();
73 
74  // open up a temporary dsdb
75  const std::string dsdbFile = "tmp.dsdb";
77  DSDBManager* dsdb = DSDBManager::createNew(dsdbFile);
78  RowID archID = dsdb->addArchitecture(*machine);
79 
81  RowID confID = dsdb->addConfiguration(confIn);
82 
83  // load BlocksConnectIC explorer plugin
84  DesignSpaceExplorer explorer;
86  explorer.loadExplorerPlugin("BlocksConnectIC", dsdb);
87  plugin->setDSDB(*dsdb);
88 
89  try {
90  std::vector<RowID> result = plugin->explore(confID, 0);
91  // store the new machine
92  TTAMachine::Machine& newMachine =
93  *dsdb->architecture(confID + result.size());
94  machine->copyFromMachine(newMachine);
95  } catch (Exception e) {
96  std::cerr << "Could not create Blocks Connect IC" << std::endl;
98  model->popFromStack();
99  return false;
100  }
102  model->notifyObservers();
103 
104  return true;
105 }

References DSDBManager::addArchitecture(), DSDBManager::addConfiguration(), DSDBManager::architecture(), assert, TTAMachine::Machine::copyFromMachine(), DSDBManager::createNew(), DesignSpaceExplorerPlugin::explore(), ILLEGAL_ROW_ID, DesignSpaceExplorer::loadExplorerPlugin(), machine, Model::notifyObservers(), Model::popFromStack(), Model::pushToStack(), FileSystem::removeFileOrDirectory(), DesignSpaceExplorer::setDSDB(), and EditorCommand::view().

Here is the call graph for this function:

◆ id()

int BlocksConnectICCmd::id ( ) const
virtual

Returns id of this command.

Implements GUICommand.

Definition at line 111 of file BlocksConnectICCmd.cc.

111  {
113 }

References ProDeConstants::COMMAND_BLOCKS_CONNECT_IC.

◆ isEnabled()

bool BlocksConnectICCmd::isEnabled ( )
virtual

Returns true when the command is executable, false when not.

This command is executable when a document is open.

Returns
True, if a document is open.

Reimplemented from EditorCommand.

Definition at line 139 of file BlocksConnectICCmd.cc.

139  {
140  wxDocManager* manager = wxGetApp().docManager();
141  wxView* view = manager->GetCurrentView();
142 
143  if (view == NULL) {
144  return false;
145  }
146 
147  Model* model =
148  dynamic_cast<MDFDocument*>(view->GetDocument())->getModel();
149 
150  if (model == NULL) {
151  return false;
152  }
153  return true;
154 }

References EditorCommand::view().

Here is the call graph for this function:

◆ shortName()

std::string BlocksConnectICCmd::shortName ( ) const
virtual

Returns short version of the command name.

Reimplemented from GUICommand.

Definition at line 127 of file BlocksConnectICCmd.cc.

127  {
129 }

References ProDeConstants::CMD_SNAME_BLOCKS_CONNECT_IC.


The documentation for this class was generated from the following files:
ILLEGAL_ROW_ID
#define ILLEGAL_ROW_ID
Definition: DSDBManager.hh:58
FileSystem::removeFileOrDirectory
static bool removeFileOrDirectory(const std::string &path)
Definition: FileSystem.cc:493
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
DSDBManager::architecture
TTAMachine::Machine * architecture(RowID id) const
Definition: DSDBManager.cc:807
DesignSpaceExplorerPlugin
Definition: DesignSpaceExplorerPlugin.hh:55
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
Model::pushToStack
void pushToStack()
Definition: Model.cc:167
EditorCommand::EditorCommand
EditorCommand(std::string name, wxWindow *parent=NULL)
Definition: EditorCommand.cc:42
Model::notifyObservers
void notifyObservers(bool modified=true)
Definition: Model.cc:152
assert
#define assert(condition)
Definition: Application.hh:86
DSDBManager::MachineConfiguration
Definition: DSDBManager.hh:78
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
Exception
Definition: Exception.hh:54
DSDBManager
Definition: DSDBManager.hh:76
DesignSpaceExplorer::loadExplorerPlugin
static DesignSpaceExplorerPlugin * loadExplorerPlugin(const std::string &pluginName, DSDBManager *dsdb=NULL)
Definition: DesignSpaceExplorer.cc:527
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
MDFDocument
Definition: MDFDocument.hh:51
ProDeConstants::CMD_SNAME_BLOCKS_CONNECT_IC
static const std::string CMD_SNAME_BLOCKS_CONNECT_IC
Command name for the "Blocks Connect IC" command.
Definition: ProDeConstants.hh:247
DSDBManager::addConfiguration
RowID addConfiguration(const MachineConfiguration &conf)
Definition: DSDBManager.cc:299
DSDBManager::addArchitecture
RowID addArchitecture(const TTAMachine::Machine &mom)
Definition: DSDBManager.cc:191
DSDBManager::createNew
static DSDBManager * createNew(const std::string &file)
Definition: DSDBManager.cc:141
DesignSpaceExplorerPlugin::explore
virtual std::vector< RowID > explore(const RowID &startPointConfigurationID, const unsigned int &maxIter=0)
Definition: DesignSpaceExplorerPlugin.cc:174
ProDeConstants::CMD_NAME_BLOCKS_CONNECT_IC
static const std::string CMD_NAME_BLOCKS_CONNECT_IC
Command name for the "Blcoks Connect IC" command.
Definition: ProDeConstants.hh:151
Model
Definition: Model.hh:50
DesignSpaceExplorer::setDSDB
virtual void setDSDB(DSDBManager &dsdb)
Definition: DesignSpaceExplorer.cc:107
TTAMachine::Machine::copyFromMachine
virtual void copyFromMachine(Machine &machine)
Definition: Machine.cc:890
DesignSpaceExplorer
Definition: DesignSpaceExplorer.hh:70
BlocksConnectICCmd::BlocksConnectICCmd
BlocksConnectICCmd()
Definition: BlocksConnectICCmd.cc:50
TTAMachine::Machine
Definition: Machine.hh:73
ProDeConstants::COMMAND_BLOCKS_CONNECT_IC
@ COMMAND_BLOCKS_CONNECT_IC
Definition: ProDeConstants.hh:456