예제 #1
0
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
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
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
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;
    }
}