Hi Butler,
To make use of serializers, your class requires a namespace, for
example, NS::Foo. And then override className() and libraryName(), the
META_Object macro would help a lot.
To use ADD_STRING_SERIALIZER. Your should have a pair of suitable functions:
void setNote(const std::string);
const std::string getNote() const;
And ADD_INT_SERIALIZER requires a little different approach:
void setNumber(int);
int getNumber() const;
Basic data types like bool, int and float, doesn't need a prefix const here.
Regards,
Wang Rui
2010/3/24 Butler, Lee Mr CIV USA USAMC lee.but...@us.army.mil:
I'm trying to use the new serialization support and getting a compile error I
don't really understand.
For the following code:
-
class Foo : public osg::Group {
public:
Foo() {}
void setNote(std::string s) { _note = s; }
const std::string getNote() const { return _note; }
void setNumber(int n) { _num = n; }
const int getNumber() const { return _num; }
private:
std::string _note;
int _num;
};
REGISTER_OBJECT_WRAPPER( Foo,
new Foo,
Foo,
osg::Object osg::Node osg::Group Foo )
{
ADD_STRING_SERIALIZER(Note, v);
ADD_INT_SERIALIZER(Number, 0);
}
-
I get the following compile-time error:
g++ -DDarwin -g -ggdb3 -32 -m32 -I. -I/usr/local/include -c -o
obj/multiTree.o ./multiTree.cpp
./multiTree.cpp: In function 'void
wrapper_propfunc_Foo(osgDB::ObjectWrapper*)':
./multiTree.cpp:42: error: no matching function for call to
'osgDB::StringSerializerFoo::StringSerializer(const char [5], const char
[2], const std::string (Foo::*)()const, void (Foo::*)(std::string))'
/usr/local/include/osgDB/Serializer:425: note: candidates are:
osgDB::StringSerializerC::StringSerializer(const char*, const std::string,
const std::string (C::*)()const, void (C::*)(const std::string)) [with C =
Foo]
/usr/local/include/osgDB/Serializer:419: note:
osgDB::StringSerializerFoo::StringSerializer(const
osgDB::StringSerializerFoo)
./multiTree.cpp:43: error: no matching function for call to
'osgDB::PropByValSerializerFoo, int::PropByValSerializer(const char [7],
int, const int (Foo::*)()const, void (Foo::*)(int))'
/usr/local/include/osgDB/Serializer:205: note: candidates are:
osgDB::PropByValSerializerC, P::PropByValSerializer(const char*, P, P
(C::*)()const, void (C::*)(P), bool) [with C = Foo, P = int]
/usr/local/include/osgDB/Serializer:199: note:
osgDB::PropByValSerializerFoo, int::PropByValSerializer(const
osgDB::PropByValSerializerFoo, int)
make: *** [obj/multiTree.o] Error 1
If I comment out the REGISTER_OBJECT_WRAPPER macro use, the code compiles
without problem.
Clearly this macro is working fine for the OSG library code, so I'm sure it's
my mistake. I just can't decipher the error message to know what to fix.
Can someone give me the clue as to what I'm doing wrong?
Lee
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org