Ulrich Hertlein wrote on 2009-12-31: 
> I have coded up a proposal for a general-purpose property system for
> osg::Object and would
> like to present it for comments and discussion.

Looks very cool!

> For data that is not derived from osg::Referenced (like floats, int,
> strings) instead of
> using a variant class I've created the following template class:
> 
> template <typename T> class Property : public Referenced {
> public:
>     //...
>     void set(const T& data) { _data = data; }
>     const T& get() const { return _data; }
>     T& get() { return _data; }
> private:
>     T _data;
> };
> 
> Data is stored like this:
> osg::Property<int>* ip = new osg::Property<int>(42);
> obj->setProperty("my.int", ip);
> 
> and retrieved like this:
> osg::Property<int>* ip0 = dynamic_cast<osg::Property<int> >(obj-
>> getProperty("my.int"));
> ip0->get() == 42;

The assignment and comparison syntax is a little odd; I think adding 
operator=(), operator==(), etc. to osg::Property would be better, so you could 
do

*obj->getProperty<int>("my.int") = 42;
if (*obj->getProperty<int>("my.int") == 42) { ...}

Thanks for the hard work, I'm looking forward to seeing this in OSG :)
--
Bryan Thrall
FlightSafety International
[email protected]
  

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to