Exemple #1
0
void GenericMap::garbageMarkVectors()
{
	unsigned int maxId=0;

	for (unsigned int orbit=0; orbit<NB_ORBITS;++orbit)
	{
		std::vector<AttributeMultiVector<MarkerBool>*>& amvv = m_attribs[orbit].getMarkerAttributes();

		for (auto it = amvv.begin(); it != amvv.end(); ++it )
		{
			AttributeMultiVector<MarkerBool>* amv = *it;
			const std::string& name = amv->getName();
			if (name.substr(0,7) == "marker_")
			{
				// store tne next free index for unique numbering
				std::string num = name.substr(name.length()-3,3);
				unsigned int id = 100*(num[0]-'0')+10*(num[1]-'0')+(num[2]-'0');
				if (id > maxId)
					maxId = id;

				amv->allFalse();
				m_markVectors_free[orbit][0].push_back(amv);
			}
		}
	}
	m_nextMarkerId = maxId+1;
}
void AttributeContainer::addAttribute(const std::string& attribName, const std::string& nametype, unsigned int index)
{
	// first check if attribute already exist
	if (attribName != "")
	{
		unsigned int i = getAttributeIndex(attribName) ;
		if (i != UNKNOWN)
			return ;
	}

	// create the new attribute
	AttributeMultiVector<T>* amv = new AttributeMultiVector<T>(attribName, nametype);

	m_tableAttribs[index] = amv;
	amv->setOrbit(m_orbit) ;
	amv->setIndex(index) ;

	// generate a name for the attribute if no one was given
	if (attribName == "")
	{
		std::stringstream ss;
		ss << "unknown" << m_nbUnknown++;
		amv->setName(ss.str());
	}

	// update the memory cost of a line
	m_lineCost += sizeof(T) ;

	// resize the new attribute so that it has the same size than others
	amv->setNbBlocks(uint32(m_holesBlocks.size())) ;

	m_nbAttributes++;
}
unsigned int AttributeContainer::getAttributeBlocksPointers(unsigned int attrIndex, std::vector<T*>& vect_ptr, unsigned int& byteBlockSize) const
{
	assert(attrIndex < m_tableAttribs.size() || !"getAttributeBlocksPointers: attribute index out of bounds");
	assert(m_tableAttribs[attrIndex] != NULL || !"getAttributeBlocksPointers: attribute does not exist");

	AttributeMultiVector<T>* atm = dynamic_cast<AttributeMultiVector<T>*>(m_tableAttribs[attrIndex]);
	assert((atm != NULL) || !"getAttributeBlocksPointers: wrong type");
	return atm->getBlocksPointers(reinterpret_cast<std::vector<void*>&>(vect_ptr), byteBlockSize);
}
AttributeMultiVector<T>* AttributeContainer::addAttribute(const std::string& attribName)
{
	// first check if attribute already exist
	unsigned int index ;
	if (attribName != "")
	{
		index = getAttributeIndex(attribName) ;
		if (index != UNKNOWN)
		{
			std::cout << "attribute " << attribName << " already found.." << std::endl ;
			return NULL ;
		}
	}

	// create the new attribute
	std::string typeName = nameOfType(T()) ;
	AttributeMultiVector<T>* amv = new AttributeMultiVector<T>(attribName, typeName) ;

	if(!m_freeIndices.empty())
	{
		index = m_freeIndices.back() ;
		m_freeIndices.pop_back() ;
		m_tableAttribs[index] = amv ;
	}
	else
	{
		index = uint32(m_tableAttribs.size()) ;
		m_tableAttribs.push_back(amv) ;
	}

	amv->setOrbit(m_orbit) ;
	amv->setIndex(index) ;

	// generate a name for the attribute if no one was given
	if (attribName == "")
	{
		std::stringstream ss ;
		ss << "unknown" << m_nbUnknown++ ;
		amv->setName(ss.str()) ;
	}

	// update the memory cost of a line
	m_lineCost += sizeof(T) ;

	// resize the new attribute so that it has the same size than others
	amv->setNbBlocks(uint32(m_holesBlocks.size())) ;

	m_nbAttributes++ ;

	return amv ;
}
Exemple #5
0
void GenericMap::garbageMarkVectors()
{
	unsigned int maxId=0;

	for (unsigned int orbit=0; orbit<NB_ORBITS;++orbit)
	{
		std::vector<std::string> attNames;
		m_attribs[orbit].getAttributesNames(attNames);
		for (auto sit=attNames.begin(); sit!=attNames.end();++sit)
		{
			if (sit->substr(0,7) == "marker_")
			{
				std::string num = sit->substr(sit->length()-3,3);
				unsigned int id = 100*(num[0]-'0')+10*(num[1]-'0')+(num[2]-'0');
				if (id > maxId)
					maxId = id;
				AttributeMultiVector<MarkerBool>* amv = m_attribs[orbit].getDataVector<MarkerBool>(*sit);
				amv->allFalse();
				m_markVectors_free[orbit][0].push_back(amv);
			}
		}
	}
	m_nextMarkerId = maxId+1;
}