diff --git a/vlsisapd/src/dtr/src/PyTechno.cpp b/vlsisapd/src/dtr/src/PyTechno.cpp index 32eb040c..180e17da 100644 --- a/vlsisapd/src/dtr/src/PyTechno.cpp +++ b/vlsisapd/src/dtr/src/PyTechno.cpp @@ -13,7 +13,8 @@ void translator(DTRException const& e) { } -// specify that Techno::getValue & Techno::getValueAsString methods have optional arguments +// specify that Techno::getRule & Techno::getValue & Techno::getValueAsString methods have optional arguments +BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getRule_overloads , getRule , 1, 3); BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getValue_overloads , getValue , 1, 3); BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getValueAsString_overloads, getValueAsString, 1, 3); // specify that Techno::addRule method has optional arguments @@ -49,7 +50,8 @@ BOOST_PYTHON_MODULE(pyDTR) { // accessors .def("getName" , &Techno::getName) .def("getUnit" , &Techno::getUnit) - .def("getValue" , &Techno::getValue, getValue_overloads()) + .def("getRule" , &Techno::getRule , getRule_overloads()[return_value_policy()]) + .def("getValue" , &Techno::getValue , getValue_overloads()) .def("getValueAsString", &Techno::getValueAsString, getValueAsString_overloads()) // modifiers diff --git a/vlsisapd/src/dtr/src/Techno.cpp b/vlsisapd/src/dtr/src/Techno.cpp index ffba92ce..73b8d9ca 100644 --- a/vlsisapd/src/dtr/src/Techno.cpp +++ b/vlsisapd/src/dtr/src/Techno.cpp @@ -46,7 +46,7 @@ ARule* Techno::addARule (Name name, double value, Name ref, Name layer1, Name la return arule; } -double Techno::getValue(Name name, Name layer1, Name layer2) { +Rule* Techno::getRule(Name name, Name layer1, Name layer2) { bool testL1 = (layer1 == Name("")) ? false : true; bool testL2 = (layer2 == Name("")) ? false : true; @@ -57,18 +57,18 @@ double Techno::getValue(Name name, Name layer1, Name layer2) { if (rule->getLayer1() == layer1) { if (testL2) { if (rule->getLayer2() == layer2) { - return rule->getValue(); + return rule; } } else { - return rule->getValue(); + return rule; } } } else { - return rule->getValue(); + return rule; } } } - string error ("[ERROR] Could not found rule: "); + string error ("[ERROR] Could not find rule: "); error += name.getString(); error += "."; error += layer1.getString(); @@ -78,36 +78,12 @@ double Techno::getValue(Name name, Name layer1, Name layer2) { throw DTRException(error); } -string Techno::getValueAsString(Name name, Name layer1, Name layer2) { - bool testL1 = (layer1 == Name("")) ? false : true; - bool testL2 = (layer2 == Name("")) ? false : true; +double Techno::getValue(Name name, Name layer1, Name layer2) { + return getRule(name, layer1, layer2)->getValue(); +} - 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->getValueAsString(); - } - } else { - return rule->getValueAsString(); - } - } - } else { - return rule->getValueAsString(); - } - } - } - string error ("[ERROR] Could not found rule: "); - error += name.getString(); - error += "."; - error += layer1.getString(); - error += "."; - error += layer2.getString(); - error += "."; - throw DTRException(error); +string Techno::getValueAsString(Name name, Name layer1, Name layer2) { + return getRule(name, layer1, layer2)->getValueAsString(); } Techno* Techno::readFromFile(const string filePath) { diff --git a/vlsisapd/src/dtr/src/vlsisapd/dtr/Techno.h b/vlsisapd/src/dtr/src/vlsisapd/dtr/Techno.h index e3edb351..e5fd3ecd 100644 --- a/vlsisapd/src/dtr/src/vlsisapd/dtr/Techno.h +++ b/vlsisapd/src/dtr/src/vlsisapd/dtr/Techno.h @@ -31,6 +31,7 @@ class Techno { 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); + Rule* getRule(Name name, Name layer1=Name(""), Name layer2=Name("")); double getValue(Name name, Name layer1=Name(""), Name layer2=Name("")); std::string getValueAsString(Name name, Name layer1=Name(""), Name layer2=Name(""));