OpenASIP 2.2
Loading...
Searching...
No Matches
FUGenerated.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2017 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 FUGenerated.cc
26 *
27 * Implementation of FUGenerated.
28 *
29 * @author Lasse Lehtonen 2017 (lasse.lehtonen-no.spam-tut.fi)
30 */
31
32#include "FUGenerated.hh"
34
35namespace IDF {
36
37const std::string ATTRIB_NAME = "name";
38const std::string TAG_OPERATION = "operation";
39const std::string TAG_OPERATION_ID = "operation-id";
40const std::string TAG_OPERATION_LATENCY = "operation-latency";
41const std::string TAG_OPTION = "option";
42const std::string TAG_FUGENERATE = "fu-generate";
43const std::string TAG_HDBFILE = "hdb-file";
44
45FUGenerated::FUGenerated(const std::string& name) : name_(name) {}
46
47void
50
51 for (int i = state->childCount() - 1; i >= 0; --i) {
52 ObjectState* child = state->child(i);
53
54 if (child->name() == TAG_OPERATION) {
55 std::string opName = child->stringAttribute(ATTRIB_NAME);
56 std::string hdbFile =
58 int id = child->childByName(TAG_OPERATION_ID)->intValue();
59 int latency = 0;
60 if (child->hasChild(TAG_OPERATION_LATENCY)) {
61 latency =
63 }
64 Info info = {opName, hdbFile, id, latency};
65 operations_.emplace_back(info);
66 } else if (child->name() == TAG_OPTION) {
67 options_.emplace_back(child->stringValue());
68 }
69 }
70}
71
75
77
78 for (const auto operation : operations_) {
80 opState->setAttribute(ATTRIB_NAME, operation.operationName);
81 ObjectState* hdbState = new ObjectState(TAG_HDBFILE);
82 hdbState->setValue(operation.hdb);
84 idState->setValue(operation.id);
86 latencyState->setValue(operation.latency);
87 opState->addChild(hdbState);
88 opState->addChild(idState);
89 opState->addChild(latencyState);
90 state->addChild(opState);
91 }
92
93 for (const auto option : options_) {
94 ObjectState* opState = new ObjectState(TAG_OPTION);
95 opState->setValue(option);
96 state->addChild(opState);
97 }
98
99 return state;
100}
101
102std::string
104 return name_;
105}
106
107void
108FUGenerated::name(const std::string& newName) {
109 name_ = newName;
110}
111
112std::vector<FUGenerated::Info>&
116
117const std::vector<FUGenerated::Info>&
119 return operations_;
120}
121
122const std::vector<std::string>&
126
127void
129 operations_.emplace_back(op);
130}
131
132void
134 dagOperations_.emplace_back(op.operationName);
135 for (auto&& subop : op.suboperations) {
136 operations_.emplace_back(subop);
137 }
138}
139
140const std::vector<std::string>&
142 return options_;
143}
144} // namespace IDF
const std::vector< std::string > & options() const
ObjectState * saveState() const override
std::vector< Info > & operations()
std::vector< Info > operations_
FUGenerated()=default
void addOperation(const Info &op)
std::string name_
std::vector< std::string > options_
std::vector< std::string > dagOperations_
void loadState(const ObjectState *state) override
std::string name() const
const std::vector< std::string > & dagOperations() const
ObjectState * childByName(const std::string &name) const
void setAttribute(const std::string &name, const std::string &value)
void setValue(const std::string &value)
bool hasChild(const std::string &name) const
ObjectState * child(int index) const
void addChild(ObjectState *child)
int intValue() const
std::string stringAttribute(const std::string &name) const
std::string stringValue() const
std::string name() const
int childCount() const
const std::string TAG_OPTION
const std::string TAG_OPERATION
const std::string TAG_OPERATION_LATENCY
const std::string ATTRIB_NAME
const std::string TAG_HDBFILE
const std::string TAG_OPERATION_ID
const std::string TAG_FUGENERATE
std::vector< Info > suboperations