From David Callu, added DBase attribute support for shapefiles
This commit is contained in:
101
include/osgSim/ShapeAttribute
Normal file
101
include/osgSim/ShapeAttribute
Normal file
@@ -0,0 +1,101 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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 <string>
|
||||
#include <vector>
|
||||
|
||||
#include <osg/Object>
|
||||
|
||||
|
||||
namespace osgSim
|
||||
{
|
||||
|
||||
class ShapeAttribute
|
||||
{
|
||||
public:
|
||||
|
||||
enum Type
|
||||
{
|
||||
UNKNOW,
|
||||
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();
|
||||
|
||||
|
||||
const std::string & getName() const { return _name; }
|
||||
const Type getType() const { return _type; }
|
||||
|
||||
int getInt() const { return _integer; }
|
||||
double getDouble() const { return _double; }
|
||||
const char * getString() const { return _string; }
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
int compare(const osgSim::ShapeAttribute& sa) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::string _name;
|
||||
Type _type;
|
||||
|
||||
union
|
||||
{
|
||||
int _integer;
|
||||
double _double;
|
||||
char * _string;
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
class ShapeAttributeList : public osg::Object, public std::vector<ShapeAttribute>
|
||||
{
|
||||
public:
|
||||
META_Object(osgSim, ShapeAttributeList)
|
||||
|
||||
ShapeAttributeList():
|
||||
Object()
|
||||
{}
|
||||
|
||||
/** Copy constructor, optional CopyOp object can be used to control
|
||||
* shallow vs deep copying of dynamic data.*/
|
||||
ShapeAttributeList(const ShapeAttributeList& sal,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
||||
osg::Object(sal, copyop)
|
||||
{
|
||||
copy(sal.begin(),sal.end(), begin());
|
||||
}
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const osgSim::ShapeAttributeList& sal) const;
|
||||
|
||||
protected:
|
||||
virtual ~ShapeAttributeList() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // ** SHAPEATTRIBUTE_ ** //
|
||||
Reference in New Issue
Block a user