ShapeAttribute
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2007 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGSIM_SHAPEATTRIBUTE
#define OSGSIM_SHAPEATTRIBUTE 1
#include <osg/Object>
#include <osg/MixinVector>
#include <osgSim/Export>
namespace osgSim
{
class OSGSIM_EXPORT ShapeAttribute
{
public:
enum Type
{
UNKNOWN,
INTEGER,
DOUBLE,
STRING
};
ShapeAttribute();
ShapeAttribute(const char * name);
ShapeAttribute(const char * name, int value);
ShapeAttribute(const char * name, double value);
ShapeAttribute(const char * name, const char * value);
ShapeAttribute(const ShapeAttribute & sa);
~ShapeAttribute();
ShapeAttribute& operator = (const ShapeAttribute& sa);
int compare(const osgSim::ShapeAttribute& sa) const;
inline bool operator == (const osgSim::ShapeAttribute& sa) const { return compare(sa)==0; }
inline bool operator != (const osgSim::ShapeAttribute& sa) const { return compare(sa)!=0; }
inline bool operator < (const osgSim::ShapeAttribute& sa) const { return compare(sa)<0; }
const std::string & getName() const { return _name; }
void setName(const std::string& name) { _name = name; }
Type getType() const { return _type; }
int getInt() const { return _integer; }
double getDouble() const { return _double; }
const char * getString() const { return _string; }
void setValue(int value) { free(); _type = INTEGER; _integer = value; }
void setValue(double value) { free(); _type = DOUBLE; _double = value; }
void setValue(const char * value);
private:
void free();
void copy(const ShapeAttribute& sa);
std::string _name;
Type _type;
union
{
int _integer;
double _double;
char* _string;
};
};
class OSGSIM_EXPORT ShapeAttributeList : public osg::Object, public osg::MixinVector<ShapeAttribute>
{
public:
META_Object(osgSim, ShapeAttributeList)
ShapeAttributeList():
Object()
{}
ShapeAttributeList(const ShapeAttributeList& sal,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
osg::Object(sal, copyop),
osg::MixinVector<ShapeAttribute>(sal)
{
}
virtual int compare(const osgSim::ShapeAttributeList& sal) const;
protected:
virtual ~ShapeAttributeList() {}
};
}
#endif // ** SHAPEATTRIBUTE_ ** //
MixinVector
Object
osgSim::ShapeAttributeList
Definition ShapeAttribute:103
osgSim::ShapeAttributeList::ShapeAttributeList
ShapeAttributeList(const ShapeAttributeList &sal, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition ShapeAttribute:113
osgSim::ShapeAttributeList::~ShapeAttributeList
virtual ~ShapeAttributeList()
Definition ShapeAttribute:123
osgSim::ShapeAttributeList::META_Object
META_Object(osgSim, ShapeAttributeList) ShapeAttributeList()
Definition ShapeAttribute:105
osgSim::ShapeAttributeList::compare
virtual int compare(const osgSim::ShapeAttributeList &sal) const
osgSim::ShapeAttribute
Definition ShapeAttribute:26
osgSim::ShapeAttribute::ShapeAttribute
ShapeAttribute(const char *name, const char *value)
osgSim::ShapeAttribute::setValue
void setValue(int value)
Set an integer attribute data.
Definition ShapeAttribute:77
osgSim::ShapeAttribute::_integer
int _integer
Definition ShapeAttribute:96
osgSim::ShapeAttribute::~ShapeAttribute
~ShapeAttribute()
osgSim::ShapeAttribute::setName
void setName(const std::string &name)
Set the attribute name.
Definition ShapeAttribute:62
osgSim::ShapeAttribute::ShapeAttribute
ShapeAttribute(const char *name, double value)
osgSim::ShapeAttribute::compare
int compare(const osgSim::ShapeAttribute &sa) const
osgSim::ShapeAttribute::Type
Type
ShapeAttribute data type.
Definition ShapeAttribute:30
osgSim::ShapeAttribute::STRING
@ STRING
Definition ShapeAttribute:34
osgSim::ShapeAttribute::DOUBLE
@ DOUBLE
Definition ShapeAttribute:33
osgSim::ShapeAttribute::INTEGER
@ INTEGER
Definition ShapeAttribute:32
osgSim::ShapeAttribute::UNKNOWN
@ UNKNOWN
Definition ShapeAttribute:31
osgSim::ShapeAttribute::getInt
int getInt() const
Get the attribute data as an int.
Definition ShapeAttribute:68
osgSim::ShapeAttribute::_double
double _double
Definition ShapeAttribute:97
osgSim::ShapeAttribute::_string
char * _string
Definition ShapeAttribute:98
osgSim::ShapeAttribute::getType
Type getType() const
Get the attribute data type.
Definition ShapeAttribute:65
osgSim::ShapeAttribute::getString
const char * getString() const
Get the attribute data as a string.
Definition ShapeAttribute:74
osgSim::ShapeAttribute::ShapeAttribute
ShapeAttribute(const char *name, int value)
osgSim::ShapeAttribute::setValue
void setValue(double value)
Set a double attribute data.
Definition ShapeAttribute:80
osgSim::ShapeAttribute::getName
const std::string & getName() const
Get the attribute name.
Definition ShapeAttribute:59
osgSim::ShapeAttribute::ShapeAttribute
ShapeAttribute(const char *name)
osgSim::ShapeAttribute::setValue
void setValue(const char *value)
Set a string attribute data.
osgSim::ShapeAttribute::ShapeAttribute
ShapeAttribute()
osgSim::ShapeAttribute::getDouble
double getDouble() const
Get the attribute data as a double.
Definition ShapeAttribute:71
osgSim::ShapeAttribute::ShapeAttribute
ShapeAttribute(const ShapeAttribute &sa)
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::MixinVector
Definition MixinVector:29
osg::MixinVector< ShapeAttribute >::MixinVector
MixinVector()
Definition MixinVector:45
osg::Object
Definition Object:61
osg::Object::Object
Object()
Definition Object:69
osgSim
Definition BlinkSequence:27
osg
Definition AlphaFunc:19
Export
OSGSIM_EXPORT
#define OSGSIM_EXPORT
Definition osgSim/Export:38