Re: document class
On 26 Sep., 23:07, Joseph M. Newcomer <newco...@flounder.com> wrote:
See below...
I think the best would be to init a std::map for the xml file
information, so it should be really easy and fast to get the required
information.
void DisplayDialog::OnInitDialog()
{
CDisplay disp;
CString bright = disp.GetValue(NAME_OF_BRIGHTNESS);
}
class CProperty
{
public:
CProperty();
~CProperty();
virtual CString GetValue(const CString & name);
virtual void SetValue(const CString & name, const CString & valu=
e);
void SetValue(const CString & name, int value)
{
CString svalue;
svalue.Format(_T("%d"), value);
SetValue(name, svalue);
}
};
class CDisplay :
public CProperty
{
public:
CDisplay(void)
{
m_error = _T("Disp err: get value\n");
CDisplay::DISPLAY_BRIGHT.SetString(_T("B=
rightness"));
}
~CDisplay(void);
virtual CString GetValue(const CString & name)
{
if(name == CProperty::DISPLAY_BRIGHT)
return m_brightness;
else if(name == _T("contrast"))
return m_contrast;
****
Again, you are taking a simple problem and making it difficult. Why sh=
ould this node have
an m_contrast variable at all? Just ask its properties list for the va=
lue!
****
Ok that means the display class either do not store or have any values
(as brightness, contrast, or state)? If the displaydialog class tries
to get the brightness:
void CDisplayDlg::OnInitDialog(void)
{
CDisplay *pdisp;
pdisp = (CDisplay *)&pop;
CString brightness = pdisp->GetValue(_T("display:brightness"));
}
class CProperty
{
public:
CProperty();
~CProperty();
virtual CString GetValue(const CString & name);
virtual void SetValue(const CString & name, const CString & value);
void SetValue(const CString & name, int value)
{
CString svalue;
svalue.Format(_T("%d"), value);
SetValue(name, svalue);
}
};
class CDisplay :
public CProperty
{
public:
CDisplay(void);
~CDisplay(void);
void Init(void);
virtual CString GetValue(const CString & name)
{
CXml *p;
p = (CXml *)∝
CString value = p-
GetValue(name); //<- get specific value/name pair from the
std::map
return (value);
}
virtual void SetValue(const CString & name, const CString & value);
protected:
CProperty *prop;
};
Using three classes (CProperty, CDisplay, CXml) to get one value/name
pair back to the dialog-class seems to me very complex.