/*! Writes the header for a field to the stream. \param[in] fieldName Name of the field. \param[in] fieldTypeName Type of the field. \param[in] fieldSize Size in bytes of the field. */ void OSBCommonElement::writeFieldHeader( const std::string &fieldName, const std::string &fieldTypeName, const UInt32 fieldSize ) { OSG_OSB_LOG(("OSBCommonElement::writeFieldHeader: " "[%s] [%s] [%u]\n", fieldName.c_str(), fieldTypeName.c_str(), fieldSize)); BinaryWriteHandler *wh = editRoot()->getWriteHandler(); wh->putValue(fieldName ); wh->putValue(fieldTypeName); wh->putValue(fieldSize ); }
void OSBChunkBlockElement::write(void) { OSG_OSB_LOG(("OSBChunkBlockElement::write\n")); if(getContainer() == NULL) { FWARNING(("OSBChunkBlockElement::write: Attempt to write NULL.\n")); return; } BinaryWriteHandler *wh = editRoot()->getWriteHandler(); wh->putValue(getFCPtrType(getContainer())); wh->putValue(getVersion() ); ChunkBlock *pCBlock = dynamic_cast<ChunkBlock *>(getContainer()); if(pCBlock != NULL) { _mfSlots.clear(); ChunkBlock::MFChunksType::const_iterator cIt = pCBlock->getMFChunks()->begin(); ChunkBlock::MFChunksType::const_iterator cEnd = pCBlock->getMFChunks()->end(); UInt32 cIdx = 0; for(; cIt != cEnd; ++cIt, ++cIdx) { if(*cIt != NULL) { UInt32 uiId = (*cIt)->getId(); Int32 iSlot = cIdx - (*cIt)->getClassId(); if(iSlot != -1) { uiId |= iSlot << 24; } _mfSlots.push_back(uiId); } } writeFieldHeader("chunks", "MFUnrecStateChunkPtr", _mfSlots.size() * sizeof(UInt32)); BinaryWriteHandler *wh = editRoot()->getWriteHandler(); _mfSlots.copyToBin(*wh); } writeFields("'chunks'", true); }
/*! Writes the containers collected with the previous call to preWrite to the stream set by initialiseWrite. First the file header is written, then for each element created during preWrite the write function is called. */ void OSBRootElement::write(void) { OSG_OSB_LOG(("OSBRootElement::write\n")); BinaryWriteHandler *wh = getWriteHandler(); wh->putValue(OSGOSB_HEADER_ID_2 ); // version wh->putValue(std::string("") ); // name wh->putValue(std::string("") ); // options wh->putValue(static_cast<UInt64>(0)); // size ElementListConstIt elemIt = getElementList().begin(); ElementListConstIt elemEnd = getElementList().end (); for(; elemIt != elemEnd; ++elemIt) { writeFieldContainerHeader((*elemIt)->getContainer()); (*elemIt)->write(); } }
void OSBGeometryElement::write(void) { OSG_OSB_LOG(("OSBGeometryElement::write\n")); BinaryWriteHandler *wh = editRoot()->getWriteHandler(); // wh->putValue(getFCPtrType(getContainer())); wh->putValue(getVersion()); writeFields("", true); }
/*! Writes the header for the given container \a fc to the stream. \param[in] fc Container to write the header for. */ void OSBCommonElement::writeFieldContainerHeader(FieldContainer * const fc) { OSG_OSB_LOG(("OSBCommonElement::writeFieldContainerHeader\n")); BinaryWriteHandler *wh = editRoot()->getWriteHandler(); const std::string &typeName = fc->getType().getName(); UInt32 fcId = fc->getId (); wh->putValue(typeName); wh->putValue(fcId ); }
void OSBNameElement::write(void) { OSG_OSB_LOG(("OSBNameElement::write\n")); if(getContainer() == NULL) { FWARNING(("OSBNameElement::write: Attempt to write NULL.\n")); return; } BinaryWriteHandler *wh = editRoot()->getWriteHandler(); wh->putValue(getFCPtrType(getContainer())); wh->putValue(getVersion() ); writeFields("", true); }