Moved the set/getName() support from osg::Node etc into the osg::Obejct

base class
This commit is contained in:
Robert Osfield
2005-06-08 13:16:19 +00:00
parent 69cd27e37f
commit 27c4c6a956
19 changed files with 135 additions and 122 deletions

View File

@@ -90,16 +90,7 @@ class OSG_EXPORT Node : public Object
/** Traverse upwards : calls parents' accept method with NodeVisitor.*/
virtual void ascend(NodeVisitor& nv);
/** Traverse downwards : calls children's accept method with NodeVisitor.*/
virtual void traverse(NodeVisitor& /*nv*/) {}
/** Set the name of node using C++ style string.*/
inline void setName( const std::string& name ) { _name = name; }
/** Set the name of node using a C style string.*/
inline void setName( const char* name ) { _name = name; }
/** Get the name of node.*/
inline const std::string& getName() const { return _name; }
virtual void traverse(NodeVisitor& /*nv*/) {}
/** A vector of osg::Group pointers which is used to store the parent(s) of node.*/
typedef std::vector<Group*> ParentList;
@@ -313,8 +304,6 @@ class OSG_EXPORT Node : public Object
mutable BoundingSphere _boundingSphere;
mutable bool _boundingSphereComputed;
std::string _name;
void addParent(osg::Group* node);
void removeParent(osg::Group* node);

View File

@@ -18,6 +18,8 @@
#include <osg/CopyOp>
#include <osg/ref_ptr>
#include <string>
namespace osg {
// forward declare
@@ -74,6 +76,16 @@ class OSG_EXPORT Object : public Referenced
virtual const char* className() const = 0;
/** Set the name of object using C++ style string.*/
inline void setName( const std::string& name ) { _name = name; }
/** Set the name of object using a C style string.*/
inline void setName( const char* name ) { _name = name; }
/** Get the name of object.*/
inline const std::string& getName() const { return _name; }
enum DataVariance
{
DYNAMIC,
@@ -121,8 +133,8 @@ class OSG_EXPORT Object : public Referenced
= new Node().*/
virtual ~Object() {}
std::string _name;
DataVariance _dataVariance;
ref_ptr<Referenced> _userData;
private:

View File

@@ -100,11 +100,6 @@ class OSG_EXPORT Program : public osg::StateAttribute
/** Query InfoLog from a glProgram */
bool getGlProgramInfoLog(unsigned int contextID, std::string& log) const;
/** A name for use by the application */
void setName( const std::string& name ) { _name = name; }
void setName( const char* name ) { _name = name; }
const std::string& getName() const { return _name; }
/** Mark internal glProgram for deletion.
* Deletion requests are queued until they can be executed
* in the proper GL context. */
@@ -221,7 +216,7 @@ class OSG_EXPORT Program : public osg::StateAttribute
virtual ~Program();
protected: /*data*/
std::string _name;
mutable osg::buffered_value< osg::ref_ptr<PerContextProgram> > _pcpList;
AttribBindingList _attribBindingList;

View File

@@ -92,11 +92,6 @@ class OSG_EXPORT Shader : public osg::Object
/** Query InfoLog from a glShader */
bool getGlShaderInfoLog(unsigned int contextID, std::string& log) const;
/** A name for use by the application */
void setName( const std::string& name ) { _name = name; }
void setName( const char* name ) { _name = name; }
const std::string& getName() const { return _name; };
/** Mark internal glShader for deletion.
* Deletion requests are queued tuntil they can be executed
* in the proper GL context. */
@@ -162,7 +157,6 @@ class OSG_EXPORT Shader : public osg::Object
protected: /*data*/
Type _type;
std::string _name;
std::string _shaderSource;
/** osg::Programs that this osg::Shader is attached to */
typedef std::set< Program* > ProgramSet;

View File

@@ -179,15 +179,15 @@ class OSG_EXPORT Uniform : public Object
/** Set the type of glUniform. */
bool setType( Type t );
bool setName( const std::string& name );
/** Get the name of glUniform. */
const std::string& getName() const { return _name; }
/** Get the type of glUniform as enum. */
const Type getType() const { return _type; }
/** Set the name of the glUniform, checking to make sure its only set once.*/
void setName( const std::string& name );
/** Return the name of a Type enum as string. */
static const char* getTypename( Type t );
@@ -344,7 +344,6 @@ class OSG_EXPORT Uniform : public Object
friend class osg::StateSet;
Type _type;
std::string _name;
union
{