OpenSceneGraph 3.6.5
ShapeAttribute
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2007 Robert Osfield
2 *
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.
7 *
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.
12*/
13
14#ifndef OSGSIM_SHAPEATTRIBUTE
15#define OSGSIM_SHAPEATTRIBUTE 1
16
17#include <osg/Object>
18#include <osg/MixinVector>
19
20#include <osgSim/Export>
21
22namespace osgSim
23{
24
26{
27 public:
36
38 ShapeAttribute(const char * name);
39 ShapeAttribute(const char * name, int value);
40 ShapeAttribute(const char * name, double value);
41
43 ShapeAttribute(const char * name, const char * value);
44
46
48
49 ShapeAttribute& operator = (const ShapeAttribute& sa);
50
52 int compare(const osgSim::ShapeAttribute& sa) const;
53
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; }
57
59 const std::string & getName() const { return _name; }
60
62 void setName(const std::string& name) { _name = name; }
63
65 Type getType() const { return _type; }
66
68 int getInt() const { return _integer; }
69
71 double getDouble() const { return _double; }
72
74 const char * getString() const { return _string; }
75
77 void setValue(int value) { free(); _type = INTEGER; _integer = value; }
78
80 void setValue(double value) { free(); _type = DOUBLE; _double = value; }
81
83 void setValue(const char * value);
84
85
86 private:
87
88 void free();
89 void copy(const ShapeAttribute& sa);
90
91 std::string _name;
92 Type _type;
93
94 union
95 {
97 double _double;
98 char* _string;
99 };
100};
101
102class OSGSIM_EXPORT ShapeAttributeList : public osg::Object, public osg::MixinVector<ShapeAttribute>
103{
104 public:
110
114 osg::Object(sal, copyop),
116 {
117 }
118
120 virtual int compare(const osgSim::ShapeAttributeList& sal) const;
121
122 protected:
124};
125
126}
127
128#endif // ** SHAPEATTRIBUTE_ ** //
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
The osgSim library is a NodeKit that extends the core scene graph to support nodes and drawables that...
Definition BlinkSequence:27
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
MixinVector is a base class that allows inheritance to be used to easily emulate derivation from std:...
Definition MixinVector:29
MixinVector()
Definition MixinVector:45
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Object()
Construct an object.
Definition Object:69
Definition ShapeAttribute:26
ShapeAttribute(const char *name, const char *value)
Note, ShapeAttribute takes a copy of both name and value, the calling code should manage its own clea...
void setValue(int value)
Set an integer attribute data.
Definition ShapeAttribute:77
int _integer
Definition ShapeAttribute:96
void setName(const std::string &name)
Set the attribute name.
Definition ShapeAttribute:62
ShapeAttribute(const char *name, double value)
int compare(const osgSim::ShapeAttribute &sa) const
return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
Type
ShapeAttribute data type.
Definition ShapeAttribute:30
@ STRING
Definition ShapeAttribute:34
@ DOUBLE
Definition ShapeAttribute:33
@ INTEGER
Definition ShapeAttribute:32
@ UNKNOWN
Definition ShapeAttribute:31
int getInt() const
Get the attribute data as an int.
Definition ShapeAttribute:68
double _double
Definition ShapeAttribute:97
char * _string
Definition ShapeAttribute:98
Type getType() const
Get the attribute data type.
Definition ShapeAttribute:65
const char * getString() const
Get the attribute data as a string.
Definition ShapeAttribute:74
ShapeAttribute(const char *name, int value)
void setValue(double value)
Set a double attribute data.
Definition ShapeAttribute:80
const std::string & getName() const
Get the attribute name.
Definition ShapeAttribute:59
ShapeAttribute(const char *name)
void setValue(const char *value)
Set a string attribute data.
double getDouble() const
Get the attribute data as a double.
Definition ShapeAttribute:71
ShapeAttribute(const ShapeAttribute &sa)
Definition ShapeAttribute:103
ShapeAttributeList(const ShapeAttributeList &sal, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Copy constructor, optional CopyOp object can be used to control shallow vs deep copying of dynamic da...
Definition ShapeAttribute:113
virtual ~ShapeAttributeList()
Definition ShapeAttribute:123
META_Object(osgSim, ShapeAttributeList) ShapeAttributeList()
Definition ShapeAttribute:105
virtual int compare(const osgSim::ShapeAttributeList &sal) const
return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
#define OSGSIM_EXPORT
Definition Export:38

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.