Re: [osg-users] META_object macro returning osg::Object* for cloneType and clone
Hi Robert, I already feared that it had to do with non-compliant compilers. It seems to be that I have already been in the lucky situation that all my compilers did never have any problems with this issue. Though I think / hope that all current C++ compilers should be able to compile this kind of stuff. Probably an item for the future. Cheers, Hartwig -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72482#72482 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_object macro returning osg::Object* for cloneType and clone
HI Hartwig, I attempted at having different return types with Object::clone() in different subclasses many years ago but different compilers would accept or not accept this usage, it simple wasn't portable enough to roll out. If you know the type and want to clone without doing the extra C++ legwork you can use the osg::clone(..) method i.e. osg::Texture2D* orig_texture; = osg::ref_ptr new_texture = osg::clone(orig_texture); This will do the required dynamic for you. If you are worried about the cost of the dynamic cast then you could just explicitly call the copy constructor: osg::ref_ptr new_texture = new osg::Texture2D(*orig_texture); Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_object macro returning osg::Object* for cloneType and clone
Hi I don't understand your ex: If you clone a list of Object you'll get...a list of Object...you can't forsee their type... Further why don't u static cast when you're sure of the return type?... hartwigw wrote: > Hi, > > if you have a list of pointer of derived classes from osg::Object and you > would like to clone them you always have to cast them. And I like to prevent > casts as often as possible. > > Example: if you clone a StateAttribute you get back a pointer to an Object > although you know (and the compiler could also know) that the result is a > StateAttribute. > > Cheers, > Hartwig -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72462#72462 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_object macro returning osg::Object* for cloneType and clone
Hi, if you have a list of pointer of derived classes from osg::Object and you would like to clone them you always have to cast them. And I like to prevent casts as often as possible. Example: if you clone a StateAttribute you get back a pointer to an Object although you know (and the compiler could also know) that the result is a StateAttribute. Cheers, Hartwig -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72461#72461 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_object macro returning osg::Object* for cloneType and clone
mp3butcher wrote: > > Hi > Indeed, but i don't see the point... > I've never used this C++ feature..For me an interface should always be > respected as a generate contract in a framewrok.. > Perhaps Robert will tell you more > Cheers > > hartwigw wrote: > > Hi, > > > > yes and no, you can change the return type though. > > > > > > Cheers, > > Hartwig > -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72460#72460 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_object macro returning osg::Object* for cloneType and clone
Indeed, but what do you want to achieve exploiting such an intrinsequent and exotic C++ feature? hartwigw wrote: > Hi, > > yes and no, you can change the return type though. > > > Cheers, > Hartwig -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72459#72459 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_object macro returning osg::Object* for cloneType and clone
Hi, yes and no, you can change the return type though. Cheers, Hartwig -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72458#72458 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_object macro returning osg::Object* for cloneType and clone
clone and cloneType are polymorphic so you can't change their prototype... hartwigw wrote: > Hi, > > is there any reason why clone(const omg::CopyOp&) and cloneType() are > returning osg::Object* and not name*? > Does changing the macro break any existing code? I do not think so but may be > that I am overlooking something. > > Thank you! > > Cheers, > Hartwig -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72456#72456 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] META_object macro returning osg::Object* for cloneType and clone
Hi, is there any reason why clone(const omg::CopyOp&) and cloneType() are returning osg::Object* and not name*? Does changing the macro break any existing code? I do not think so but may be that I am overlooking something. Thank you! Cheers, Hartwig -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=72455#72455 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_OBJECT
Hi all, Those methods are defined by the "META_Object" macro ( osg/Object header ) Not completely sure because I do not have a great experience with osgCompute, but I used the "find" utility and can't find META_OBJECT (all capitals) in the osgCompute trunk dir Regards, Martino 2013/4/29 Thomas Hogarth > hi > > Posting what META_OBJECT defines will help, but the clue is here > > /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:23:4: > error: cannot declare parameter ?? to be of abstract type > ?osgOpenCL::osgOpenCLContext? > /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:18:23: > note: because the following virtual functions are pure within > ?osgOpenCL::osgOpenCLContext?: > > You have some pure virtual functions somewhere, then other code is trying > to allocate an instance of a class with pure virtual functions which is not > allowed. > > Tom > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=53855#53855 > > > > > > ___ > 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
Re: [osg-users] META_OBJECT
hi Posting what META_OBJECT defines will help, but the clue is here /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:23:4: error: cannot declare parameter ?? to be of abstract type ?osgOpenCL::osgOpenCLContext? /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:18:23: note: because the following virtual functions are pure within ?osgOpenCL::osgOpenCLContext?: You have some pure virtual functions somewhere, then other code is trying to allocate an instance of a class with pure virtual functions which is not allowed. Tom -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53855#53855 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_OBJECT
Ah. I see now that you're asking about how to use a macro that is defined in a project external to OSG. Sorry for my confusion. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_OBJECT
Hi again, I should have posted the whole compilation error in the previous post. Here it goes: Code: sajjad@sajjad-G74Sx:~/Downloads/OpenSceneGraph/osgCompute/osgCompute$ make [ 15%] Built target osgCompute [ 25%] Built target osgCuda [ 32%] Built target osgCudaUtil [ 55%] Built target osgdb_serializers_osgCuda [ 57%] Built target osgCudaStats [ 60%] Built target osgCudaInit [ 62%] Building CXX object src/osgOpenCL/CMakeFiles/osgOpenCL.dir/osgOpenCLContext.cpp.o In file included from /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:10:0: /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:23:16: error: ‘osgOpenCL’ is not a type /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:23:42: error: ISO C++ forbids declaration of ‘META_OBJECT’ with no type [-fpermissive] /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:23:4: error: cannot declare parameter ‘’ to be of abstract type ‘osgOpenCL::osgOpenCLContext’ /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:18:23: note: because the following virtual functions are pure within ‘osgOpenCL::osgOpenCLContext’: /usr/local/include/osg/Object:71:25: note: virtual osg::Object* osg::Object::cloneType() const /usr/local/include/osg/Object:75:25: note: virtual osg::Object* osg::Object::clone(const osg::CopyOp&) const /usr/local/include/osg/Object:82:29: note: virtual const char* osg::Object::libraryName() const /usr/local/include/osg/Object:86:29: note: virtual const char* osg::Object::className() const /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp: In member function ‘bool osgOpenCL::osgOpenCLContext::setupOsgOpenCLAndViewer(osgViewer::ViewerBase&, int)’: /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:26: error: expected type-specifier before ‘GraphicsWindowX11’ /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:26: error: expected ‘>’ before ‘GraphicsWindowX11’ /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:26: error: expected ‘(’ before ‘GraphicsWindowX11’ /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:26: error: ‘GraphicsWindowX11’ was not declared in this scope /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:26: note: suggested alternative: /usr/local/include/osgViewer/api/X11/GraphicsWindowX11:30:24: note: ‘osgViewer::GraphicsWindowX11’ /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:44: error: expected primary-expression before ‘>’ token /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:50: error: expected ‘)’ before ‘;’ token /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:121:51: error: ‘class osg::GraphicsContext’ has no member named ‘getGLXContext’ /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:122:39: error: ‘class osg::GraphicsContext’ has no member named ‘getDisplay’ make[2]: *** [src/osgOpenCL/CMakeFiles/osgOpenCL.dir/osgOpenCLContext.cpp.o] Error 1 make[1]: *** [src/osgOpenCL/CMakeFiles/osgOpenCL.dir/all] Error 2 make: *** [all] Error 2 Thank you! Cheers, Sajjadul -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53851#53851 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_OBJECT
Hi, If you take a look into the Resource of osgCompute you will also find that they have declared META_OBJECT as all caps and they have the declared the copy constructor in the private scope and they are not defined in the source, i find this strange though.But It compiled fine. Now i am extending the this plugin and i am having error while trying to compile the following class. (Now i am including the while class definition). Code: #ifndef OSGOPENCL_CONTEXT #define OSGOPENCL_CONTEXT 1 #include #include #include #include #include #include #include namespace osgOpenCL { class LIBRARY_EXPORT osgOpenCLContext : public osg::Object { public: osgOpenCLContext(); META_OBJECT(osgOpenCL,osgOpenCLContext); bool setupOsgOpenCLAndViewer(osgViewer::ViewerBase &viewer, int ctxID = -1); ~osgOpenCLContext(); public: //typedef the list of the device within the context //IN THIS INITIAL VERSION WE ARE ONLY CONSIDERING ONE DEVICE ON ONE CONTEXT //SO COMMENT THE FOLLOWING //typedef std::vector > osgOpenCLDeviceList; //declare the device list //osgOpenCLDeviceList m_osgOpenCLDeviceList; //hold the current OpenCL context cl_context m_clContext; //hold the current platform id cl_platform_id m_clPlatform; //hold the current device id cl_device_id m_clDevice; //hold the command queue for the device cl_command_queue m_clCommandQueue; private: // Copy constructor and operator should not be called osgOpenCLContext(const osgOpenCLContext& ,const osg::CopyOp& ) {} osgOpenCLContext &operator=(const osgOpenCLContext&) { return *this; } }; } #endif Any more idea to get around this issue? Cheers, Sajjadul -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53850#53850 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_OBJECT
I'm not sure what "META_OBJECT" (all caps) is, or where it's defined. Did you intend to use "META_Object" from include/osg/Object instead? One other possible issue I noted: Assuming you intended to use META_Object, I believe you are required to implement the copy constructor, and I don't see that in your code... On Sun, Apr 28, 2013 at 6:38 AM, Sajjadul Islam wrote: > Hi forum, > > I am extending a osg::Object as follows: > > > Code: > > class LIBRARY_EXPORT osgOpenCLContext : public osg::Object > { > public: > osgOpenCLContext(); > > META_OBJECT(osgOpenCL,osgOpenCLContext); > > > bool setupOsgOpenCLAndViewer(osgViewer::ViewerBase > &viewer, > int ctxID = -1); > > ~osgOpenCLContext(); > > }; > > > > > And i am getting the following error among many others: > > > Code: > > [ 62%] Building CXX object > src/osgOpenCL/CMakeFiles/osgOpenCL.dir/osgOpenCLContext.cpp.o > In file included from > /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:7:0: > /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:22:16: > error: ‘osgOpenCL’ is not a type > /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:22:42: > error: ISO C++ forbids declaration of ‘META_OBJECT’ with no type > [-fpermissive] > > > > > > Any idea folks ? i used to know that META_Object and META_Node are just > convenience macro's that help streamline > the writing of subclasses, have a look at their definition to see what they > do. The methods that these macros implement are useful for implementing IO > and other ops that require richer RTTI info that C++ provides by default. > > Please fill out if i miss anything in the process > > Thank you! > > Cheers, > Sajjadul > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=53846#53846 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- Paul Martz Skew Matrix Software LLC ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] META_OBJECT
Hi forum, I am extending a osg::Object as follows: Code: class LIBRARY_EXPORT osgOpenCLContext : public osg::Object { public: osgOpenCLContext(); META_OBJECT(osgOpenCL,osgOpenCLContext); bool setupOsgOpenCLAndViewer(osgViewer::ViewerBase &viewer, int ctxID = -1); ~osgOpenCLContext(); }; And i am getting the following error among many others: Code: [ 62%] Building CXX object src/osgOpenCL/CMakeFiles/osgOpenCL.dir/osgOpenCLContext.cpp.o In file included from /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:7:0: /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:22:16: error: ‘osgOpenCL’ is not a type /home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:22:42: error: ISO C++ forbids declaration of ‘META_OBJECT’ with no type [-fpermissive] Any idea folks ? i used to know that META_Object and META_Node are just convenience macro's that help streamline the writing of subclasses, have a look at their definition to see what they do. The methods that these macros implement are useful for implementing IO and other ops that require richer RTTI info that C++ provides by default. Please fill out if i miss anything in the process Thank you! Cheers, Sajjadul -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53846#53846 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_OBJECT
Hi Sajjadul 2013/4/27 Sajjadul Islam > Hi forum, > > Is that mandatory to declare the META_OBJECT() for every class > declaration that derives from osg::Object ? > > What is its purpose? How to decide the parameters inside it ? > > Copied from reference manuals: "META_Object macro define the standard clone, isSameKindAs and className methods. Use when subclassing from Object to make it more convenient to define the standard pure virtual clone, isSameKindAs and className methods which are required for all Object subclasses." > Is the osg reference site down ? trying to access the osg::Object > reference > > We were changing the main web to the new joomla site, and I missed to update the reference docs URL. Now it should be online. Cheers. > Thank you! > > Regards > Sajjadul > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=53836#53836 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- Jordi Torres Fabra gvSIG 3D blog http://gvsig3d.blogspot.com ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] META_OBJECT
Hi forum, Is that mandatory to declare the META_OBJECT() for every class declaration that derives from osg::Object ? What is its purpose? How to decide the parameters inside it ? Is the osg reference site down ? trying to access the osg::Object reference Thank you! Regards Sajjadul -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53836#53836 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] META_Object definition
Hi Kim, META_Object and META_Node are just convenience macro's that help streamline the writing of subclasses, have a look at their definition to see what they do. The methods that these macros implement are useful for implementing IO and other ops that require richer RTTI info that C++ provides by default. Robert. On Tue, Apr 8, 2008 at 1:11 PM, Kim C Bale <[EMAIL PROTECTED]> wrote: > Hi all, > > > > I've started to inherit from some of the core osg classes to modify their > functionality and I noticed the use of this META_Object definition in > headers. Now I traced this back to its definition in osg::Object and I just > wanted to clarify its use. > > > > To give a bit of background I am currently inheriting from > osgParticle::ParticleSystem in order to override it's update function. Am I > right in thinking that the META_Object call is just a convenience definition > that define the set of copy operations? If so, does it need to be included > in the classes I create that inherit from the osg library? > > > > Regards to you all, > > > > Kim. > > > * > To view the terms under which this email is distributed, please go to > http://www.hull.ac.uk/legal/email_disclaimer.html > > * > ___ > 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
[osg-users] META_Object definition
Hi all, I've started to inherit from some of the core osg classes to modify their functionality and I noticed the use of this META_Object definition in headers. Now I traced this back to its definition in osg::Object and I just wanted to clarify its use. To give a bit of background I am currently inheriting from osgParticle::ParticleSystem in order to override it's update function. Am I right in thinking that the META_Object call is just a convenience definition that define the set of copy operations? If so, does it need to be included in the classes I create that inherit from the osg library? Regards to you all, Kim. * To view the terms under which this email is distributed, please go to http://www.hull.ac.uk/legal/email_disclaimer.html *___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org