+ bool first_route = true;
+
+ std::map<std::string,bool> targets_dedup;
+ for (; db_it != databases.end(); db_it++)
+ {
+ std::list<VirtualDB::Map>::const_iterator map_it;
+ map_it = m_p->m_maps.begin();
+ while (map_it != m_p->m_maps.end())
+ {
+ if (map_it->match(*db_it))
+ break;
+ map_it++;
+ }
+
+ if (map_it == m_p->m_maps.end()) // database not found
+ {
+ error_code = YAZ_BIB1_DATABASE_DOES_NOT_EXIST;
+ addinfo = *db_it;
+ BackendPtr ptr;
+ return ptr;
+ }
+ std::list<std::string>::const_iterator t_it =
+ map_it->m_targets.begin();
+ for (; t_it != map_it->m_targets.end(); t_it++) {
+ if (!targets_dedup[*t_it])
+ {
+ targets_dedup[*t_it] = true;
+ b->m_targets.push_back(*t_it);
+ }
+ }
+
+ // see if we have a route conflict.
+ if (!first_route && b->m_route != map_it->m_route)
+ {
+ // we have a conflict.. routing must be same for all
+ error_code = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
+ BackendPtr ptr;
+ return ptr;
+ }
+ b->m_route = map_it->m_route;
+ first_route = false;
+ }