Beispiel #1
0
void OSGWriter::visitContainer(FieldContainer * const pFC)
{

    if(pFC == NULL)
    {
        return;
    }

    typedef std::pair<FCInfoHelperMap::iterator, bool> MapInsertInfo;

          std::string         containerName;
//    const FieldContainerType &fcType    = pFC->getType();
          UInt32              numFields = pFC->getNumFields();
          MapInsertInfo       insertInfo;

    insertInfo = _visitedFCMap.insert(std::make_pair(pFC, FCInfoHelper()));

    if(insertInfo.second == true)
    {
        //the FC was NOT visited before
        for(UInt32 field = 1; field <= numFields; field++)
        {
            GetFieldHandlePtr fHandle = pFC->getField(field);

            if(fHandle == NULL || (fHandle != NULL && fHandle->isInternal()))
            {
                continue;
            }

            visitField(fHandle);
        }
    }
    else
    {
        //the FC was in the map => FC is shared

        FCInfoHelperMap::iterator iter = _visitedFCMap.find(pFC);

        if(iter == _visitedFCMap.end())
        {
            SWARNING << "OSGWriter::visitContainer(): FieldContainer * "
                     << "not found in map" << std::endl;
            return;
        }
        if(iter->second.hasName == false)
        {
            iter->second.setName(pFC);
            iter->second.hasName = true;
        }
    }
}
Beispiel #2
0
void OSGWriter::writeContainer(FieldContainer * const pFC,
                               bool                   bIndent)
{
    if(pFC == NULL)
    {
        return;
    }

    UInt32 numFields = pFC->getNumFields();

    FCInfoHelperMap::iterator iter = _visitedFCMap.find(pFC);

    if(iter == _visitedFCMap.end())
    {
        SWARNING << "OSGWriter::writeContainer(): FieldContainer * "
                 << "not found in map" << std::endl;
        return;
    }

    if(!iter->second.written)
    {
        //FC is not written yet
        iter->second.written = true;

        if(bIndent == true)
        {
            _outStream << BeginElem;
        }

        if(iter->second.hasName)
        {
            _outStream << "DEF "
                       << iter->second.containerName 
                       << " "
                       << pFC->getTypeName()
                       << EndElemNL
                       << BeginElem
                       << "{"
                       << EndElemNL;
        }
        else
        {
            _outStream <<  pFC->getTypeName() 
                       << EndElemNL
                       << BeginElem
                       << "{"
                       << EndElemNL;
        }
        
        _outStream << IncIndent;

        for(UInt32 field = numFields; field > 0; field--)
        {
            GetFieldHandlePtr fHandle = pFC->getField(field);

            if(fHandle == NULL || (fHandle != NULL && fHandle->isInternal()))
            {
                continue;
            }

            writeField(fHandle);
        }

        _outStream << DecIndent;

        _outStream << BeginElem 
                   << "}" 
                   << EndElemNL;
    }
    else
    {
        //FC is already written -> its shared -> write reference
        if(!iter->second.hasName)
        {
            SWARNING << "OSGWriter::writeContainer(): FieldContainer is "
                     << "shared, but not named"
                     << std::endl;
            return;
        }
        
        if(bIndent == true)
        {
            _outStream << BeginElem;
        }

        _outStream << "USE "
                   << iter->second.containerName 
                   << EndElemNL;
    }

}