Hello everyone,

Well im currently going through OpenScenGraph. i could not understand this piece of code:

class OSG_EXPORT Group : public Node
    public :

        /** Copy constructor using CopyOp to manage deep vs shallow copy. */
        Group(const Group&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);

        META_Node(osg, Group);
        ... // code coninues

Now, i could not understand 3 things here:

1) What does class OSG_EXPORT Group : public Node exactly mean(im referring to OSG_EXPORT) ?

2) i could not understand how this copy constructor is written:

Group(const Group&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);

3) and this:

META_Node(osg, Group); // what is META here?

Can anyone please help?

Edited by myk45: n/a

7 Years
Discussion Span
Last Post by myk45

1) I've seen something like this before:

class OSG_EXPORT Group : public Node

to indicate that the class is part of a specific library ( I think used for wrapping by other languages?)


Group(const Group&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);

I believe the first parameter is required and the second is optional, with a default value of CopyOp::SHALLOW_COPY (probably an enum).


META_Node(osg, Group); // what is META here?

I don't think META is separate from META_Node. This is probably a function or a macro.



1) This line:

class OSG_EXPORT Group : public Node

means that the class Group can be exported. This if because when you compile this code into a shared library (.so or .dll), you can export the entire class. This is rarely used in practice because there are binary compatibility problems with doing that. So, the "OSG_EXPORT" is simply a #define that is probably defined like this (not exactly, you can find it for yourself in their source code):

#define OSG_EXPORT __declspec(dllexport)
#define OSG_EXPORT __declspec(dllimport)

The above just means that the class' implementation will be exported from the dll it is compiled to, or imported from the dll it was compiled in (if you are using this code outside the source code of OSG).

2) This line:

Group(const Group&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);

just means that if you use the copy-constructor in the default way (i.e. Group g1(g2)), then, the copy will be a shallow copy (meaning the pointers or handles inside the Group object will be copied, but the memory or resources they refer to will not be duplicated; basically, both copies will share a pointer or handle to the same memory or resource). But this function also allows for an optional parameter to make it a deep-copy (probably used like so: Group g1(g2, CopyOp::DEEP_COPY)). The deep-copy refers to the opposite of the shallow-copy, that is, all the resources and memory are duplicated for the new copy of the object.

Personally, I find this approach very disturbing, you should not leave the user with the choice between deep or shallow copy.. but that's their prerogative.

3) META_Node is a MACRO (function-like #define). No doubts about that. Find it in the source code or documentation if you want to know what it does.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.