コード例 #1
0
ファイル: OutputStream.cpp プロジェクト: Stupeflix/osg
void OutputStream::writeObjectFields( const osg::Object* obj )
{
    std::string name = obj->libraryName();
    name += std::string("::") + obj->className();

    ObjectWrapper* wrapper = Registry::instance()->getObjectWrapperManager()->findWrapper( name );
    if ( !wrapper )
    {
        OSG_INFO << "OutputStream::writeObject(): Unsupported wrapper class "
                                << name << std::endl;
        return;
    }
    _fields.push_back( name );

    const StringList& associates = wrapper->getAssociates();
    for ( StringList::const_iterator itr=associates.begin(); itr!=associates.end(); ++itr )
    {
        const std::string& assocName = *itr;
        ObjectWrapper* assocWrapper = Registry::instance()->getObjectWrapperManager()->findWrapper(assocName);
        if ( !assocWrapper )
        {
            OSG_INFO << "OutputStream::writeObject(): Unsupported associated class "
                                    << assocName << std::endl;
            continue;
        }
        else if ( _useSchemaData )
        {
            if ( _inbuiltSchemaMap.find(assocName)==_inbuiltSchemaMap.end() )
            {
                StringList properties;
                std::vector<int> types;
                assocWrapper->writeSchema( properties, types );

                unsigned int size = osg::minimum( properties.size(), types.size() );
                if ( size>0 )
                {
                    std::stringstream propertiesStream;
                    for ( unsigned int i=0; i<size; ++i )
                    {
                        propertiesStream << properties[i] << ":" << types[i] << " ";
                    }
                    _inbuiltSchemaMap[assocName] = propertiesStream.str();
                }
            }
        }
        _fields.push_back( assocWrapper->getName() );

        assocWrapper->write( *this, *obj );
        if ( getException() ) return;

        _fields.pop_back();
    }
    _fields.pop_back();

}
コード例 #2
0
ファイル: OutputStream.cpp プロジェクト: nsmoooose/osg
void OutputStream::writeObjectFields( const osg::Object* obj )
{
    std::string name = obj->libraryName();
    name += std::string("::") + obj->className();

    ObjectWrapper* wrapper = Registry::instance()->getObjectWrapperManager()->findWrapper( name );
    if ( !wrapper )
    {
        OSG_WARN << "OutputStream::writeObject(): Unsupported wrapper class "
                                << name << std::endl;
        return;
    }
    _fields.push_back( name );

    const StringList& associates = wrapper->getAssociates();
    for ( StringList::const_iterator itr=associates.begin(); itr!=associates.end(); ++itr )
    {
        const std::string& assocName = *itr;
        ObjectWrapper* assocWrapper = Registry::instance()->getObjectWrapperManager()->findWrapper(assocName);
        if ( !assocWrapper )
        {
            OSG_WARN << "OutputStream::writeObject(): Unsupported associated class "
                                    << assocName << std::endl;
            continue;
        }
        else if ( _useSchemaData )
        {
            if ( _inbuiltSchemaMap.find(assocName)==_inbuiltSchemaMap.end() )
            {
                StringList properties;
                assocWrapper->writeSchema( properties );
                if ( properties.size()>0 )
                {
                    std::string propertiesString;
                    for ( StringList::iterator sitr=properties.begin(); sitr!=properties.end(); ++sitr )
                    {
                        propertiesString += *sitr;
                        propertiesString += ' ';
                    }
                    _inbuiltSchemaMap[assocName] = propertiesString;
                }
            }
        }
        _fields.push_back( assocWrapper->getName() );

        assocWrapper->write( *this, *obj );
        if ( getException() ) return;

        _fields.pop_back();
    }
    _fields.pop_back();

}
コード例 #3
0
ファイル: OutputStream.cpp プロジェクト: nsmoooose/osg
void OutputStream::writeSchema( std::ostream& fout )
{
    // Write to external ascii stream
    const ObjectWrapperManager::WrapperMap& wrappers = Registry::instance()->getObjectWrapperManager()->getWrapperMap();
    for ( ObjectWrapperManager::WrapperMap::const_iterator itr=wrappers.begin();
          itr!=wrappers.end(); ++itr )
    {
        ObjectWrapper* wrapper = itr->second.get();
        fout << itr->first << " =";
        
        StringList properties;
        wrapper->writeSchema( properties );
        if ( properties.size()>0 )
        {
            for ( StringList::iterator sitr=properties.begin(); sitr!=properties.end(); ++sitr )
            {
                fout << ' ' << *sitr;
            }
        }
        fout << std::endl;
    }
}
コード例 #4
0
ファイル: OutputStream.cpp プロジェクト: Stupeflix/osg
void OutputStream::writeSchema( std::ostream& fout )
{
    // Write to external ascii stream
    const ObjectWrapperManager::WrapperMap& wrappers = Registry::instance()->getObjectWrapperManager()->getWrapperMap();
    for ( ObjectWrapperManager::WrapperMap::const_iterator itr=wrappers.begin();
          itr!=wrappers.end(); ++itr )
    {
        ObjectWrapper* wrapper = itr->second.get();
        fout << itr->first << " =";

        StringList properties;
        std::vector<int> types;
        wrapper->writeSchema( properties, types );

        std::string propertiesString;
        unsigned int size = osg::minimum( properties.size(), types.size() );
        for ( unsigned int i=0; i<size; ++i )
        {
            fout << " " << properties[i] << ":" << types[i];
        }
        fout << std::endl;
    }
}