OpenASIP 2.2
Loading...
Searching...
No Matches
BlocksConnectICCmd.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2021 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 BlocksConnectICCmd.cc
26 *
27 * Definition of BlocksConnectICCmd class. (Derived from VLIWConnectICCmd.cc)
28 *
29 * @author Kanishkan Vadivel 2021 (k.vadivel-no.spam-tue.nl)
30 * @note rating: red
31 */
32
33#include "BlocksConnectICCmd.hh"
34
35#include <wx/docview.h>
36
37#include <string>
38
39#include "DSDBManager.hh"
41#include "FileSystem.hh"
42#include "MDFDocument.hh"
43#include "Machine.hh"
44#include "Model.hh"
45#include "ProDe.hh"
46#include "ProDeConstants.hh"
47
48using namespace TTAMachine;
49
52
54
55/**
56 * Executes the command.
57 *
58 * @return True, if the command was succesfully executed, false otherwise.
59 */
60bool
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 const& 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}
106
107/**
108 * Returns id of this command.
109 */
110int
114
115/**
116 * Creates and returns a new instance of this command.
117 */
120 return new BlocksConnectICCmd();
121}
122
123/**
124 * Returns short version of the command name.
125 */
126std::string
130
131/**
132 * Returns true when the command is executable, false when not.
133 *
134 * This command is executable when a document is open.
135 *
136 * @return True, if a document is open.
137 */
138bool
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}
#define assert(condition)
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
#define ILLEGAL_ROW_ID
TTAMachine::Machine * machine
the architecture definition of the estimated processor
virtual std::string shortName() const
virtual BlocksConnectICCmd * create() const
virtual int id() const
RowID addArchitecture(const TTAMachine::Machine &mom)
TTAMachine::Machine * architecture(RowID id) const
static DSDBManager * createNew(const std::string &file)
RowID addConfiguration(const MachineConfiguration &conf)
virtual std::vector< RowID > explore(const RowID &startPointConfigurationID, const unsigned int &maxIter=0)
virtual void setDSDB(DSDBManager &dsdb)
static DesignSpaceExplorerPlugin * loadExplorerPlugin(const std::string &pluginName, DSDBManager *dsdb=NULL)
wxView * view() const
static bool removeFileOrDirectory(const std::string &path)
Definition Model.hh:50
void pushToStack()
Definition Model.cc:167
void notifyObservers(bool modified=true)
Definition Model.cc:152
void popFromStack(bool modified=false)
Definition Model.cc:195
static const std::string CMD_SNAME_BLOCKS_CONNECT_IC
Command name for the "Blocks Connect IC" command.
virtual void copyFromMachine(Machine &machine)
Definition Machine.cc:884