Tools.h++ Class Reference

Table Of Contents
"Thermostat" and the "Dial": when the setting of the thermostat is changed, the dial must be
notified so that it can update itself to reflect the new setting of the thermostat.
#include <rw/model.h>
class Dial : public RWModelClient {
public:
virtual void updateFrom(RWModel* m, void* d);
};
class Thermostat : public RWModel {
double setting;
public:
Thermostat( Dial* d )
{ addDependent(d); }
double temperature() const
{ return setting; }
void setTemperature(double t)
{ setting = t; changed(); }
};
void Dial::updateFrom(RWModel* m, void*) {
Thermostat* t = (Thermostat*)m;
double temp = t->temperature();
// Redraw graphic.
}
Public Constructor
RWModel();
When called by the specializing class, sets up the internal ordered list of dependents.
Public Member Functions
void
addDependent(RWModelClient* m);
Adds the object pointed to by m to the list of dependents of self.
void
removeDependent(RWModelClient* m);
Removes the object pointed to by m from the list of dependents of self.
virtual void
changed(void* d);
Traverse the internal list of dependents, calling member function
updateFrom(RWModel*, void*) for each one, with self as the first argument and d as the