Jean-Yves Didier

Inclusion des types et serialisation.

......@@ -40,8 +40,7 @@ QString OSGStringSerializer::toString(osg::ref_ptr<osg::Object> target)
OSGStringSerializer::OSGStringSerializer() :
binaryInputStream(0),binaryOutputStream(0),
inputStream(0),outputStream(0)
binaryInputStream(0),binaryOutputStream(0)
{
bip = new BinaryInputIterator(&source);
bop = new BinaryOutputIterator(&source);
......
......@@ -34,8 +34,6 @@ private:
std::stringstream source;
osgDB::InputStream binaryInputStream;
osgDB::OutputStream binaryOutputStream;
osgDB::InputStream inputStream;
osgDB::OutputStream outputStream;
BinaryInputIterator* bip;
BinaryOutputIterator* bop;
osgDB::ReaderWriter* osgRW;
......
......@@ -16,6 +16,10 @@
#include <osg/Matrixf>
#include <osg/Matrixd>
#include <osg/ValueObject>
#include "osgstringserializer.h"
#include <typeinfo>
template<typename T> class OSGType : public ARCSTypeFactoryTemplate<T>
......@@ -37,9 +41,79 @@ template<typename T> QString OSGType<T>::getTypeName() const
template<typename T> T OSGType<T>::parse(QString s)
{
osg::ref_ptr<osg::Object> object =
OSGStringSerializer::getInstance()->parseString(s);
osg::TemplateValueObject<T>* value;
if ((value = dynamic_cast<osg::TemplateValueObject<T>* >(object.get())))
return value->getValue();
return T();
}
template<typename T> QString OSGType<T>::serialize(T obj)
{
osg::TemplateValueObject<T> value;
value.setValue(obj);
return OSGStringSerializer::getInstance()->toString(&value);
}
///////////////////////////////////////////////////////////////////////////
// Here are declarations of types
//////////////////////////////////////////////////////////////////////////
typedef osg::Vec2f osgVec2f;
Q_DECLARE_METATYPE(osgVec2f)
template class OSGType<osgVec2f>;
typedef OSGType<osgVec2f> ARCSTypeFactoryTemplate_osgVec2f;
typedef osg::Vec2d osgVec2d;
Q_DECLARE_METATYPE(osgVec2d)
template class OSGType<osgVec2d>;
typedef OSGType<osgVec2d> ARCSTypeFactoryTemplate_osgVec2d;
typedef osg::Vec3f osgVec3f;
Q_DECLARE_METATYPE(osgVec3f)
template class OSGType<osgVec3f>;
typedef OSGType<osgVec3f> ARCSTypeFactoryTemplate_osgVec3f;
typedef osg::Vec3d osgVec3d;
Q_DECLARE_METATYPE(osgVec3d)
template class OSGType<osgVec3d>;
typedef OSGType<osgVec3d> ARCSTypeFactoryTemplate_osgVec3d;
typedef osg::Vec4f osgVec4f;
Q_DECLARE_METATYPE(osgVec4f)
template class OSGType<osgVec4f>;
typedef OSGType<osgVec4f> ARCSTypeFactoryTemplate_osgVec4f;
typedef osg::Vec4d osgVec4d;
Q_DECLARE_METATYPE(osgVec4d)
template class OSGType<osgVec4d>;
typedef OSGType<osgVec4d> ARCSTypeFactoryTemplate_osgVec4d;
typedef osg::Quat osgQuat;
Q_DECLARE_METATYPE(osgQuat)
template class OSGType<osgQuat>;
typedef OSGType<osgQuat> ARCSTypeFactoryTemplate_osgQuat;
typedef osg::Plane osgPlane;
Q_DECLARE_METATYPE(osgPlane)
template class OSGType<osgPlane>;
typedef OSGType<osgPlane> ARCSTypeFactoryTemplate_osgPlane;
typedef osg::Matrixf osgMatrixf;
Q_DECLARE_METATYPE(osgMatrixf)
template class OSGType<osgMatrixf>;
typedef OSGType<osgMatrixf> ARCSTypeFactoryTemplate_osgMatrixf;
typedef osg::Matrixd osgMatrixd;
Q_DECLARE_METATYPE(osgMatrixd)
template class OSGType<osgMatrixd>;
typedef OSGType<osgMatrixd> ARCSTypeFactoryTemplate_osgMatrixd;
#endif // __OSGTYPES_H__
......