1. Design 1: Have an independent class to handle everything and "friend" it with the users.
Pro: Only 1 interface needed and we can switch interface easily.
Con: There is a lot of inter-class data which destroys encapsulation
class CalibratorXML;
class Device{
string sourceLabel;
string destLabel;
vector<CalPoint> calPoints;
friendclass CalibratorXML;
};
class Calibrator {
string readLabel;
string saveLabel;
std::vector<Device> devices;
friendclass CalibratorXML;
};
class CalibratorXML {
public:
staticvoid Read( Calibrator* cal );
staticvoid Write( Calibrator* cal );
private:
staticvoid ReadCalibrator( Calibrator* cal, TiXmlElement* calibrator );
staticvoid ReadDevice( Calibrator* cal, TiXmlElement* device );
staticvoid ReadCalPoint( Device* dev, TiXmlElement* calPoint );
// ... same for write
};
2. Encapsulate XML into the main classes. I think it's more organized, but makes it tougher to swap out for another interface and the class becomes less modular/generic.