/*! Visits a map field (essentially an SF that contains a std::map
    with a FieldContainer* as value type) for
    preWrite. It creates elements for the pointed to containers and
    calls preWrite on them. If the pointed to containers are not in the
    root's id set they are added and thus scheduled for writing.

    \param[in] fieldId Id of the field in the container of this element.
 */
void OSBCommonElement::preWriteMapField(const UInt32 fieldId)
{
    OSG_OSB_LOG(("OSBCommonElement::preWriteMapField: "
                 "fieldId: [%u]\n", fieldId));

    GetMapFieldHandlePtr sfMapField =
        boost::dynamic_pointer_cast<GetMapFieldHandle>(
            getContainer()->getField(fieldId));

    if(sfMapField == NULL || sfMapField->isValid() == false)
        return;

    sfMapField->traverse(
        boost::bind(&OSBCommonElement::handleMapElementPreWrite,
                    this,
                    _1));
}
Ejemplo n.º 2
0
void OSGWriter::visitField(GetFieldHandlePtr hF)
{
    if(hF->isValid() == false)
    {
        return;
    }

//    const FieldType &fType       = hF->getType();

    GetMapFieldHandlePtr sfMap = 
        boost::dynamic_pointer_cast<
            GetMapFieldHandle>(hF);

    if(sfMap != NULL && sfMap->isValid() == true)
    {
        sfMap->traverse(boost::bind(&OSGWriter::visitContainer, this, _1));
    }
    else
    {
        FieldContainerPtrSFieldBase::GetHandlePtr sfFCPtr = 
            boost::dynamic_pointer_cast<
                FieldContainerPtrSFieldBase::GetHandle>(hF);

        FieldContainerPtrMFieldBase::GetHandlePtr mfFCPtr = 
            boost::dynamic_pointer_cast<
                FieldContainerPtrMFieldBase::GetHandle>(hF);

        if(sfFCPtr != NULL && sfFCPtr->isValid() == true)
        {
            visitContainer((*sfFCPtr)->getValue());
        }
        else if(mfFCPtr != NULL && mfFCPtr->isValid() == true)
        {
            SizeT mfSize = (*mfFCPtr)->size();

            for(SizeT i = 0; i < mfSize; i++)
            {
                visitContainer((**mfFCPtr)[i]);
            }
        }
    }
}