V
Vincent RICHOMME
Hi,
I would like to learn a good object approach and to do so I have started
to design an application used to manage smart cards.
It's developped with a multi-plateform gui toolkit (wxWidgets)
You can see a screenshot here :
http://smartdev-info.com/IMG/png/SmartTester.png
As you can see a SmartCardProject is composed of
one or many Readers,
one or many Card and each card is composed of CardCmds
one or many script files
So I did this :
class SCardReader
{
public:
SCardReader(wxString strRealName,
wxString strUserName)
:m_strRealName(strRealName),
m_strUserName(strUserName)
{
}
wxString m_strRealName;
wxString m_strUserName;
};
WX_DEFINE_ARRAY(SCardReader*, SCardReaderArray);
/*----------------------------------------------------------*/
class SCardCmd
{
public:
SCardCmd(const wxString& strCmdName);
private:
wxString m_strCLA;
wxString m_strINS;
wxString m_strP1;
wxString m_strP2;
wxString m_strLc;
wxString m_strData;
wxString m_strLe;
wxString m_strResponse;
wxString m_strSW;
};
WX_DECLARE_HASH_MAP(wxString, SCardCmd*,
wxStringHash,wxStringEqual,SCardCmdHMap);
/*----------------------------------------------------------*/
class SCardDesc
{
public:
protected:
wxString strUserCardName;
SCardCmdHMap m_scCmds;
};
WX_DECLARE_HASH_MAP(wxString, SCardDesc*,
wxStringHash,wxStringEqual,SCardDescHMap);
class ProjDockBar;
class SCardPrj
{
public:
SCardPrj() {}
SCardPrj(ProjDockBar* pProjDockBar);
virtual ~SCardPrj();
void AddReader();
void AddCardDesc();
void AddCardCmd();
void AddCardCmd(const wxString& strCardName);
bool GetCardCmd(wxString strCardCmd, SCardCmd& refCardCmd);
protected:
void UpdateGUI();
SCardReaderArray m_scReaders;
SCardDescHMap m_scDesc;
PrjTree* m_pPrjTree;
};
#endif
My problem is about how can I associate my project and the GuiPart.
For now when someone right-click on a CardCommand item I offer the
choice to add a CardCommand, so I get a pointer on a Scardprj and I call
AddCardCmd and this method update the Gui by calling a method
belonging to my tree.
The flow is :
Gui(Project Tree) is requested to make a change --->SCardPrj is notified
and do the action ---> Update Gui
Is it the right way to do, actually since my Project Structure is almost
the same as its Gui counterpart(Tree), is there a mean of coupling these
two things ?
I would like to learn a good object approach and to do so I have started
to design an application used to manage smart cards.
It's developped with a multi-plateform gui toolkit (wxWidgets)
You can see a screenshot here :
http://smartdev-info.com/IMG/png/SmartTester.png
As you can see a SmartCardProject is composed of
one or many Readers,
one or many Card and each card is composed of CardCmds
one or many script files
So I did this :
class SCardReader
{
public:
SCardReader(wxString strRealName,
wxString strUserName)
:m_strRealName(strRealName),
m_strUserName(strUserName)
{
}
wxString m_strRealName;
wxString m_strUserName;
};
WX_DEFINE_ARRAY(SCardReader*, SCardReaderArray);
/*----------------------------------------------------------*/
class SCardCmd
{
public:
SCardCmd(const wxString& strCmdName);
private:
wxString m_strCLA;
wxString m_strINS;
wxString m_strP1;
wxString m_strP2;
wxString m_strLc;
wxString m_strData;
wxString m_strLe;
wxString m_strResponse;
wxString m_strSW;
};
WX_DECLARE_HASH_MAP(wxString, SCardCmd*,
wxStringHash,wxStringEqual,SCardCmdHMap);
/*----------------------------------------------------------*/
class SCardDesc
{
public:
protected:
wxString strUserCardName;
SCardCmdHMap m_scCmds;
};
WX_DECLARE_HASH_MAP(wxString, SCardDesc*,
wxStringHash,wxStringEqual,SCardDescHMap);
class ProjDockBar;
class SCardPrj
{
public:
SCardPrj() {}
SCardPrj(ProjDockBar* pProjDockBar);
virtual ~SCardPrj();
void AddReader();
void AddCardDesc();
void AddCardCmd();
void AddCardCmd(const wxString& strCardName);
bool GetCardCmd(wxString strCardCmd, SCardCmd& refCardCmd);
protected:
void UpdateGUI();
SCardReaderArray m_scReaders;
SCardDescHMap m_scDesc;
PrjTree* m_pPrjTree;
};
#endif
My problem is about how can I associate my project and the GuiPart.
For now when someone right-click on a CardCommand item I offer the
choice to add a CardCommand, so I get a pointer on a Scardprj and I call
AddCardCmd and this method update the Gui by calling a method
belonging to my tree.
The flow is :
Gui(Project Tree) is requested to make a change --->SCardPrj is notified
and do the action ---> Update Gui
Is it the right way to do, actually since my Project Structure is almost
the same as its Gui counterpart(Tree), is there a mean of coupling these
two things ?