Hi Grogoire,

On Fri, Jun 10, 2011 at 2:58 PM, Gregoire Tarizzo
<gregoire.tari...@virtuelcity.com> wrote:
> As for me I have two main questions:
> 1. This first question is not directly linked with the meta feature it's
> just that i'm still very new to OSG and even more to serialization. How are
> we going to serialize a custom type meta in our container? I've looked into
> the UserDataContainer serializer, and I get that when it serializes the
> _objectList, every object serialializer is called depending on the object
> "type". But I still couldn't figure how and where I should specify the
> proper serialization for a custom object.

I provide an example of serializer in the osguserdata example, and
there are plenty
of other examples of serializers in src/osgWrappers/serializes for all
the core OSG
classes.

> 2. When I see the 3 diffent attributes in the UserDataContainer for
> _userData, _descriptionList and _objectList, I don't know if there's
> something awkward, or if I don't fully understand the issues. The _userData
> and _desciptionList are, to me, meta values like any other meta value, so
> why the special treatment?

For backwards compatibility UserData is a osg::Referenced, you can't just assign
it as a UserObject as this requires the Objects to be subclassed from
osg::Object.
You could in their have a custom Obect that holds the a ref_ptr<> for
the UserData
but this really would be an ungodly hack.

In the case of the Descriptions list it's also backwards compatibility
- you can fake
compatibiity using a custom UserObject just for holding the Descriptions vector
but it's a real hack to do so.

So the approach I took actually has far less special treatment than
the alternative,
and fits very seamlessly in with the old API and it's usage.


>It makes the UserDataContainer a little heavier
> to have these three attributes instead of one std::vector. Couldn't we
> imagine some kind of _userData and _desciptionList subclassing from Object?
> Maybe this way we could make UserDataConainer inherit from std::vector
> directly? Instead of being a container containing our real containers.

The extra cost a ref_ptr<> and std::vector<std::string> is pretty
small, and in normal
usage I woudl expect only a small number of UserDataContainer objects to ever be
created so this cost really is likely to be very small indeed.  Given
we have removed
the std::vector<std::string> from osg::Node I would expect the new
scheme to result
in small scene graphs for everybody.

Robert.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to