Added copy operator to ShapeAttribute to prevent problems when assigned them or use within a vector

This commit is contained in:
Robert Osfield
2007-12-13 12:30:31 +00:00
parent 6cca3b8f49
commit b6f32a3ed0
2 changed files with 41 additions and 13 deletions

View File

@@ -41,11 +41,15 @@ class OSGSIM_EXPORT ShapeAttribute
ShapeAttribute(const char * name);
ShapeAttribute(const char * name, int value);
ShapeAttribute(const char * name, double value);
/** Note, ShapeAttribute takes a copy of both name and value, the calling code should manage its own clean up of the original strings.*/
ShapeAttribute(const char * name, const char * value);
ShapeAttribute(const ShapeAttribute & sa);
~ShapeAttribute();
ShapeAttribute& operator = (const ShapeAttribute& sa);
const std::string & getName() const { return _name; }
const Type getType() const { return _type; }
@@ -59,6 +63,9 @@ class OSGSIM_EXPORT ShapeAttribute
private:
void free();
void copy(const ShapeAttribute& sa);
std::string _name;
Type _type;
@@ -67,7 +74,7 @@ class OSGSIM_EXPORT ShapeAttribute
{
int _integer;
double _double;
char * _string;
char* _string;
};