Ejemplo n.º 1
0
void AbstractRouter::validate(const RouteList& routeGroup) const
{
	for (auto i = 0; i < routeGroup.size(); i++) {
		for (auto j = i + 1; j < routeGroup.size(); j++) {
			auto a = routeGroup[i];
			auto b = routeGroup[j];
			if (ambiguous(a, b))
				throw Exception(format("Ambiguity between `%s` and `%s", a->toString(), b->toString()));
		}
	}
}
        PeerToFinderPeerLocationFindRequestPtr PeerToFinderPeerLocationFindRequest::create(ElementPtr root)
        {
          PeerToFinderPeerLocationFindRequestPtr ret(new message::PeerToFinderPeerLocationFindRequest);

          if (root)
          {
            ret->mID = IMessageHelper::getAttributeID(root);

            ElementPtr routes = root->findFirstChildElement("routes");
            if (routes)
            {
              RouteList routeLst;
              ElementPtr route = routes->findFirstChildElement("route");
              while (route)
              {
                String id = IMessageHelper::getAttributeID(route);
                routeLst.push_back(id);

                route = route->getNextSiblingElement();
              }

              if (routeLst.size() > 0)
                ret->mRoutes = routeLst;
            }

            ElementPtr exclude = root->findFirstChildElement("exclude");
            if (exclude)
            {
              ElementPtr locations = root->findFirstChildElement("locations");
              if (locations)
              {
                message::PeerToFinderPeerLocationFindRequest::ExcludedLocationList exclLst;
                ElementPtr loc = locations->findFirstChildElement("location");
                while (loc)
                {
                  String id = IMessageHelper::getAttributeID(loc);
                  exclLst.push_back(id);

                  loc = loc->getNextSiblingElement();
                }

                if (exclLst.size() > 0)
                  ret->mExcludedLocations = exclLst;
              }
            }

            ElementPtr location = root->findFirstChildElement("location");
            if (location)
            {
              ret->mLocation = MessageHelper::createLocation(location);
            }

          }

          return ret;
        }