Example #1
0
void TagComparator::_promoteToCommonAncestor(Tags& t1, Tags& t2, Tags& result)
{
  OsmSchema& schema = OsmSchema::getInstance();

  // we're deleting as we iterate so be careful making changes.
  for (Tags::iterator it1 = t1.begin(); it1 != t1.end(); )
  {
    for (Tags::iterator it2 = t2.begin(); it2 != t2.end(); )
    {
      const SchemaVertex& ancestor = schema.getFirstCommonAncestor(it1.key() + "=" + it1.value(),
        it2.key() + "=" + it2.value());
      if (ancestor.isEmpty() == false)
      {
        // erase from the iterators in a safe way
        t1.erase(it1++);
        t2.erase(it2++);
        if (ancestor.value.isEmpty() == false)
        {
          result[ancestor.key] = ancestor.value;
        }
      }
      else
      {
        // if we didn't erase anything then increment the iterators.
        ++it2;
      }
    }
    if (it1 != t1.end())
    {
      ++it1;
    }
  }
}
Example #2
0
void TagComparator::_addNonConflictingTags(Tags& t1, const Tags& t2, Tags& result)
{
  OsmSchema& schema = OsmSchema::getInstance();

  // we're deleting as we iterate so be careful making changes.
  for (Tags::iterator it1 = t1.begin(); it1 != t1.end(); )
  {
    QString kvp1 = it1.key() + "=" + it1.value();
    bool conflict = false;
    for (Tags::const_iterator it2 = t2.begin(); it2 != t2.end(); ++it2)
    {
      QString kvp2 = it2.key() + "=" + it2.value();
      if (schema.score(kvp1, kvp2) > 0.0)
      {
        conflict = true;
        break;
      }
    }

    if (conflict)
    {
      ++it1;
    }
    else
    {
      result[it1.key()] = it1.value();
      t1.erase(it1++);
    }
  }
}
Example #3
0
void LogManager::SetDisplayFlags(const std::string& tag, unsigned char flag)
{
	m_CritSection.Lock();
	if (flag != 0)
	{
		Tags::iterator findIt = m_Tags.find(tag);
		if (findIt == m_Tags.end())
			m_Tags.insert(std::make_pair(tag, flag));
		else
			findIt->second = flag;
	}
	else
		m_Tags.erase(tag);
	m_CritSection.Unlock();
}
Example #4
0
	void LogMgr::setDisplayFLags(const std::string& tag, unsigned char flags)
	{
		m_TagCriticalSection.lock();
		if (flags != 0)
		{
			Tags::iterator findIt = m_Tags.find(tag);
			if (findIt == m_Tags.end())
				m_Tags.insert(std::make_pair(tag, flags));
			else
				findIt->second = flags;
		}
		else
		{
			m_Tags.erase(tag);
		}
		m_TagCriticalSection.unlock();
	}
Example #5
0
///////////////////////////////////////////////////////////////////////////////////////
// sets one or more display flags
///////////////////////////////////////////////////////////////////////////////////////
void LogMgr::SetDisplayFlags(const std::string& tag, unsigned char flags)
{
  _tag_critical_section.Lock();
  if(flags != 0)
  {
    Tags::iterator it = _tags.find(tag);
    if(it == _tags.end())
      _tags.insert(std::make_pair(tag, flags));
    else
      it->second = flags;
  }
  else
  {
    _tags.erase(tag);
  }
  _tag_critical_section.Unlock();
}