
On May 20, 2007, at 3:06 PM, Johan Torp wrote:
I often find myself in the situation of wanting to listen to changes of a value type variable. I had a templated class called ConcreteObservable which encapsulated a get/set-able value and provided ways of listening to changes in the value. I.e. ConcreteObservable<bool> was a bool which you could get, set and listen to.
1. Does the idea of a listenable value seem sound to you or do you see any problems?
Looks good to me. You might consider a few minor additions: - A copy constructor for signalling_value, that just copies the underlying value - A copy assignment operator for signalling_value, that just copies the underlying value - A conversion to const T& (same functionality as get) - An assignment operator that takes a const T& (same functionality as set)
2. Is there any existing boost code that already provides this functionality?
Not that I know of.
3. Do you see any problems with my implementation?
Looks good!
4. Do you have a better naming suggestion? Is signalling (user code would read signalling<bool>), listenable or signal_value perhaps better?
Did you consider "observable_value"? Or even just "observable"? - Doug