Skip to content
Snippets Groups Projects
Commit 42f1b691 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

correctly handle algorithm template parameters in list overloads

parent 2b529232
No related branches found
No related tags found
No related merge requests found
Pipeline #27404 passed
......@@ -29,7 +29,7 @@ void AlgorithmRegistry::registerInternal ( std::string algorithm, ext::vector <
group.push_back ( ext::make_tuple ( category, std::move ( params ), entryValue ) );
}
 
std::shared_ptr < abstraction::OperationAbstraction > AlgorithmRegistry::getAbstraction ( const std::string & name, const ext::vector < std::string > & templateParams, const ext::vector < std::string > & paramTypes, AlgorithmCategories::AlgorithmCategory ) {
ext::map < ext::pair < std::string, ext::vector < std::string > >, ext::vector < ext::tuple < AlgorithmCategories::AlgorithmCategory, ext::vector < ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier >, std::string > >, ext::pair < ext::pair < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > >, std::shared_ptr < AlgorithmRegistry::Entry > > > > >::const_iterator AlgorithmRegistry::findAbstractionGroup ( const std::string & name, const ext::vector < std::string > & templateParams ) {
auto group = getEntries ( ).find ( ext::make_pair ( name, templateParams ) );
if ( group == getEntries ( ).end ( ) ) {
for ( auto iter = getEntries ( ).begin ( ); iter != getEntries ( ).end ( ); ++ iter ) {
......@@ -49,6 +49,11 @@ std::shared_ptr < abstraction::OperationAbstraction > AlgorithmRegistry::getAbst
else
throw std::invalid_argument ( "Templated entry " + name + " < " + ext::to_string ( templateParams ) + " > not available" );
}
return group;
}
std::shared_ptr < abstraction::OperationAbstraction > AlgorithmRegistry::getAbstraction ( const std::string & name, const ext::vector < std::string > & templateParams, const ext::vector < std::string > & paramTypes, AlgorithmCategories::AlgorithmCategory ) {
auto group = findAbstractionGroup ( name, templateParams );
 
auto incompatibleLambda = [ ] ( const ext::tuple < MatchType, std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > > & compatibility ) {
return std::get < 0 > ( compatibility ) == MatchType::INCOMPATIBLE;
......@@ -155,13 +160,7 @@ ext::set < ext::pair < std::string, ext::vector < std::string > > > AlgorithmReg
}
 
ext::set < ext::tuple < AlgorithmCategories::AlgorithmCategory, ext::pair < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > >, ext::vector < ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier >, std::string > > > > AlgorithmRegistry::listOverloads ( const std::string & algorithm, const ext::vector < std::string > & templateParams ) {
auto group = getEntries ( ).find ( ext::make_pair ( algorithm, templateParams ) );
if ( group == getEntries ( ).end ( ) ) {
if ( templateParams.size ( ) == 0 )
throw std::invalid_argument ( "Entry " + algorithm + " not available" );
else
throw std::invalid_argument ( "Templated entry " + algorithm + " < " + ext::to_string ( templateParams ) + " > not available" );
}
auto group = findAbstractionGroup ( algorithm, templateParams );
 
ext::set < ext::tuple < AlgorithmCategories::AlgorithmCategory, ext::pair < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > >, ext::vector < ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier >, std::string > > > > res;
for ( const ext::tuple < AlgorithmCategories::AlgorithmCategory, ext::vector < ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier >, std::string > >, ext::pair < ext::pair < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > >, std::shared_ptr < Entry > > > & overloads : group->second )
......
......@@ -115,6 +115,8 @@ class AlgorithmRegistry {
 
static void registerInternal ( std::string algorithm, ext::vector < std::string > templateParams, AlgorithmCategories::AlgorithmCategory category, ext::pair < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > > result, ext::vector < ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier >, std::string > > params, std::shared_ptr < Entry > value );
 
static ext::map < ext::pair < std::string, ext::vector < std::string > >, ext::vector < ext::tuple < AlgorithmCategories::AlgorithmCategory, ext::vector < ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier >, std::string > >, ext::pair < ext::pair < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > >, std::shared_ptr < Entry > > > > >::const_iterator findAbstractionGroup ( const std::string & algorithm, const ext::vector < std::string > & templateParams );
public:
template < class Algo, class ObjectType, class ReturnType, class ... ParamTypes >
static void registerMethod ( ReturnType ( ObjectType:: * callback ) ( ParamTypes ... ), std::string methodName, std::array < std::string, sizeof ... ( ParamTypes ) > paramNames ) {
......
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