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++; }
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 ; }