Beispiel #1
0
void NetworkManager::cleanUpLinks(Links & links, Assignment * assignment)
{
    for ( Links::iterator l = links.begin(); l != links.end(); l++ )
    {
        NetPath path = assignment->GetAssignment(*l);
        if ( !path.empty() )
            removeAssignment(*l, path);

        assignment->RemoveAssignment(*l);
    }
}
Beispiel #2
0
	void Print(std::ostream& stream, Objects::const_iterator object, bool last = false)
	{
		for(size_t i = 0; i < levels.size(); ++i)
			if(i == levels.size() - 1)
				stream << "|_";
			else if(levels[i])
				stream << "| ";
			else
				stream << "  ";

		bool cyclicReference = std::find(levelObjects.begin(), levelObjects.end(), object) != levelObjects.end();
		if(cyclicReference)
			stream << "CYCLIC ";

		stream << object->data << ", " << object->info << "\n";

		if(cyclicReference)
			return;

		if(last)
			levels[levels.size() - 1] = false;

		levelObjects.push_back(object);

		Links::const_iterator link = links.lower_bound(object);
		Links::const_iterator endLink = links.upper_bound(object);
		if(link != endLink)
		{
			levels.push_back(true);
			Links::const_iterator nextLink;
			for(; link != links.end() && link->first == object; link = nextLink)
			{
				nextLink = link;
				++nextLink;
				Print(stream, link->second, nextLink == links.end() || nextLink->first != object);
			}
			levels.pop_back();
		}

		levelObjects.pop_back();
	}
Beispiel #3
0
	void Print(std::ostream& stream)
	{
		std::vector<Objects::const_iterator> referencedObjects;
		referencedObjects.reserve(links.size());
		for(Links::const_iterator i = links.begin(); i != links.end(); ++i)
			referencedObjects.push_back(i->second);
		std::sort(referencedObjects.begin(), referencedObjects.end());
		referencedObjects.resize(std::unique(referencedObjects.begin(), referencedObjects.end()) - referencedObjects.begin());

		// пока просто вывести
		for(Objects::const_iterator object = objects.begin(); object != objects.end(); ++object)
		{
			if(std::binary_search(referencedObjects.begin(), referencedObjects.end(), object))
				continue;
			Print(stream, object);
		}
	}
/** Gets the results of the trace, then returns the first detector
 * (that is NOT a monitor) found in the results.
 * @return sptr to IDetector, or an invalid sptr if not found
 */
IDetector_const_sptr InstrumentRayTracer::getDetectorResult() const {
  Links results = this->getResults();

  // Go through all results
  Links::const_iterator resultItr = results.begin();
  for (; resultItr != results.end(); ++resultItr) {
    IComponent_const_sptr component =
        m_instrument->getComponentByID(resultItr->componentID);
    IDetector_const_sptr det =
        boost::dynamic_pointer_cast<const IDetector>(component);
    if (det) {
      if (!det->isMonitor()) {
        return det;
      }
    } // (is a detector)
  }   // each ray tracer result
  return IDetector_const_sptr();
}