In our previous implementation of the ParameterModifier feature, ParameterModifier had two methods, setParameter and getParameter. The subclasses of ParameterModifier were responsible for creating a method to add the specialized parameter(s) to the Sweep object. For example, rpc::Iterator has a virtual method called addParameterTypes, which is called by rpc::Sweep in its constructor method to add any specialized sweep parameters from the Iterator. This was OK, but I felt like it would be more appropriate if ParameterModifier itself contained a (virtual) method that was responsible for adding the specialized sweep parameters to the Sweep object. This way, all of the operations that are necessary for a ParameterModifier to work properly are actually laid out in the base class, rather than being left for the subclasses to define separately. This change will also make future development on the thin film code easier, so I decided to make the change.
The primary barrier to making this change was that the ParameterModifier needed to know the class type of the Sweep object to which it should send its ParameterTypes. In the pscf namespace, the only Sweep class is the SweepTmpl<State> template class, which requires a template parameter that we do not know. Therefore, it is easier to find a way for the ParameterModifier to send its ParameterTypes without any knowledge of the Sweep object. This is achieved in this pull request by the method ParameterModifier::getParameterTypes(), which requires no input parameters and returns a DArray<ParameterType> that contains all of the ParameterType objects associated with this ParameterModifier. A Sweep object must then have a method called addParameterTypes(DArray<ParameterType>) that can accept a DArray of ParameterType objects and add them all to its own parameterTypes_ array. Then, the Sweep class can retrieve the ParameterType objects from the Iterator with one line of code, just as it did before:
addParameterTypes(system().iterator().getParameterTypes())
This change is preferable over the previous version of ParameterModifier, because now the ParameterModifier does not need to know anything about the system's Sweep object, and because it now contains a virtual method getParameterTypes() that defines the way in which subclasses will provide their ParameterType objects to the Sweep.
In our previous implementation of the
ParameterModifier
feature,ParameterModifier
had two methods,setParameter
andgetParameter
. The subclasses ofParameterModifier
were responsible for creating a method to add the specialized parameter(s) to theSweep
object. For example,rpc::Iterator
has a virtual method calledaddParameterTypes
, which is called byrpc::Sweep
in its constructor method to add any specialized sweep parameters from theIterator
. This was OK, but I felt like it would be more appropriate ifParameterModifier
itself contained a (virtual) method that was responsible for adding the specialized sweep parameters to theSweep
object. This way, all of the operations that are necessary for aParameterModifier
to work properly are actually laid out in the base class, rather than being left for the subclasses to define separately. This change will also make future development on the thin film code easier, so I decided to make the change.The primary barrier to making this change was that the
ParameterModifier
needed to know the class type of theSweep
object to which it should send itsParameterTypes
. In thepscf
namespace, the onlySweep
class is theSweepTmpl<State>
template class, which requires a template parameter that we do not know. Therefore, it is easier to find a way for theParameterModifier
to send itsParameterTypes
without any knowledge of theSweep
object. This is achieved in this pull request by the methodParameterModifier::getParameterTypes()
, which requires no input parameters and returns aDArray<ParameterType>
that contains all of theParameterType
objects associated with thisParameterModifier
. ASweep
object must then have a method calledaddParameterTypes(DArray<ParameterType>)
that can accept aDArray
ofParameterType
objects and add them all to its ownparameterTypes_
array. Then, theSweep
class can retrieve theParameterType
objects from theIterator
with one line of code, just as it did before:addParameterTypes(system().iterator().getParameterTypes())
This change is preferable over the previous version of
ParameterModifier
, because now theParameterModifier
does not need to know anything about the system'sSweep
object, and because it now contains a virtual methodgetParameterTypes()
that defines the way in which subclasses will provide their ParameterType objects to the Sweep.All unit tests have been ran, and they all pass.