root/OpenSceneGraph/trunk/src/osgPlugins/ive/Object.cpp @ 13041

Revision 13041, 2.2 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/**********************************************************************
2 *
3 *  FILE:           Object.cpp
4 *
5 *  DESCRIPTION:    Read/Write osg::Object in binary format to disk.
6 *
7 *  CREATED BY:     Auto generated by iveGenerated
8 *                  and later modified by Rune Schmidt Jensen.
9 *
10 *  HISTORY:        Created 17.3.2003
11 *
12 *    Copyright 2003 VR-C
13 **********************************************************************/
14
15#include "Exception.h"
16#include "Object.h"
17
18using namespace ive;
19
20void Object::write(DataOutputStream* out)
21{
22    // Write Object's identification.
23    out->writeInt(IVEOBJECT);
24
25    if ( out->getVersion() >= VERSION_0012 )
26    {
27        // Write Name
28        out->writeString(getName());
29    }
30
31    // Write Object's properties.
32    switch(getDataVariance())
33    {
34        case(osg::Object::STATIC): out->writeChar((char)0); break;
35        case(osg::Object::DYNAMIC): out->writeChar((char)1); break;
36        case(osg::Object::UNSPECIFIED): out->writeChar((char)2); break;
37    }
38
39    if ( out->getVersion() >= VERSION_0031)
40    {
41        const osg::Object* object = dynamic_cast<const osg::Object*>(getUserData());
42        if (object)
43        {
44            out->writeBool(true);
45            out->writeObject(object);
46        }
47        else
48        {
49            out->writeBool(false);
50        }
51    }
52}
53
54void Object::read(DataInputStream* in){
55    // Read Object's identification.
56    int id = in->peekInt();
57    if(id == IVEOBJECT)
58    {
59        // Code to read Object's properties.
60        id = in->readInt();
61
62        if ( in->getVersion() >= VERSION_0012 )
63        {
64            // Read name
65            setName(in->readString());
66        }
67
68        char c = in->readChar();
69        switch((int)c)
70        {
71            case 0: setDataVariance(osg::Object::STATIC);break;
72            case 1: setDataVariance(osg::Object::DYNAMIC);break;
73            case 2: setDataVariance(osg::Object::UNSPECIFIED);break;
74        }
75
76        if ( in->getVersion() >= VERSION_0031)
77        {
78            bool hasUserData = in->readBool();
79            if (hasUserData)
80            {
81                setUserData(in->readObject());
82            }
83        }
84
85    }
86    else{
87        in_THROW_EXCEPTION("Object::read(): Expected Object identification");
88    }
89}
Note: See TracBrowser for help on using the browser.