14 #ifndef OSG_VALUEOBJECT
15 #define OSG_VALUEOBJECT 1
18 #include <osg/UserDataContainer>
19 #include <osg/BoundingBox>
20 #include <osg/BoundingSphere>
49 virtual ~GetValueVisitor() {}
50 virtual void apply(
bool ) {}
51 virtual void apply(
char ) {}
52 virtual void apply(
unsigned char ) {}
53 virtual void apply(
short ) {}
54 virtual void apply(
unsigned short ) {}
55 virtual void apply(
int ) {}
56 virtual void apply(
unsigned int ) {}
57 virtual void apply(
float ) {}
58 virtual void apply(
double ) {}
59 virtual void apply(
const std::string& ) {}
82 virtual void apply(
unsigned char& ) {}
84 virtual void apply(
unsigned short& ) {}
86 virtual void apply(
unsigned int& ) {}
89 virtual void apply(std::string& ) {}
106 virtual bool get(GetValueVisitor& )
const {
return false; }
113 template<
typename T >
116 static const char*
className() {
return "TemplateValueObject"; }
120 template<
typename T >
146 virtual bool get(GetValueVisitor& gvv)
const { gvv.apply(
_value);
return true; }
157 #define META_ValueObject(TYPE,NAME) \
158 template<> struct ValueObjectClassNameTrait<TYPE> { static const char* className() { return #NAME; } }; \
159 typedef TemplateValueObject<TYPE> NAME;
193 if (!udc) udc = _userDataContainer;
195 const UserValueObject* uvo = udc ?
dynamic_cast<const UserValueObject*
>(udc->
getUserObject(name)) : 0;
198 value = uvo->getValue();
216 getOrCreateUserDataContainer();
217 udc = _userDataContainer;
221 if (i<udc->getNumUserObjects()) udc->
setUserObject(i,
new UserValueObject(name,value));
bool getUserValue(const osg::NodePath &nodepath, const std::string &name, T &value)
TemplateValueObject(const std::string &name, const T &value)
const T & getValue() const
virtual void apply(unsigned short &)
virtual unsigned int getUserObjectIndex(const osg::Object *obj, unsigned int startPos=0) const =0
BoundingSphereImpl< Vec3d > BoundingSphered
void setUserValue(const std::string &name, const T &value)
META_ValueObject(std::string, StringValueObject) META_ValueObject(bool
virtual void apply(short &)
BoundingSphereImpl< Vec3f > BoundingSpheref
virtual void apply(int &)
static const char * s_TemplateValueObject_className
virtual void apply(osg::BoundingBoxf &)
virtual unsigned int addUserObject(Object *obj)=0
BoundingBoxImpl< Vec3f > BoundingBoxf
META_Object(osg, ValueObject) class GetValueVisitor
virtual void apply(double &)
virtual void apply(unsigned int &)
ValueObject(const ValueObject &rhs, const osg::CopyOp copyop=osg::CopyOp::SHALLOW_COPY)
virtual void apply(osg::BoundingBoxd &)
virtual void apply(osg::Vec2d &)
virtual Object * getUserObject(unsigned int i)=0
virtual void apply(osg::Vec2f &)
void setValue(const T &value)
virtual Object * clone(const CopyOp ©op) const
virtual void apply(osg::Vec4f &)
virtual void apply(bool &)
BoundingBoxImpl< Vec3d > BoundingBoxd
virtual void apply(osg::Matrixf &)
virtual void setName(const std::string &name)
static const char * className()
virtual void apply(osg::BoundingSphered &)
virtual const char * className() const
virtual void apply(std::string &)
virtual void apply(osg::Quat &)
virtual void apply(osg::Plane &)
ValueObject(const std::string &name)
A plane class. It can be used to represent an infinite plane.
virtual void apply(osg::Vec4d &)
TemplateValueObject(const TemplateValueObject &rhs, const osg::CopyOp copyop=osg::CopyOp::SHALLOW_COPY)
virtual void apply(osg::Vec3d &)
virtual ~TemplateValueObject()
virtual const char * libraryName() const
virtual void apply(osg::Vec3f &)
virtual bool set(SetValueVisitor &svv)
virtual ~SetValueVisitor()
virtual bool set(SetValueVisitor &)
virtual void setUserObject(unsigned int i, Object *obj)=0
virtual bool isSameKindAs(const Object *obj) const
virtual void apply(float &)
virtual void apply(unsigned char &)
virtual void apply(osg::Matrixd &)
virtual void apply(char &)
virtual Object * cloneType() const
virtual void apply(osg::BoundingSpheref &)