Simplified media constructors for common media
Currently, there are lots of medium properties:
-
MediumData
that defines the continuous energy loss process -
IMediumModel
that defines density distribution and nuclei composition -
IMagneticFieldModel
that defines the magnetic field distribution
The current way to get properties is adding all those classes to the template, and then the constructed object can inherit those properties. But the final object will have class like MediumPropertyModel<UniformMagneticField<HomogeneousMedium<IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>>>>
My question is: can we use strategy design parttern to combine thoes properties? A small example here:
class MediumPropertyModel {
public:
void setMedium(Medium const medium) { medium_ = medium; }
void setIMediumModel(std::unique_ptr<IMediumModel> mediumModel) { mediumModel_ = std::move(mediumModel); }
// other setters...
Medium getMedium(Point const&) const { return medium_; }
MassDensityType getMassDensity(Point const& p) { return mediumModel_->getMassDensity(p); }
// other methods...
private:
Medium medium_;
std::unique_ptr<IMediumModel> mediumModel_;
// other properties...
}
I feel like such a structure is clear and easy to learn for beginer. What is the motivation behind current design?
Edited by Remy Prechelt