|
Revision 13041, 2.2 kB
(checked in by robert, 15 months 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 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | #include "Exception.h" |
|---|
| 16 | #include "Object.h" |
|---|
| 17 | |
|---|
| 18 | using namespace ive; |
|---|
| 19 | |
|---|
| 20 | void Object::write(DataOutputStream* out) |
|---|
| 21 | { |
|---|
| 22 | |
|---|
| 23 | out->writeInt(IVEOBJECT); |
|---|
| 24 | |
|---|
| 25 | if ( out->getVersion() >= VERSION_0012 ) |
|---|
| 26 | { |
|---|
| 27 | |
|---|
| 28 | out->writeString(getName()); |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 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 | |
|---|
| 54 | void Object::read(DataInputStream* in){ |
|---|
| 55 | |
|---|
| 56 | int id = in->peekInt(); |
|---|
| 57 | if(id == IVEOBJECT) |
|---|
| 58 | { |
|---|
| 59 | |
|---|
| 60 | id = in->readInt(); |
|---|
| 61 | |
|---|
| 62 | if ( in->getVersion() >= VERSION_0012 ) |
|---|
| 63 | { |
|---|
| 64 | |
|---|
| 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 | } |
|---|