Skip to content
Snippets Groups Projects
Commit 676ebaa1 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Fix attribute parsing findBestMatch + add log if matchingSpecs is empty.

parent 541ea019
No related branches found
No related tags found
3 merge requests!279v0.4.0,!253v0.4.0,!163Export refactor
...@@ -120,11 +120,10 @@ Aidge::ImplSpec Aidge::OperatorImpl::getBestMatch(const ImplSpec& requiredSpecs) ...@@ -120,11 +120,10 @@ Aidge::ImplSpec Aidge::OperatorImpl::getBestMatch(const ImplSpec& requiredSpecs)
std::string qualifier; std::string qualifier;
const auto qualifierPos = std::find_if(attrName.begin(), attrName.end(), const auto qualifierPos = std::find_if(attrName.begin(), attrName.end(),
[](char c) { return c == ':'; }); [](char c) { return c == ':'; });
if (qualifierPos != attrName.begin()) { if (qualifierPos != attrName.end()) {
name = attrName.substr(0, qualifierPos - attrName.begin()); name = attrName.substr(0, (qualifierPos - attrName.begin()));
qualifier = attrName.substr(qualifierPos - attrName.begin()); qualifier = attrName.substr((qualifierPos - attrName.begin())+1);
} }
const bool mandatory = (qualifier == "!"); const bool mandatory = (qualifier == "!");
if (mandatory) { if (mandatory) {
// Required attribute: // Required attribute:
...@@ -161,6 +160,10 @@ Aidge::ImplSpec Aidge::OperatorImpl::getBestMatch(const ImplSpec& requiredSpecs) ...@@ -161,6 +160,10 @@ Aidge::ImplSpec Aidge::OperatorImpl::getBestMatch(const ImplSpec& requiredSpecs)
Log::debug(" {}:{} - {}", (match) ? "MATCH" : "MISMATCH", priority, spec); Log::debug(" {}:{} - {}", (match) ? "MATCH" : "MISMATCH", priority, spec);
} }
if(matchingSpecs.empty()){
Log::debug(" No spec to match registered, returning requiredSpecs.");
return requiredSpecs;
}
// Return best match // Return best match
const auto bestMatch = std::max_element(matchingSpecs.begin(), matchingSpecs.end()); const auto bestMatch = std::max_element(matchingSpecs.begin(), matchingSpecs.end());
if (*bestMatch >= 0) { if (*bestMatch >= 0) {
...@@ -367,6 +370,6 @@ std::shared_ptr<Aidge::ProdConso> Aidge::OperatorImpl::getProdConso() const { ...@@ -367,6 +370,6 @@ std::shared_ptr<Aidge::ProdConso> Aidge::OperatorImpl::getProdConso() const {
return std::make_shared<ProdConso>(mOp); return std::make_shared<ProdConso>(mOp);
} }
std::set<Aidge::ImplSpec> Aidge::OperatorImpl::getAvailableImplSpecs() const { std::vector<Aidge::ImplSpec> Aidge::OperatorImpl::getAvailableImplSpecs() const {
return std::set<ImplSpec>(); return std::vector<ImplSpec>();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment