Parametered Devices

With Commands successfully using the Parametered class, it now remains to convert Devices to the use the new parameter system.

Devices have the added complication of needing to write their parameters to and read the values from the configuration file. To achieve this when the Device is constructed it is passed the pointer to the ConfigHolder. This pointer is passed down into the constructor of Parametered. When a parameter is stored if the pointer to ConfigHolder is not NULL, then WriteFile is called to cause the configuration file to be rewritten.

In the process of writing the file, the GetFirstParameter/GetNextParameter functions are used to traverse the list of parameters, and each one is written as an attribute to the Device element. On read back, the attributes of the Device elements are enumerated and iterated over and stored accordingly in the Device class.

I needed to add some extra logic in the ConfigHolder class to ensure that the file is not written while the file is being read, this would occur during startup, when the parameters are stored using SetParameter on the Device which has a valid ConfigHolder. A simple boolean member variable guarantees that while ConfigHolder is in the ReadFile method, WriteFile will short circuit and do nothing. There is a risk that information may get lost because of this flag, but I think it is minimal as the only time the configuration is read is during startup and at this time nothing should be trying to set parameters.

Subject: