root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osg/Object.cpp @ 13041

Revision 13041, 1.4 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1#include <osg/Object>
2#include <osg/UserDataContainer>
3#include <osgDB/ObjectWrapper>
4#include <osgDB/InputStream>
5#include <osgDB/OutputStream>
6#include <osg/Notify>
7#include <string.h>
8
9static bool checkUserData( const osg::Object& obj )
10{
11    return (obj.getUserData() && dynamic_cast<const osg::Object*>(obj.getUserData()));
12}
13
14static bool readUserData( osgDB::InputStream& is, osg::Object& obj )
15{
16    is >> osgDB::BEGIN_BRACKET;
17    osg::Object* object = is.readObject();
18    if(object) obj.setUserData(object);
19    is >> osgDB::END_BRACKET;
20    return true;
21}
22
23static bool writeUserData( osgDB::OutputStream& os, const osg::Object& obj )
24{
25    os << osgDB::BEGIN_BRACKET << std::endl;
26    os.writeObject(dynamic_cast<const osg::Object*>(obj.getUserData()));
27    os << osgDB::END_BRACKET << std::endl;
28    return true;
29}
30
31REGISTER_OBJECT_WRAPPER( Object,
32                         /*new osg::Object*/NULL,
33                         osg::Object,
34                         "osg::Object" )
35{
36    ADD_STRING_SERIALIZER( Name, "" );  // _name
37
38    BEGIN_ENUM_SERIALIZER( DataVariance, UNSPECIFIED );
39        ADD_ENUM_VALUE( STATIC );
40        ADD_ENUM_VALUE( DYNAMIC );
41        ADD_ENUM_VALUE( UNSPECIFIED );
42    END_ENUM_SERIALIZER();  // _dataVariance
43
44    ADD_USER_SERIALIZER( UserData );  // _userData, deprecated
45
46    UPDATE_TO_VERSION( 77 )
47    {
48        REMOVE_SERIALIZER( UserData );
49        ADD_OBJECT_SERIALIZER( UserDataContainer, osg::UserDataContainer, NULL );
50    }
51}
Note: See TracBrowser for help on using the browser.