58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
|
/**********************************************************************
|
||
|
*
|
||
|
* FILE: Uniform.cpp
|
||
|
*
|
||
|
* DESCRIPTION: Read/Write osg::Uniform in binary format to disk.
|
||
|
*
|
||
|
* CREATED BY: Auto generated by iveGenerated
|
||
|
* and later modified by Rune Schmidt Jensen.
|
||
|
*
|
||
|
* HISTORY: Created 20.3.2003
|
||
|
*
|
||
|
* Copyright 2003 VR-C
|
||
|
**********************************************************************/
|
||
|
|
||
|
#include "Exception.h"
|
||
|
#include "Uniform.h"
|
||
|
#include "Object.h"
|
||
|
|
||
|
using namespace ive;
|
||
|
|
||
|
void Uniform::write(DataOutputStream* out){
|
||
|
// Write Uniform's identification.
|
||
|
out->writeInt(IVEUNIFORM);
|
||
|
// If the osg class is inherited by any other class we should also write this to file.
|
||
|
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
||
|
if(obj)
|
||
|
{
|
||
|
((ive::Object*)(obj))->write(out);
|
||
|
}
|
||
|
else
|
||
|
throw Exception("Uniform::write(): Could not cast this osg::Uniform to an osg::Object.");
|
||
|
|
||
|
}
|
||
|
|
||
|
void Uniform::read(DataInputStream* in)
|
||
|
{
|
||
|
// Read Uniform's identification.
|
||
|
int id = in->peekInt();
|
||
|
if(id == IVEUNIFORM)
|
||
|
{
|
||
|
// Read Uniform's identification.
|
||
|
id = in->readInt();
|
||
|
// If the osg class is inherited by any other class we should also read this from file.
|
||
|
osg::Object* obj = dynamic_cast<osg::Object*>(this);
|
||
|
if(obj)
|
||
|
{
|
||
|
((ive::Object*)(obj))->read(in);
|
||
|
}
|
||
|
else
|
||
|
throw Exception("Uniform::read(): Could not cast this osg::Uniform to an osg::Object.");
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
throw Exception("Uniform::read(): Expected Uniform identification.");
|
||
|
}
|
||
|
}
|