Moved the set/getName() support from osg::Node etc into the osg::Obejct

base class
This commit is contained in:
Robert Osfield
2005-06-08 13:16:19 +00:00
parent 69cd27e37f
commit 27c4c6a956
19 changed files with 135 additions and 122 deletions

View File

@@ -17,31 +17,46 @@
using namespace ive;
void Object::write(DataOutputStream* out){
// Write Object's identification.
out->writeInt(IVEOBJECT);
void Object::write(DataOutputStream* out)
{
// Write Object's identification.
out->writeInt(IVEOBJECT);
// Write Object's properties.
switch(getDataVariance()){
if ( out->getVersion() >= VERSION_0012 )
{
// Write Name
out->writeString(getName());
}
// Write Object's properties.
switch(getDataVariance())
{
case(osg::Object::STATIC): out->writeChar((char)0); break;
case(osg::Object::DYNAMIC): out->writeChar((char)1); break;
case(osg::Object::DYNAMIC): out->writeChar((char)1); break;
}
}
void Object::read(DataInputStream* in){
// Read Object's identification.
int id = in->peekInt();
if(id == IVEOBJECT){
// Code to read Object's properties.
id = in->readInt();
// Read Object's identification.
int id = in->peekInt();
if(id == IVEOBJECT)
{
// Code to read Object's properties.
id = in->readInt();
char c = in->readChar();
switch((int)c){
case 0: setDataVariance(osg::Object::STATIC);break;
case 1: setDataVariance(osg::Object::DYNAMIC);break;
}
}
else{
throw Exception("Object::read(): Expected Object identification");
if ( in->getVersion() >= VERSION_0012 )
{
// Read name
setName(in->readString());
}
char c = in->readChar();
switch((int)c){
case 0: setDataVariance(osg::Object::STATIC);break;
case 1: setDataVariance(osg::Object::DYNAMIC);break;
}
}
else{
throw Exception("Object::read(): Expected Object identification");
}
}