1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2007 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
14#ifndef OSGSIM_SHAPEATTRIBUTE
15#define OSGSIM_SHAPEATTRIBUTE 1
18#include <osg/MixinVector>
20#include <osgSim/Export>
25class OSGSIM_EXPORT ShapeAttribute
28 /// ShapeAttribute data type.
38 ShapeAttribute(const char * name);
39 ShapeAttribute(const char * name, int value);
40 ShapeAttribute(const char * name, double value);
42 /** Note, ShapeAttribute takes a copy of both name and value, the calling code should manage its own clean up of the original strings.*/
43 ShapeAttribute(const char * name, const char * value);
45 ShapeAttribute(const ShapeAttribute & sa);
49 ShapeAttribute& operator = (const ShapeAttribute& sa);
51 /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
52 int compare(const osgSim::ShapeAttribute& sa) const;
54 inline bool operator == (const osgSim::ShapeAttribute& sa) const { return compare(sa)==0; }
55 inline bool operator != (const osgSim::ShapeAttribute& sa) const { return compare(sa)!=0; }
56 inline bool operator < (const osgSim::ShapeAttribute& sa) const { return compare(sa)<0; }
58 /// Get the attribute name.
59 const std::string & getName() const { return _name; }
61 /// Set the attribute name.
62 void setName(const std::string& name) { _name = name; }
64 /// Get the attribute data type.
65 Type getType() const { return _type; }
67 /// Get the attribute data as an int.
68 int getInt() const { return _integer; }
70 /// Get the attribute data as a double.
71 double getDouble() const { return _double; }
73 /// Get the attribute data as a string.
74 const char * getString() const { return _string; }
76 /// Set an integer attribute data.
77 void setValue(int value) { free(); _type = INTEGER; _integer = value; }
79 /// Set a double attribute data.
80 void setValue(double value) { free(); _type = DOUBLE; _double = value; }
82 /// Set a string attribute data.
83 void setValue(const char * value);
89 void copy(const ShapeAttribute& sa);
102class OSGSIM_EXPORT ShapeAttributeList : public osg::Object, public osg::MixinVector<ShapeAttribute>
105 META_Object(osgSim, ShapeAttributeList)
107 ShapeAttributeList():
111 /** Copy constructor, optional CopyOp object can be used to control
112 * shallow vs deep copying of dynamic data.*/
113 ShapeAttributeList(const ShapeAttributeList& sal,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
114 osg::Object(sal, copyop),
115 osg::MixinVector<ShapeAttribute>(sal)
119 /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
120 virtual int compare(const osgSim::ShapeAttributeList& sal) const;
123 virtual ~ShapeAttributeList() {}
128#endif // ** SHAPEATTRIBUTE_ ** //