Erik Hofman wrote :
> James Turner wrote:
>
> > Basically, I can envisage lots of things the ChangeListener API is
> > perfect for, whether you're observing a value that changes one a week or
> > 50 times a second, but right now those things won't work because some %
> > of the properties don't tell you they've changed. Now, we could always
> > flag some properties as 'immediate' I suppose, but that seems like a 
> > hack. There's nothing wrong with the current API, we just ought to make
> > all the property nodes meet the contract it defines, or we need to
> > remove change listeners from the API and have everyone poll / update as
> > you suggest.
>
> Aren't the C++ opperators the perfect place to add this kind of action 
> to tied properties?

I had the same idea reading the message from James.
imagine that template (we are not against templates, aren't we ? ;) :

template <class T>
class tied_value
{
  public:
    tied_value() : node( 0 ) {}
    ~tied_value() : { untie(); }
    tie( SGPropertyNode_ptr n ) { node = n; n->tie( &val ); }
    untie() { node = 0; n->untie( &val ); }
    T operator=( const T &v ) { val = v; if (node) node->fireChangeListeners(); return 
*this; }
    operator T() { return val; }
  private:
    T val;
    SGPropertyNode_ptr node;
}

Then replace every tied values with that template :
  change :
    double xPos;
  into :
    tied_value<double> xPos;

You get the picture ?

One can use xPos as usual and when the data is changed, listeners are advertised.

( disclaimer : all the above is written from memory and is presumably
  incomplete )

Cheers,

-Fred



_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to