void EditSFieldHandle<SFAttachmentPtrMap>::cloneValues(
          GetFieldHandlePtr  pSrc,
    const TypePtrVector     &shareTypes,
    const TypePtrVector     &ignoreTypes,
    const TypeIdVector      &shareGroupIds,
    const TypeIdVector      &ignoreGroupIds) const
{
    SFAttachmentPtrMap::GetHandlePtr pGetHandle = 
        boost::dynamic_pointer_cast<
            SFAttachmentPtrMap::GetHandle>(pSrc);

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

    const SFAttachmentPtrMap &pAttMap = **pGetHandle;

    AttachmentMap::const_iterator mapIt  = pAttMap.getValue().begin();
    AttachmentMap::const_iterator mapEnd = pAttMap.getValue().end();

    for(; mapIt != mapEnd; ++mapIt)
    {
        AttachmentUnrecPtr att       = mapIt->second;
        UInt16             uiBinding = UInt16(mapIt->first &
                                              0x0000FFFF    );

        if(att != NULL)
        {
            const FieldContainerType &attType = att->getType();

            // test if att type should NOT be ignored
            if(!TypePredicates::typeInGroupIds (ignoreGroupIds.begin(),
                                                ignoreGroupIds.end(),
                                                attType                ) &&
               !TypePredicates::typeDerivedFrom(ignoreTypes.begin(),
                                                ignoreTypes.end(),
                                                attType                )   )
            {
                // test if att should cloned
                if(!TypePredicates::typeInGroupIds (shareGroupIds.begin(),
                                                    shareGroupIds.end(),
                                                    attType               ) &&
                   !TypePredicates::typeDerivedFrom(shareTypes.begin(),
                                                    shareTypes.end(),
                                                    attType               )   )
                {
                    att = dynamic_pointer_cast<Attachment>(
                        OSG::deepClone(att, shareTypes,    ignoreTypes,
                                            shareGroupIds, ignoreGroupIds));
                }
            }
        }

        if(_fAddMethod)
        {
            _fAddMethod(att, uiBinding);
        }
    }
}
Ejemplo n.º 2
0
void EditSFieldHandle<SFChunkBlockPtrMap>::add(
          FieldContainer *rhs,
    const std::string    &szBindings)
{
    ChunkBlock *pVal = dynamic_cast<ChunkBlock *>(rhs);
    KeyType     oKey = 0x0000;

    if(pVal == NULL)
    {
        MapHelper *pMHelper = dynamic_cast<MapHelper *>(rhs);
 
        if(pMHelper != NULL)
        {
            pVal = dynamic_cast<ChunkBlock *>(pMHelper->getContainer());

            const MapHelper::MFKeysType *pKeys = pMHelper->getMFKeys();
           
            if(pKeys->empty() == false)
            {
                KeyType tmpKey = KeyPool::the()->getDefault();

                for(UInt32 i = 0; i < pKeys->size(); ++i)
                {
                    const std::string &szKey = pMHelper->getKeys(i);

                    tmpKey = KeyPool::the()->getAuto(szKey.c_str());

                    oKey |= tmpKey;
                }
            }
        }
    }
    else
    {
        if(szBindings.empty() == false)
        {
            oKey = KeyPool::the()->getAuto(szBindings.c_str());
        }
    }

    if(rhs != NULL && pVal == NULL)
        return;


    // for whatever reason VS2003 does not like == NULL
    if(_fAddMethod)
    {
        _fAddMethod(pVal, oKey);
    }
}
void EditSFieldHandle<SFAttachmentPtrMap>::add(
          FieldContainer *rhs,
    const std::string    &szBindings)
{
    Attachment *pVal       = dynamic_cast<Attachment *>(rhs);
    UInt32      uiBindings = 0;

    if(pVal == NULL)
    {
        MapHelper *pMHelper = dynamic_cast<MapHelper *>(rhs);
 
        if(pMHelper != NULL)
        {
            pVal = dynamic_cast<Attachment *>(pMHelper->getContainer());

            if(pMHelper->getMFKeys()->empty() == false)
            {
                const std::string &szKey = pMHelper->getKeys(0);

                uiBindings = TypeTraits<UInt32>::getFromCString(szKey.c_str());
            }
        }
    }
    else
    {
        if(szBindings.empty() == false)
        {
            uiBindings = TypeTraits<UInt32>::getFromCString(szBindings.c_str());
        }
    }

    if(rhs != NULL && pVal == NULL)
        return;


    // for whatever reason VS2003 does not like == NULL
    if(_fAddMethod)
    {
        _fAddMethod(pVal, uiBindings);
    }
}