void MemoryConsumption::scan(void) { FieldContainerFactory::the()->lockStore(); FieldContainerFactoryBase::ContainerStoreConstIt sIt = FieldContainerFactory::the()->beginStore(); FieldContainerFactoryBase::ContainerStoreConstIt sEnd = FieldContainerFactory::the()->endStore(); for(; sIt != sEnd; ++sIt) { FieldContainer *pFC = (*sIt).second->getPtr(); if(pFC == NULL) continue; TypeMemMapIt tmIt = _memMap.find(pFC->getType().getId()); SizeT binSize = pFC->getBinSize(TypeTraits<BitVector>::BitsSet); if(tmIt != _memMap.end()) { tmIt->second.first += binSize; tmIt->second.second += 1; } else { _memMap[pFC->getType().getId()] = MemCountPair(binSize, 1); } } FieldContainerFactory::the()->unlockStore(); }
/*! Writes all fields to the stream, except for those whose name is in \a excludeFields. Optionally writes an end marker. The excludeFields string has the format: "'name1' 'name2' 'name3'", the spaces between the "'" are mandatory. \param[in] excludeFields String of field names that shall be skipped. \param[in] endMarker Write an end marker to the stream after all fields are processed. */ void OSBCommonElement::writeFields( const std::string &excludeFields, const bool endMarker) { OSG_OSB_LOG(("OSBCommonElement::writeFields: " "excludeFields: [%s]\n", excludeFields.c_str())); FieldContainer *fc = getContainer(); UInt32 fieldCount = fc->getType().getNumFieldDescs(); // go through all fields and write them. for(UInt32 fieldId = 1; fieldId <= fieldCount; ++fieldId) { const FieldDescriptionBase *fieldDesc = fc->getFieldDescription(fieldId); const std::string &fieldName = fieldDesc->getName(); // skip internal fields if(fieldDesc->isInternal()) { OSG_OSB_LOG(("OSBCommonElement::writeFields: " "Skipping internal field: [%s]\n", fieldName.c_str())); continue; } // skip excluded fields if((!excludeFields.empty() ) && (excludeFields.find("'" + fieldName + "'") != std::string::npos) ) { OSG_OSB_LOG(("OSBCommonElement::writeFields: " "Skipping excluded field: [%s]\n", fieldName.c_str())); continue; } const FieldType &fieldType = fieldDesc->getFieldType(); const std::string &fieldTypeName = fieldType .getName (); BitVector fieldMask = fieldDesc->getFieldMask(); UInt32 fieldSize = UInt32(fc->getBinSize(fieldMask)); writeFieldHeader (fieldName, fieldTypeName, fieldSize); writeFieldContent(fieldId ); } if(endMarker) { writeEndMarker(); } }