diff --git a/vlsisapd/src/dtr/src/PyDtr.cpp b/vlsisapd/src/dtr/src/PyDtr.cpp index a73c8433..1d50a46d 100644 --- a/vlsisapd/src/dtr/src/PyDtr.cpp +++ b/vlsisapd/src/dtr/src/PyDtr.cpp @@ -46,6 +46,8 @@ BOOST_PYTHON_MODULE(DTR) { // modifiers .def("setType" , &Rule::setType ) + .def("setValue" , &Rule::setValue ) + .def("setRef" , &Rule::setRef ) ; // class DTR::ARule derived from DTR::Rule @@ -53,15 +55,19 @@ BOOST_PYTHON_MODULE(DTR) { ; // class DTR::Techno - class_("Techno", init()) + class_("Techno", init()) // accessors .def("getName" , &Techno::getName) .def("getUnit" , &Techno::getUnit) + .def("getVersion" , &Techno::getVersion) .def("getRule" , &Techno::getRule , getRule_overloads()[return_value_policy()]) .def("getValue" , &Techno::getValue , getValue_overloads()) .def("getValueAsString", &Techno::getValueAsString, getValueAsString_overloads()[return_value_policy()]) // modifiers + .def("setName" , &Techno::setName) + .def("setUnit" , &Techno::setUnit) + .def("setVersion" , &Techno::setVersion) .def("addRule" , &Techno::addRule , addRule_overloads()[return_value_policy()]) .def("addARule" , &Techno::addARule, return_value_policy()) diff --git a/vlsisapd/src/dtr/src/Techno.cpp b/vlsisapd/src/dtr/src/Techno.cpp index 665b15dd..79d97b4a 100644 --- a/vlsisapd/src/dtr/src/Techno.cpp +++ b/vlsisapd/src/dtr/src/Techno.cpp @@ -36,7 +36,7 @@ namespace { } namespace DTR { -Techno::Techno(Name name, Name unit) : _name(name), _unit(unit) {} +Techno::Techno(Name name, Name unit, Name version) : _name(name), _unit(unit), _version(version) {} Rule* Techno::addRule (Name name, double value, Name ref, Name layer1, Name layer2) { Rule* rule = new Rule(name, value, ref, layer1, layer2); @@ -51,37 +51,11 @@ ARule* Techno::addARule (Name name, double value, Name ref, Name layer1, Name la } Rule* Techno::getRule(Name name, Name layer1, Name layer2) { - //bool testL1 = (layer1 == Name("")) ? false : true; - //bool testL2 = (layer2 == Name("")) ? false : true; - for (size_t i = 0 ; i < _rules.size() ; i++) { Rule* rule = _rules[i]; - // if (rule->getName() == name) { - // if (testL1) { - // if (rule->getLayer1() == layer1) { - // if (testL2) { - // if (rule->getLayer2() == layer2) { - // return rule; - // } - // } else { - // return rule; - // } - // } - // } else { - // return rule; - // } - // } if ((rule->getName() == name) && (rule->getLayer1() == layer1) && (rule->getLayer2() == layer2)) return rule; } - //string error ("[ERROR] Could not find rule: "); - //error += name.getString(); - //error += "."; - //error += layer1.getString(); - //error += "."; - //error += layer2.getString(); - //error += "."; - //throw DTRException(error); return NULL; } @@ -111,19 +85,20 @@ Techno* Techno::readFromFile(const string filePath) { string error ("[ERROR] Failed to parse: "); error += filePath; throw DTRException(error); - //return NULL; } xmlNode* rootElement = xmlDocGetRootElement(doc); if (rootElement->type == XML_ELEMENT_NODE && xmlStrEqual(rootElement->name, (xmlChar*)"technology")) { xmlChar* technoNameC = xmlGetProp(rootElement, (xmlChar*)"name"); xmlChar* technoUnitC = xmlGetProp(rootElement, (xmlChar*)"unit"); + xmlChar* technoVersC = xmlGetProp(rootElement, (xmlChar*)"version"); - if (technoNameC && technoUnitC) { + if (technoNameC && technoUnitC && technoVersC) { Name name ((const char*)technoNameC); Name unit ((const char*)technoUnitC); - techno = new Techno(name, unit); + Name vers ((const char*)technoVersC); + techno = new Techno(name, unit, vers); } else { - throw DTRException("[ERROR] 'technology' node must have 'name' and 'unit' properties."); + throw DTRException("[ERROR] 'technology' node must have 'name', 'unit' and 'version' properties."); return NULL; } @@ -215,7 +190,7 @@ bool Techno::writeToFile(string filePath) { throw DTRException("[ERROR] Cannot writeToFile since no rule is defined!"); } - file << "" << endl + file << "" << endl << " " << endl; file.setf(ios::left, ios::adjustfield); diff --git a/vlsisapd/src/dtr/src/vlsisapd/dtr/Techno.h b/vlsisapd/src/dtr/src/vlsisapd/dtr/Techno.h index 585b6bd2..91978260 100644 --- a/vlsisapd/src/dtr/src/vlsisapd/dtr/Techno.h +++ b/vlsisapd/src/dtr/src/vlsisapd/dtr/Techno.h @@ -22,14 +22,16 @@ class Rule; class ARule; class Techno { public: - Techno(Name name, Name unit); + Techno(Name name, Name unit, Name version); inline Name getName(); inline Name getUnit(); + inline Name getVersion(); inline std::vector& getRules(); inline void setName(Name); inline void setUnit(Name); + inline void setVersion(Name); Rule* addRule (Name name, double value, Name ref, Name layer1=Name(""), Name layer2=Name("")); ARule* addARule(Name name, double value, Name ref, Name layer1 , Name layer2); @@ -43,15 +45,18 @@ class Techno { Name _name; Name _unit; + Name _version; std::vector _rules; }; -inline Name Techno::getName() { return _name; }; -inline Name Techno::getUnit() { return _unit; }; +inline Name Techno::getName() { return _name; }; +inline Name Techno::getUnit() { return _unit; }; +inline Name Techno::getVersion() { return _version; }; inline std::vector& Techno::getRules() { return _rules; }; -inline void Techno::setName(Name name) { _name = name; }; -inline void Techno::setUnit(Name unit) { _unit = unit; }; +inline void Techno::setName (Name name) { _name = name; }; +inline void Techno::setUnit (Name unit) { _unit = unit; }; +inline void Techno::setVersion(Name version) { _version = version; }; } // namespace DTR #endif