Hi Wang Rui and Robert, 2011/5/12 Wang Rui <[email protected]>: > Hi Rafa, > > Sorry for not following the thread in time. Of course I'd like to see > the serializers to be used in more fields besides file I/O operations. > And your changes will surely make it possible. The comments are good > to me, too. > > In the last year I posted some of my work with the reflection > framework using the wrappers. It's not a submission so you can't find > it in the source code. You may read and download the example code at: > http://lists.openscenegraph.org/htdig.cgi/osg-users-openscenegraph.org/2010-June/042270.html
Thank you I will take a look at this. > > The main problem I've met is that custom wrapper serializers > (ADD_USER_SERIALZIER) can hardly be reused here so that the reflection > framework will be useless because some very basic methods like > adding/removing children are impossible to be done. I've no idea about > the solution at present and hope someone will give me a flash of > miraculous brightness someday. :-) Currently, my idea is not use it as a complete reflection system, only for a generic setter/getter of basic properties. I've been playing with this in a similar way that the xml iterator works. If you find an osg::Object, you explore the properties if you find a USER object, go deep and so on. For example I did my own PropertySet and Property classes (they are similar to the proposal of meta objects in osg, but less powerful) and a PropertyInputIterator and PropertyOutputIterator.. after apply the serializer I have a similar graph in a way that I can explore it. By now are only tests, but I didn't find yet the most handy solution :). Rafa. > > Regards, > > Wang Rui > > > 2011/5/12 Rafa Gaitan <[email protected]>: >> Hi Robert, >> >> Yes, it make sense to me. I didn't want to change too much that class >> to maintain compatibility, that's why I added that methods. Maybe Wang >> Rui can comment more about this, he is the master of the serializers! >> :). >> >> I'm also thinking about the possibility of add methods to request >> "properties" or "serializers" of an osg::Object class and "read" and >> "write" that values. So it can be exported to a gui easily. What do >> you think? Maybe a helper method in osgDB::Serializer?, >> osgDB::Registry. >> >> Greets, >> Rafa. >> >> >> 2011/5/12 Robert Osfield <[email protected]>: >>> Hi Rafa, >>> >>> I'm just merging your changes but feel that we need to add some >>> doxygen comments to clarify what the set*Iterator(..) and start(..) >>> methods relate to. My first bash at these comments follows: >>> >>> /// set an input iterator, used directly when not using >>> InputStream with a traditional file releated stream. >>> void setInputIterator( InputIterator* ii ) { _in = ii; } >>> >>> /// start reading from InputStream treating it as a traditional >>> file releated stream, handles headers and versioning >>> ReadType start( InputIterator* ); >>> >>> And >>> >>> >>> /// set an output iterator, used directly when not using >>> OutputStream with a traditional file releated stream. >>> void setOutputIterator( OutputIterator* oi ) { _out = oi; } >>> >>> /// start writing to OutputStream treating it as a traditional >>> file releated stream, handles headers and versioning >>> void start( OutputIterator* outIterator, WriteType type ); >>> >>> Does this make sense? Feel free to suggest better wording. >>> >>> Cheers, >>> Robert. >>> >>> >>> On Sat, May 7, 2011 at 9:12 AM, Rafa Gaitan <[email protected]> wrote: >>>> Hi Robert, >>>> >>>> I've been playing around with serializers in order to use it as a >>>> "generic" property mechanism for osg::Object. >>>> >>>> The main problem I have found is that InputStream and OutputStream >>>> only takes the stream when you call start method, and in that case it >>>> attaches to the stream buffer some stuff, useful for files but not for >>>> runtime/gui usage. I have added a simple setInputIterator and >>>> setOutputIterator to the classes so now you can easily serialize >>>> values without version and other stuff. >>>> >>>> Writing matrix: >>>> osgDB::OutputStream os(0); >>>> std::stringstream sstream; >>>> os.setOutputIterator(new AsciiOutputIterator(&sstream)); >>>> os << matrix; >>>> std::string value = sstream.str(); >>>> >>>> Reading matrix: >>>> osgDB::InputStream is(0); >>>> std::stringstream sstream(value); >>>> is.setInputIterator(new AsciiInputIterator(&sstream)); >>>> osg::Matrixf mat2; >>>> is >> mat2; >>>> >>>> Maybe this can be used with the Metadata mechanism that is in >>>> discussion in the osg-user list, so generic values can be read by a >>>> GUI in a string like format, or even generic properties of objects. >>>> >>>> Cheers, >>>> Rafa. >>>> >>>> >>>> -- >>>> Rafael Gaitán Linares >>>> Instituto de Automática e Informática Industrial http://www.ai2.upv.es >>>> http://gvsig3d.blogspot.com >>>> Ciudad Politécnica de la Innovación >>>> Universidad Politécnica de Valencia >>>> >>>> _______________________________________________ >>>> osg-submissions mailing list >>>> [email protected] >>>> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org >>>> >>>> >>> _______________________________________________ >>> osg-submissions mailing list >>> [email protected] >>> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org >>> >> >> >> >> -- >> Rafael Gaitán Linares >> Instituto de Automática e Informática Industrial http://www.ai2.upv.es >> http://gvsig3d.blogspot.com >> Ciudad Politécnica de la Innovación >> Universidad Politécnica de Valencia >> _______________________________________________ >> osg-submissions mailing list >> [email protected] >> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org >> > _______________________________________________ > osg-submissions mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > -- Rafael Gaitán Linares Instituto de Automática e Informática Industrial http://www.ai2.upv.es http://gvsig3d.blogspot.com Ciudad Politécnica de la Innovación Universidad Politécnica de Valencia _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
