2010-01-21 04:13:33 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
|
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
// Written by Wang Rui, (C) 2010
|
|
|
|
|
2010-01-25 19:03:21 +08:00
|
|
|
#ifndef OSGDB__SERIALIZER
|
|
|
|
#define OSGDB__SERIALIZER
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/Notify>
|
|
|
|
#include <osg/Object>
|
|
|
|
#include <osgDB/InputStream>
|
|
|
|
#include <osgDB/OutputStream>
|
2010-11-09 21:23:43 +08:00
|
|
|
|
2010-01-21 04:13:33 +08:00
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
2010-11-09 21:23:43 +08:00
|
|
|
#include <limits.h>
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
namespace osgDB
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef OBJECT_CAST
|
|
|
|
#define OBJECT_CAST static_cast
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class IntLookup
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef int Value;
|
|
|
|
typedef std::map<std::string, Value> StringToValue;
|
|
|
|
typedef std::map<Value, std::string> ValueToString;
|
|
|
|
|
|
|
|
IntLookup() {}
|
|
|
|
unsigned int size() const { return _stringToValue.size(); }
|
|
|
|
|
|
|
|
void add( const char* str, Value value )
|
|
|
|
{
|
|
|
|
if ( _valueToString.find(value)!=_valueToString.end() )
|
|
|
|
{
|
|
|
|
osg::notify(osg::WARN) << "Duplicate enum value " << value
|
|
|
|
<< " with old string: " << _valueToString[value]
|
|
|
|
<< " and new string: " << str << std::endl;
|
|
|
|
}
|
|
|
|
_valueToString[value] = str;
|
|
|
|
_stringToValue[str] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
Value getValue( const char* str )
|
|
|
|
{
|
|
|
|
StringToValue::iterator itr = _stringToValue.find(str);
|
|
|
|
if ( itr==_stringToValue.end() )
|
|
|
|
{
|
|
|
|
Value value;
|
|
|
|
std::stringstream stream;
|
|
|
|
stream << str; stream >> value;
|
|
|
|
_stringToValue[str] = value;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
return itr->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& getString( Value value )
|
|
|
|
{
|
|
|
|
ValueToString::iterator itr = _valueToString.find(value);
|
|
|
|
if ( itr==_valueToString.end() )
|
|
|
|
{
|
|
|
|
std::string str;
|
|
|
|
std::stringstream stream;
|
|
|
|
stream << value; stream >> str;
|
|
|
|
_valueToString[value] = str;
|
|
|
|
return _valueToString[value];
|
|
|
|
}
|
|
|
|
return itr->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
StringToValue _stringToValue;
|
|
|
|
ValueToString _valueToString;
|
|
|
|
};
|
|
|
|
|
|
|
|
class UserLookupTableProxy
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef void (*AddValueFunc)( IntLookup* lookup );
|
|
|
|
UserLookupTableProxy( AddValueFunc func ) { if ( func ) (*func)(&_lookup); }
|
|
|
|
|
|
|
|
IntLookup _lookup;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define BEGIN_USER_TABLE(NAME, CLASS) \
|
|
|
|
static void add_user_value_func_##NAME(osgDB::IntLookup*); \
|
|
|
|
static osgDB::UserLookupTableProxy s_user_lookup_table_##NAME(&add_user_value_func_##NAME); \
|
|
|
|
static void add_user_value_func_##NAME(osgDB::IntLookup* lookup) { typedef CLASS MyClass
|
|
|
|
#define ADD_USER_VALUE(VALUE) lookup->add(#VALUE, MyClass::VALUE)
|
|
|
|
#define END_USER_TABLE() }
|
|
|
|
|
|
|
|
#define USER_READ_FUNC(NAME, FUNCNAME) \
|
|
|
|
static int FUNCNAME(osgDB::InputStream& is) { \
|
|
|
|
int value; if (is.isBinary()) is >> value; \
|
|
|
|
else { std::string str; is >> str; \
|
|
|
|
value = (s_user_lookup_table_##NAME)._lookup.getValue(str.c_str()); } \
|
|
|
|
return value; }
|
|
|
|
|
|
|
|
#define USER_WRITE_FUNC(NAME, FUNCNAME) \
|
|
|
|
static void FUNCNAME(osgDB::OutputStream& os, int value) { \
|
|
|
|
if (os.isBinary()) os << value; \
|
|
|
|
else os << (s_user_lookup_table_##NAME)._lookup.getString(value); } \
|
|
|
|
|
|
|
|
class BaseSerializer : public osg::Referenced
|
|
|
|
{
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
friend class ObjectWrapper;
|
2010-01-21 04:13:33 +08:00
|
|
|
public:
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
RW_UNDEFINED = 0, RW_USER, RW_OBJECT, RW_IMAGE, RW_LIST,
|
|
|
|
RW_BOOL, RW_SHORT, RW_USHORT, RW_INT, RW_UINT, RW_FLOAT, RW_DOUBLE,
|
|
|
|
RW_VEC2F, RW_VEC2D, RW_VEC3F, RW_VEC3D, RW_VEC4F, RW_VEC4D, RW_QUAT, RW_PLANE,
|
|
|
|
RW_MATRIXF, RW_MATRIXD, RW_MATRIX, RW_GLENUM, RW_STRING, RW_ENUM
|
|
|
|
};
|
|
|
|
|
2010-11-09 21:23:43 +08:00
|
|
|
BaseSerializer() : _firstVersion(0), _lastVersion(INT_MAX) {}
|
|
|
|
|
2010-01-21 04:13:33 +08:00
|
|
|
virtual bool read( InputStream&, osg::Object& ) = 0;
|
|
|
|
virtual bool write( OutputStream&, const osg::Object& ) = 0;
|
|
|
|
virtual const std::string& getName() const = 0;
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
|
|
|
|
protected:
|
2010-11-09 21:23:43 +08:00
|
|
|
int _firstVersion; // Library version when the serializer is first introduced
|
|
|
|
int _lastVersion; // Library version when the serializer is last required.
|
2010-01-21 04:13:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename C>
|
|
|
|
class UserSerializer : public BaseSerializer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef bool (*Checker)( const C& );
|
|
|
|
typedef bool (*Reader)( InputStream&, C& );
|
|
|
|
typedef bool (*Writer)( OutputStream&, const C& );
|
|
|
|
|
|
|
|
UserSerializer( const char* name, Checker cf, Reader rf, Writer wf )
|
|
|
|
: _name(name), _checker(cf), _reader(rf), _writer(wf) {}
|
|
|
|
|
|
|
|
virtual bool read( InputStream& is, osg::Object& obj )
|
|
|
|
{
|
|
|
|
C& object = OBJECT_CAST<C&>(obj);
|
2010-01-28 01:09:05 +08:00
|
|
|
if ( is.isBinary() )
|
|
|
|
{
|
|
|
|
bool ok = false; is >> ok;
|
|
|
|
if ( !ok ) return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !is.matchString(_name) )
|
|
|
|
return true;
|
|
|
|
}
|
2010-01-21 04:13:33 +08:00
|
|
|
return (*_reader)(is, object);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool write( OutputStream& os, const osg::Object& obj )
|
|
|
|
{
|
|
|
|
const C& object = OBJECT_CAST<const C&>(obj);
|
2010-01-28 01:09:05 +08:00
|
|
|
bool ok = (*_checker)(object);
|
|
|
|
if ( os.isBinary() )
|
2010-01-21 04:13:33 +08:00
|
|
|
{
|
2010-01-28 01:09:05 +08:00
|
|
|
os << ok;
|
|
|
|
if ( !ok ) return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !ok ) return true;
|
|
|
|
os << PROPERTY(_name.c_str());
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
|
|
|
return (*_writer)(os, object);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual const std::string& getName() const { return _name; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
std::string _name;
|
|
|
|
Checker _checker;
|
2010-01-28 01:09:05 +08:00
|
|
|
|
|
|
|
public:
|
2010-01-21 04:13:33 +08:00
|
|
|
Reader _reader;
|
|
|
|
Writer _writer;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename P>
|
|
|
|
class TemplateSerializer : public BaseSerializer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TemplateSerializer( const char* name )
|
|
|
|
: _name(name) {}
|
|
|
|
|
|
|
|
virtual bool read( InputStream& is, osg::Object& obj ) = 0;
|
|
|
|
virtual bool write( OutputStream& os, const osg::Object& obj ) = 0;
|
|
|
|
virtual const std::string& getName() const { return _name; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
std::string _name;
|
|
|
|
P _defaultValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename C, typename P>
|
|
|
|
class PropByValSerializer : public TemplateSerializer<P>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef TemplateSerializer<P> ParentType;
|
|
|
|
typedef P (C::*Getter)() const;
|
|
|
|
typedef void (C::*Setter)( P );
|
|
|
|
|
|
|
|
PropByValSerializer( const char* name, P def, Getter gf, Setter sf, bool useHex=false )
|
|
|
|
: ParentType(name), _getter(gf), _setter(sf), _useHex(useHex)
|
|
|
|
{ ParentType::_defaultValue = def; }
|
|
|
|
|
|
|
|
virtual bool read( InputStream& is, osg::Object& obj )
|
|
|
|
{
|
|
|
|
C& object = OBJECT_CAST<C&>(obj);
|
|
|
|
P value;
|
|
|
|
if ( is.isBinary() )
|
|
|
|
{
|
|
|
|
is >> value;
|
|
|
|
if ( ParentType::_defaultValue!=value )
|
|
|
|
(object.*_setter)( value );
|
|
|
|
}
|
|
|
|
else if ( is.matchString(ParentType::_name) )
|
|
|
|
{
|
|
|
|
if ( _useHex ) is >> std::hex;
|
|
|
|
is >> value;
|
|
|
|
if ( _useHex ) is >> std::dec;
|
|
|
|
(object.*_setter)( value );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool write( OutputStream& os, const osg::Object& obj )
|
|
|
|
{
|
|
|
|
const C& object = OBJECT_CAST<const C&>(obj);
|
2010-10-02 01:07:27 +08:00
|
|
|
P value = (object.*_getter)();
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( os.isBinary() )
|
|
|
|
{
|
2010-10-01 00:03:04 +08:00
|
|
|
os << value;
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
2010-10-01 00:03:04 +08:00
|
|
|
else if ( ParentType::_defaultValue!=value )
|
2010-01-21 04:13:33 +08:00
|
|
|
{
|
2010-01-28 01:09:05 +08:00
|
|
|
os << PROPERTY((ParentType::_name).c_str());
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( _useHex ) os << std::hex;
|
2010-10-01 00:03:04 +08:00
|
|
|
os << value;
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( _useHex ) os << std::dec;
|
|
|
|
os << std::endl;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-28 01:09:05 +08:00
|
|
|
public:
|
2010-01-21 04:13:33 +08:00
|
|
|
Getter _getter;
|
|
|
|
Setter _setter;
|
2010-01-28 01:09:05 +08:00
|
|
|
|
|
|
|
protected:
|
2010-01-21 04:13:33 +08:00
|
|
|
bool _useHex;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename C, typename P>
|
|
|
|
class PropByRefSerializer : public TemplateSerializer<P>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef TemplateSerializer<P> ParentType;
|
|
|
|
typedef const P& CP;
|
|
|
|
typedef CP (C::*Getter)() const;
|
|
|
|
typedef void (C::*Setter)( CP );
|
|
|
|
|
|
|
|
PropByRefSerializer( const char* name, CP def, Getter gf, Setter sf )
|
|
|
|
: ParentType(name), _getter(gf), _setter(sf)
|
|
|
|
{ ParentType::_defaultValue = def; }
|
|
|
|
|
|
|
|
virtual bool read( InputStream& is, osg::Object& obj )
|
|
|
|
{
|
|
|
|
C& object = OBJECT_CAST<C&>(obj);
|
|
|
|
P value;
|
|
|
|
if ( is.isBinary() )
|
|
|
|
{
|
|
|
|
is >> value;
|
|
|
|
if ( ParentType::_defaultValue!=value )
|
|
|
|
(object.*_setter)( value );
|
|
|
|
}
|
|
|
|
else if ( is.matchString(ParentType::_name) )
|
|
|
|
{
|
|
|
|
is >> value;
|
|
|
|
(object.*_setter)( value );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool write( OutputStream& os, const osg::Object& obj )
|
|
|
|
{
|
|
|
|
const C& object = OBJECT_CAST<const C&>(obj);
|
2010-10-02 01:07:27 +08:00
|
|
|
CP value = (object.*_getter)();
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( os.isBinary() )
|
|
|
|
{
|
2010-10-01 00:03:04 +08:00
|
|
|
os << value;
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
2010-10-01 00:03:04 +08:00
|
|
|
else if ( ParentType::_defaultValue!=value )
|
2010-01-21 04:13:33 +08:00
|
|
|
{
|
2010-10-01 00:03:04 +08:00
|
|
|
os << PROPERTY((ParentType::_name).c_str()) << value << std::endl;
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-28 01:09:05 +08:00
|
|
|
public:
|
2010-01-21 04:13:33 +08:00
|
|
|
Getter _getter;
|
|
|
|
Setter _setter;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename C>
|
|
|
|
class MatrixSerializer : public TemplateSerializer<osg::Matrix>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef TemplateSerializer<osg::Matrix> ParentType;
|
|
|
|
typedef const osg::Matrix& (C::*Getter)() const;
|
|
|
|
typedef void (C::*Setter)( const osg::Matrix& );
|
|
|
|
|
|
|
|
MatrixSerializer( const char* name, const osg::Matrix& def, Getter gf, Setter sf )
|
|
|
|
: ParentType(name), _getter(gf), _setter(sf)
|
|
|
|
{ ParentType::_defaultValue = def; }
|
|
|
|
|
|
|
|
virtual bool read( InputStream& is, osg::Object& obj )
|
|
|
|
{
|
|
|
|
C& object = OBJECT_CAST<C&>(obj);
|
|
|
|
osg::Matrix value;
|
|
|
|
if ( is.isBinary() )
|
|
|
|
{
|
|
|
|
readMatrixImplementation( is, value );
|
|
|
|
if ( ParentType::_defaultValue!=value )
|
|
|
|
(object.*_setter)( value );
|
|
|
|
}
|
|
|
|
else if ( is.matchString(ParentType::_name) )
|
|
|
|
{
|
|
|
|
readMatrixImplementation( is, value );
|
|
|
|
(object.*_setter)( value );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool write( OutputStream& os, const osg::Object& obj )
|
|
|
|
{
|
2010-10-04 23:23:19 +08:00
|
|
|
|
2010-01-21 04:13:33 +08:00
|
|
|
const C& object = OBJECT_CAST<const C&>(obj);
|
2010-10-01 00:03:04 +08:00
|
|
|
const osg::Matrix& value = (object.*_getter)();
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( os.isBinary() )
|
|
|
|
{
|
2010-10-04 23:23:19 +08:00
|
|
|
OSG_NOTICE<<"MatrixSerializer::write() binary"<<std::endl;
|
2010-10-01 00:03:04 +08:00
|
|
|
os << value;
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
2010-10-01 00:03:04 +08:00
|
|
|
else if ( ParentType::_defaultValue!=value )
|
2010-01-21 04:13:33 +08:00
|
|
|
{
|
2010-10-04 23:23:19 +08:00
|
|
|
OSG_NOTICE<<"MatrixSerializer::write() ascii, ParentType::_name="<<ParentType::_name<<std::endl;
|
2010-10-01 00:03:04 +08:00
|
|
|
os << PROPERTY((ParentType::_name).c_str()) << value << std::endl;
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void readMatrixImplementation( InputStream& is, osg::Matrix& matrix )
|
|
|
|
{
|
2010-10-04 23:23:19 +08:00
|
|
|
#if 1
|
|
|
|
is >> matrix;
|
|
|
|
#else
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( is.getUseFloatMatrix() )
|
|
|
|
{
|
|
|
|
osg::Matrixf realValue; is >> realValue;
|
|
|
|
matrix = realValue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
osg::Matrixd realValue; is >> realValue;
|
|
|
|
matrix = realValue;
|
|
|
|
}
|
2010-10-04 23:23:19 +08:00
|
|
|
#endif
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
|
|
|
|
2010-01-28 01:09:05 +08:00
|
|
|
public:
|
2010-01-21 04:13:33 +08:00
|
|
|
Getter _getter;
|
|
|
|
Setter _setter;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename C, typename P>
|
|
|
|
class GLenumSerializer : public TemplateSerializer<P>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef TemplateSerializer<P> ParentType;
|
|
|
|
typedef P (C::*Getter)() const;
|
|
|
|
typedef void (C::*Setter)( P );
|
|
|
|
|
|
|
|
GLenumSerializer( const char* name, P def, Getter gf, Setter sf )
|
|
|
|
: ParentType(name), _getter(gf), _setter(sf)
|
|
|
|
{ ParentType::_defaultValue = def; }
|
|
|
|
|
|
|
|
virtual bool read( InputStream& is, osg::Object& obj )
|
|
|
|
{
|
|
|
|
C& object = OBJECT_CAST<C&>(obj);
|
|
|
|
if ( is.isBinary() )
|
|
|
|
{
|
|
|
|
GLenum value; is >> value;
|
|
|
|
if ( ParentType::_defaultValue!=static_cast<P>(value) )
|
|
|
|
(object.*_setter)( static_cast<P>(value) );
|
|
|
|
}
|
|
|
|
else if ( is.matchString(ParentType::_name) )
|
|
|
|
{
|
|
|
|
DEF_GLENUM(value); is >> value;
|
|
|
|
(object.*_setter)( static_cast<P>(value.get()) );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool write( OutputStream& os, const osg::Object& obj )
|
|
|
|
{
|
|
|
|
const C& object = OBJECT_CAST<const C&>(obj);
|
2010-10-01 00:03:04 +08:00
|
|
|
const P value = (object.*_getter)();
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( os.isBinary() )
|
|
|
|
{
|
2010-10-01 00:03:04 +08:00
|
|
|
os << static_cast<GLenum>(value);
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
2010-10-01 00:03:04 +08:00
|
|
|
else if ( ParentType::_defaultValue!=value )
|
2010-01-21 04:13:33 +08:00
|
|
|
{
|
2010-10-01 00:03:04 +08:00
|
|
|
os << PROPERTY((ParentType::_name).c_str()) << GLENUM(value) << std::endl;
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-28 01:09:05 +08:00
|
|
|
public:
|
2010-01-21 04:13:33 +08:00
|
|
|
Getter _getter;
|
|
|
|
Setter _setter;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename C>
|
|
|
|
class StringSerializer : public TemplateSerializer<std::string>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef TemplateSerializer<std::string> ParentType;
|
|
|
|
typedef const std::string& (C::*Getter)() const;
|
|
|
|
typedef void (C::*Setter)( const std::string& );
|
|
|
|
|
|
|
|
StringSerializer( const char* name, const std::string& def, Getter gf, Setter sf )
|
|
|
|
: ParentType(name), _getter(gf), _setter(sf)
|
|
|
|
{ ParentType::_defaultValue = def; }
|
|
|
|
|
|
|
|
virtual bool read( InputStream& is, osg::Object& obj )
|
|
|
|
{
|
|
|
|
C& object = OBJECT_CAST<C&>(obj);
|
|
|
|
std::string value;
|
|
|
|
if ( is.isBinary() )
|
|
|
|
{
|
|
|
|
is >> value;
|
|
|
|
if ( ParentType::_defaultValue!=value )
|
|
|
|
(object.*_setter)( value );
|
|
|
|
}
|
|
|
|
else if ( is.matchString(ParentType::_name) )
|
|
|
|
{
|
|
|
|
is.readWrappedString( value );
|
|
|
|
if ( !value.empty() )
|
|
|
|
(object.*_setter)( value );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool write( OutputStream& os, const osg::Object& obj )
|
|
|
|
{
|
|
|
|
const C& object = OBJECT_CAST<const C&>(obj);
|
2010-10-01 00:03:04 +08:00
|
|
|
const std::string& value = (object.*_getter)();
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( os.isBinary() )
|
|
|
|
{
|
2010-10-01 00:03:04 +08:00
|
|
|
os << value;
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
2010-10-01 00:03:04 +08:00
|
|
|
else if ( ParentType::_defaultValue!=value )
|
2010-01-21 04:13:33 +08:00
|
|
|
{
|
2010-01-28 01:09:05 +08:00
|
|
|
os << PROPERTY((ParentType::_name).c_str());
|
2010-10-01 00:03:04 +08:00
|
|
|
os.writeWrappedString( value );
|
2010-01-21 04:13:33 +08:00
|
|
|
os << std::endl;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-28 01:09:05 +08:00
|
|
|
public:
|
2010-01-21 04:13:33 +08:00
|
|
|
Getter _getter;
|
|
|
|
Setter _setter;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename C, typename P>
|
|
|
|
class ObjectSerializer : public TemplateSerializer<P*>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef TemplateSerializer<P*> ParentType;
|
|
|
|
typedef const P* (C::*Getter)() const;
|
|
|
|
typedef void (C::*Setter)( P* );
|
|
|
|
|
|
|
|
ObjectSerializer( const char* name, P* def, Getter gf, Setter sf )
|
|
|
|
: ParentType(name), _getter(gf), _setter(sf)
|
|
|
|
{ ParentType::_defaultValue = def; }
|
|
|
|
|
|
|
|
virtual bool read( InputStream& is, osg::Object& obj )
|
|
|
|
{
|
|
|
|
C& object = OBJECT_CAST<C&>(obj);
|
|
|
|
bool hasObject = false;
|
|
|
|
if ( is.isBinary() )
|
|
|
|
{
|
|
|
|
is >> hasObject;
|
|
|
|
if ( hasObject )
|
|
|
|
{
|
|
|
|
P* value = dynamic_cast<P*>( is.readObject() );
|
|
|
|
if ( ParentType::_defaultValue!=value )
|
|
|
|
(object.*_setter)( value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( is.matchString(ParentType::_name) )
|
|
|
|
{
|
|
|
|
is >> hasObject;
|
|
|
|
if ( hasObject )
|
|
|
|
{
|
|
|
|
is >> BEGIN_BRACKET;
|
|
|
|
P* value = dynamic_cast<P*>( is.readObject() );
|
From Wang Rui, "Attached is the osgAnimation wrappers for serialize IO operations. A
few headers and the osgAnimation sources are also modified to make
everything goes well, including:
A new REGISTER_OBJECT_WRAPPER2 macro to wrap classes like
Skeleton::UpdateSkeleton.
A bug fix in the Seralizer header which avoids setting default values
to objects.
Naming style fixes in osgAnimation headers and sources, also in the
deprecated dotosg wrappers.
A bug fix for the XML support, to write char values correctly.
A small change in the osg::Geometry wrapper to ignore the
InternalGeometry property, which is used by the MorphGeometry and
should not be set by user applications.
The avatar.osg, nathan.osg and robot.osg data files all work fine with
serializers, with some 'unsupported wrapper' warnings when converting.
I'm thinking of removing these warnings by disabling related property
serializers (ComputeBoundingBoxCallback and Drawable::UpdateCallback),
which are seldom recorded by users.
By the way, I still wonder how would we handle the C4121 problem,
discussed some days before. The /Zp compile option is set to 16 in the
attached cmake script file. And is there a better solution now?"
2010-04-19 18:35:18 +08:00
|
|
|
if ( ParentType::_defaultValue!=value )
|
|
|
|
(object.*_setter)( value );
|
2010-01-21 04:13:33 +08:00
|
|
|
is >> END_BRACKET;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool write( OutputStream& os, const osg::Object& obj )
|
|
|
|
{
|
|
|
|
const C& object = OBJECT_CAST<const C&>(obj);
|
2010-10-01 00:03:04 +08:00
|
|
|
const P* value = (object.*_getter)();
|
|
|
|
bool hasObject = (value!=NULL);
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( os.isBinary() )
|
|
|
|
{
|
|
|
|
os << hasObject;
|
2010-10-01 00:03:04 +08:00
|
|
|
os.writeObject( value );
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
2010-10-01 00:03:04 +08:00
|
|
|
else if ( ParentType::_defaultValue!=value )
|
2010-01-21 04:13:33 +08:00
|
|
|
{
|
2010-01-28 01:09:05 +08:00
|
|
|
os << PROPERTY((ParentType::_name).c_str()) << hasObject;
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( hasObject )
|
|
|
|
{
|
|
|
|
os << BEGIN_BRACKET << std::endl;
|
2010-10-01 00:03:04 +08:00
|
|
|
os.writeObject( value );
|
2010-01-21 04:13:33 +08:00
|
|
|
os << END_BRACKET;
|
|
|
|
}
|
|
|
|
os << std::endl;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-28 01:09:05 +08:00
|
|
|
public:
|
2010-01-21 04:13:33 +08:00
|
|
|
Getter _getter;
|
|
|
|
Setter _setter;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename C, typename P>
|
|
|
|
class ImageSerializer : public TemplateSerializer<P*>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef TemplateSerializer<P*> ParentType;
|
|
|
|
typedef const P* (C::*Getter)() const;
|
|
|
|
typedef void (C::*Setter)( P* );
|
|
|
|
|
|
|
|
ImageSerializer( const char* name, P* def, Getter gf, Setter sf )
|
|
|
|
: ParentType(name), _getter(gf), _setter(sf)
|
|
|
|
{ ParentType::_defaultValue = def; }
|
|
|
|
|
|
|
|
virtual bool read( InputStream& is, osg::Object& obj )
|
|
|
|
{
|
|
|
|
C& object = OBJECT_CAST<C&>(obj);
|
|
|
|
bool hasObject = false;
|
|
|
|
if ( is.isBinary() )
|
|
|
|
{
|
|
|
|
is >> hasObject;
|
|
|
|
if ( hasObject )
|
|
|
|
{
|
|
|
|
P* value = dynamic_cast<P*>( is.readImage() );
|
|
|
|
if ( ParentType::_defaultValue!=value )
|
|
|
|
(object.*_setter)( value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( is.matchString(ParentType::_name) )
|
|
|
|
{
|
|
|
|
is >> hasObject;
|
|
|
|
if ( hasObject )
|
|
|
|
{
|
|
|
|
is >> BEGIN_BRACKET;
|
|
|
|
P* value = dynamic_cast<P*>( is.readImage() );
|
From Wang Rui, "Attached is the osgAnimation wrappers for serialize IO operations. A
few headers and the osgAnimation sources are also modified to make
everything goes well, including:
A new REGISTER_OBJECT_WRAPPER2 macro to wrap classes like
Skeleton::UpdateSkeleton.
A bug fix in the Seralizer header which avoids setting default values
to objects.
Naming style fixes in osgAnimation headers and sources, also in the
deprecated dotosg wrappers.
A bug fix for the XML support, to write char values correctly.
A small change in the osg::Geometry wrapper to ignore the
InternalGeometry property, which is used by the MorphGeometry and
should not be set by user applications.
The avatar.osg, nathan.osg and robot.osg data files all work fine with
serializers, with some 'unsupported wrapper' warnings when converting.
I'm thinking of removing these warnings by disabling related property
serializers (ComputeBoundingBoxCallback and Drawable::UpdateCallback),
which are seldom recorded by users.
By the way, I still wonder how would we handle the C4121 problem,
discussed some days before. The /Zp compile option is set to 16 in the
attached cmake script file. And is there a better solution now?"
2010-04-19 18:35:18 +08:00
|
|
|
if ( ParentType::_defaultValue!=value )
|
|
|
|
(object.*_setter)( value );
|
2010-01-21 04:13:33 +08:00
|
|
|
is >> END_BRACKET;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool write( OutputStream& os, const osg::Object& obj )
|
|
|
|
{
|
|
|
|
const C& object = OBJECT_CAST<const C&>(obj);
|
2010-10-01 00:03:04 +08:00
|
|
|
const P* value = (object.*_getter)();
|
|
|
|
bool hasObject = (value!=NULL);
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( os.isBinary() )
|
|
|
|
{
|
|
|
|
os << hasObject;
|
2010-10-01 00:03:04 +08:00
|
|
|
os.writeImage( value );
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
2010-10-01 00:03:04 +08:00
|
|
|
else if ( ParentType::_defaultValue!=value )
|
2010-01-21 04:13:33 +08:00
|
|
|
{
|
2010-01-28 01:09:05 +08:00
|
|
|
os << PROPERTY((ParentType::_name).c_str()) << hasObject;
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( hasObject )
|
|
|
|
{
|
|
|
|
os << BEGIN_BRACKET << std::endl;
|
2010-10-01 00:03:04 +08:00
|
|
|
os.writeImage( value );
|
2010-01-21 04:13:33 +08:00
|
|
|
os << END_BRACKET;
|
|
|
|
}
|
|
|
|
os << std::endl;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-28 01:09:05 +08:00
|
|
|
public:
|
2010-01-21 04:13:33 +08:00
|
|
|
Getter _getter;
|
|
|
|
Setter _setter;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename C, typename P, typename B>
|
|
|
|
class EnumSerializer : public TemplateSerializer<P>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef TemplateSerializer<P> ParentType;
|
|
|
|
typedef P (C::*Getter)() const;
|
|
|
|
typedef B (C::*Setter)( P );
|
|
|
|
|
|
|
|
EnumSerializer( const char* name, P def, Getter gf, Setter sf )
|
|
|
|
: ParentType(name), _getter(gf), _setter(sf)
|
|
|
|
{ ParentType::_defaultValue = def; }
|
|
|
|
|
|
|
|
void add( const char* str, P value )
|
2010-10-01 00:03:04 +08:00
|
|
|
{ _lookup.add(str, static_cast<IntLookup::Value>(value)); }
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
P getValue( const char* str )
|
|
|
|
{ return static_cast<P>(_lookup.getValue(str)); }
|
|
|
|
|
|
|
|
const std::string& getString( P value )
|
2010-10-01 00:03:04 +08:00
|
|
|
{ return _lookup.getString(static_cast<IntLookup::Value>(value)); }
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
virtual bool read( InputStream& is, osg::Object& obj )
|
|
|
|
{
|
|
|
|
C& object = OBJECT_CAST<C&>(obj);
|
|
|
|
IntLookup::Value value;
|
|
|
|
if ( is.isBinary() )
|
|
|
|
{
|
|
|
|
is >> value;
|
|
|
|
if ( ParentType::_defaultValue!=static_cast<P>(value) )
|
|
|
|
(object.*_setter)( static_cast<P>(value) );
|
|
|
|
}
|
|
|
|
else if ( is.matchString(ParentType::_name) )
|
|
|
|
{
|
|
|
|
std::string str; is >> str;
|
|
|
|
(object.*_setter)( getValue(str.c_str()) );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool write( osgDB::OutputStream& os, const osg::Object& obj )
|
|
|
|
{
|
|
|
|
const C& object = OBJECT_CAST<const C&>(obj);
|
2010-10-01 00:03:04 +08:00
|
|
|
const P value = (object.*_getter)();
|
2010-01-21 04:13:33 +08:00
|
|
|
if ( os.isBinary() )
|
|
|
|
{
|
2010-10-01 00:03:04 +08:00
|
|
|
os << (IntLookup::Value)value;
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
2010-10-01 00:03:04 +08:00
|
|
|
else if ( ParentType::_defaultValue!=value )
|
2010-01-21 04:13:33 +08:00
|
|
|
{
|
2010-10-01 00:03:04 +08:00
|
|
|
os << PROPERTY((ParentType::_name).c_str()) << getString(value) << std::endl;
|
2010-01-21 04:13:33 +08:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-28 01:09:05 +08:00
|
|
|
public:
|
2010-01-21 04:13:33 +08:00
|
|
|
Getter _getter;
|
|
|
|
Setter _setter;
|
2010-01-28 01:09:05 +08:00
|
|
|
|
|
|
|
protected:
|
2010-01-21 04:13:33 +08:00
|
|
|
IntLookup _lookup;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename C, typename P>
|
|
|
|
class ListSerializer : public TemplateSerializer<P>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef TemplateSerializer<P> ParentType;
|
|
|
|
typedef typename P::value_type ValueType;
|
|
|
|
typedef typename P::const_iterator ConstIterator;
|
2010-10-01 00:03:04 +08:00
|
|
|
typedef const P& (C::*Getter)() const;
|
2010-01-21 04:13:33 +08:00
|
|
|
typedef void (C::*Setter)( const P& );
|
|
|
|
|
|
|
|
ListSerializer( const char* name, Getter gf, Setter sf )
|
|
|
|
: ParentType(name), _getter(gf), _setter(sf) {}
|
|
|
|
|
|
|
|
virtual bool read( InputStream& is, osg::Object& obj )
|
|
|
|
{
|
|
|
|
C& object = OBJECT_CAST<C&>(obj);
|
|
|
|
unsigned int size = 0;
|
|
|
|
P list;
|
|
|
|
if ( is.isBinary() )
|
|
|
|
{
|
|
|
|
is >> size;
|
|
|
|
for ( unsigned int i=0; i<size; ++i )
|
|
|
|
{
|
|
|
|
ValueType value;
|
|
|
|
is >> value;
|
|
|
|
list.push_back( value );
|
|
|
|
}
|
|
|
|
if ( size>0 ) (object.*_setter)( list );
|
|
|
|
}
|
|
|
|
else if ( is.matchString(ParentType::_name) )
|
|
|
|
{
|
|
|
|
is >> size;
|
|
|
|
if ( size>0 ) is >> BEGIN_BRACKET;
|
|
|
|
for ( unsigned int i=0; i<size; ++i )
|
|
|
|
{
|
|
|
|
ValueType value;
|
|
|
|
is >> value;
|
|
|
|
list.push_back( value );
|
|
|
|
}
|
|
|
|
if ( size>0 )
|
|
|
|
{
|
|
|
|
is >> END_BRACKET;
|
|
|
|
(object.*_setter)( list );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool write( OutputStream& os, const osg::Object& obj )
|
|
|
|
{
|
|
|
|
const C& object = OBJECT_CAST<const C&>(obj);
|
|
|
|
const P& list = (object.*_getter)();
|
|
|
|
unsigned int size = (unsigned int)list.size();
|
|
|
|
if ( os.isBinary() )
|
|
|
|
{
|
|
|
|
os << size;
|
|
|
|
for ( ConstIterator itr=list.begin();
|
|
|
|
itr!=list.end(); ++itr )
|
|
|
|
{
|
|
|
|
os << (*itr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( size>0 )
|
|
|
|
{
|
2010-01-28 01:09:05 +08:00
|
|
|
os << PROPERTY((ParentType::_name).c_str()) << size << BEGIN_BRACKET << std::endl;
|
2010-01-21 04:13:33 +08:00
|
|
|
for ( ConstIterator itr=list.begin();
|
|
|
|
itr!=list.end(); ++itr )
|
|
|
|
{
|
|
|
|
os << (*itr);
|
|
|
|
}
|
2010-06-09 18:01:25 +08:00
|
|
|
os << std::endl;
|
2010-01-21 04:13:33 +08:00
|
|
|
os << END_BRACKET << std::endl;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-28 01:09:05 +08:00
|
|
|
public:
|
2010-01-21 04:13:33 +08:00
|
|
|
Getter _getter;
|
|
|
|
Setter _setter;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ADDING MANIPULATORS
|
|
|
|
#define ADD_SERIALIZER(S) \
|
2010-04-20 18:29:04 +08:00
|
|
|
wrapper->addSerializer( (S) )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_USER_SERIALIZER(PROP) \
|
|
|
|
wrapper->addSerializer( new osgDB::UserSerializer<MyClass>( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, &check##PROP, &read##PROP, &write##PROP), osgDB::BaseSerializer::RW_USER )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_BOOL_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, bool >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_BOOL )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_SHORT_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, short >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_SHORT )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_USHORT_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, unsigned short >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_USHORT )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_HEXSHORT_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, unsigned short >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP, true), osgDB::BaseSerializer::RW_USHORT )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_INT_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, int >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_INT )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_UINT_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, unsigned int >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_UINT )
|
2010-04-19 20:09:21 +08:00
|
|
|
|
|
|
|
#define ADD_GLINT_SERIALIZER(PROP, DEF) \
|
|
|
|
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, GLint >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, ((int)(DEF)), &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_INT )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_HEXINT_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, unsigned int >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP, true), osgDB::BaseSerializer::RW_UINT )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_FLOAT_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, float >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_FLOAT )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_DOUBLE_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, double >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_DOUBLE )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
2010-04-20 18:29:04 +08:00
|
|
|
#define ADD_VEC2F_SERIALIZER(PROP, DEF) \
|
|
|
|
wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Vec2f >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_VEC2F )
|
2010-04-20 18:29:04 +08:00
|
|
|
|
|
|
|
#define ADD_VEC2D_SERIALIZER(PROP, DEF) \
|
|
|
|
wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Vec2d >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_VEC2D )
|
2010-04-20 18:29:04 +08:00
|
|
|
|
|
|
|
#define ADD_VEC2_SERIALIZER(PROP, DEF) ADD_VEC2F_SERIALIZER(PROP, DEF)
|
|
|
|
|
2010-01-21 04:13:33 +08:00
|
|
|
#define ADD_VEC3F_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Vec3f >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_VEC3F )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_VEC3D_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Vec3d >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_VEC3D )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_VEC3_SERIALIZER(PROP, DEF) ADD_VEC3F_SERIALIZER(PROP, DEF)
|
|
|
|
|
|
|
|
#define ADD_VEC4F_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Vec4f >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_VEC4F )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_VEC4D_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Vec4d >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_VEC4D )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_VEC4_SERIALIZER(PROP, DEF) ADD_VEC4F_SERIALIZER(PROP, DEF)
|
|
|
|
|
|
|
|
#define ADD_QUAT_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Quat >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_QUAT )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_PLANE_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Plane >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_PLANE )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_MATRIXF_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Matrixf >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_MATRIXF )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_MATRIXD_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Matrixd >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_MATRIXD )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_MATRIX_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::MatrixSerializer< MyClass >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_MATRIX )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_GLENUM_SERIALIZER(PROP, TYPE, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::GLenumSerializer< MyClass, TYPE >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_GLENUM )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_STRING_SERIALIZER(PROP, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::StringSerializer< MyClass >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_STRING )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_OBJECT_SERIALIZER(PROP, TYPE, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::ObjectSerializer< MyClass, TYPE >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_OBJECT )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_IMAGE_SERIALIZER(PROP, TYPE, DEF) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::ImageSerializer< MyClass, TYPE >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_IMAGE )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define ADD_LIST_SERIALIZER(PROP, TYPE) \
|
2010-02-26 23:54:37 +08:00
|
|
|
wrapper->addSerializer( new osgDB::ListSerializer< MyClass, TYPE >( \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
#PROP, &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_LIST )
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#define BEGIN_ENUM_SERIALIZER(PROP, DEF) \
|
|
|
|
{ typedef osgDB::EnumSerializer<MyClass, MyClass::PROP, void> MySerializer; \
|
|
|
|
osg::ref_ptr<MySerializer> serializer = new MySerializer( \
|
|
|
|
#PROP, MyClass::DEF, &MyClass::get##PROP, &MyClass::set##PROP)
|
|
|
|
|
|
|
|
#define BEGIN_ENUM_SERIALIZER2(PROP, TYPE, DEF) \
|
|
|
|
{ typedef osgDB::EnumSerializer<MyClass, TYPE, void> MySerializer; \
|
|
|
|
osg::ref_ptr<MySerializer> serializer = new MySerializer( \
|
|
|
|
#PROP, MyClass::DEF, &MyClass::get##PROP, &MyClass::set##PROP)
|
|
|
|
|
|
|
|
#define BEGIN_ENUM_SERIALIZER3(PROP, DEF) \
|
|
|
|
{ typedef osgDB::EnumSerializer<MyClass, MyClass::PROP, bool> MySerializer; \
|
|
|
|
osg::ref_ptr<MySerializer> serializer = new MySerializer( \
|
|
|
|
#PROP, MyClass::DEF, &MyClass::get##PROP, &MyClass::set##PROP)
|
|
|
|
|
2010-03-17 02:44:27 +08:00
|
|
|
#define BEGIN_ENUM_SERIALIZER4(PROPERTIES_CLASS, PROP, DEF) \
|
|
|
|
{ typedef osgDB::EnumSerializer<MyClass, PROPERTIES_CLASS::PROP, void> MySerializer; \
|
|
|
|
osg::ref_ptr<MySerializer> serializer = new MySerializer( \
|
|
|
|
#PROP, PROPERTIES_CLASS::DEF, &MyClass::get##PROP, &MyClass::set##PROP)
|
|
|
|
|
2010-01-21 04:13:33 +08:00
|
|
|
#define ADD_ENUM_VALUE(VALUE) \
|
|
|
|
serializer->add(#VALUE, MyClass::VALUE)
|
|
|
|
|
2010-03-17 02:44:27 +08:00
|
|
|
#define ADD_ENUM_CLASS_VALUE(CLASS, VALUE) \
|
|
|
|
serializer->add(#VALUE, CLASS::VALUE)
|
|
|
|
|
2010-01-21 04:13:33 +08:00
|
|
|
#define END_ENUM_SERIALIZER() \
|
From Wang Rui, "I'd like to submit my latest modification of the serialization IO
functionalities. It includes two main parts: a version checking macro
for handling backward-compatiblity since 3.0, and enhencement of
current schema mechanism. I also change the option handling process to
use getPluginStringData(), and add new USE_SERIALIZER_WRAPPER macro in
the Registry header to allow for static-link usage as well.
The enhencement of schema machanism just tells the type of each
serializer while outputting them, such as:
osg::Group = Children:1
The meaning of the number can be found in the osgDB/Serializer header,
BaseSerializer::Type enum. It may help 3rdparty utilities understand
the structure of the wrapper and do some reflection work in the
future.
The new macro UPDATE_TO_VERSION can help indicate the InputStream (no
affect on the writer) that a serializer is added/removed since certain
OSG version. An example wrapper file is also attached. The
Geode_modified.cpp is based on the serializers/osg/Geode.cpp file
(hey, don't merge it :-), but assumes that a new user serializer
'Test' is added since version 65 (that is, the OSG_SOVERSION):
REGISTER_OBJECT_WRAPPER( Geode, ... )
{
ADD_USER_SERIALIZER( Drawables ); // origin ones
UPDATE_TO_VERSION( 65 )
{
ADD_USER_SERIALIZER( Test ); // a serializer added from version 65
}
}
All kinds of ADD_... macros following UPDATE_TO_VERSION will
automatically apply the updated version. The braces here are only for
typesetting!
While reading an osgt/osgb/osgx file, OSG will now check if the file
version (recorded as the writer's soversion, instead of previous
meaningless "#Version 2") is equal or greater than Test's version, and
try reading it, or just ignore it if file version is lesser.
And we also have the REMOVE_SERIALIZER macro will mark a named
serializer as removed in some version, with which all files generated
by further versions will just ignore it:
UPDATE_TO_VERSION( 70 )
{
REMOVE_SERIALIZER( Test );
}
This means that from version 70, the serializer Test is removed (but
not actually erased from the list) and should not be read anymore. If
the read file version is less than 70 (and equal or greater than 65),
Test will still be handled when reading; otherwise it will be ignored
to keep compatiblity on different OSG versions.
"
2010-11-09 20:41:55 +08:00
|
|
|
wrapper->addSerializer(serializer.get(), osgDB::BaseSerializer::RW_ENUM); }
|
|
|
|
|
|
|
|
// VERSION CONTROL OPERATORS
|
|
|
|
#define UPDATE_TO_VERSION(VER) \
|
|
|
|
wrapper->setUpdatedVersion( (VER) );
|
|
|
|
|
|
|
|
#define REMOVE_SERIALIZER(PROP) \
|
|
|
|
wrapper->markSerializerAsRemoved( #PROP );
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|