GUIアプリケーションを開発しています。メインウィンドウがあります。メイン ウィンドウには情報ウィンドウがあり、現在の操作の基本情報 (実行中の操作や所要時間など) が記録されます。コードは次のようなものです。
class InfoWindow
{
public:
InfoWindow();
void Record(const string& info);
};
class MainWindow
{
public:
void OperationInMainWindow()
{
// Perform the operation.
...
// Record the operation information (okay here since m_infoWindow is
// accessible.
m_infoWindow.Record(...);
}
private:
InfoWindow m_infoWindow;
// Many other windows. Other windows have also operations whose information
// need to record. And getting worse, the other windows have children
// windows who have to record operation information in the main window's
// info window.
OtherWindow1 m_otherWindow1; //
OtherWindow2 m_otherWindow2;
...
};
情報記録を簡単にするには?情報ウィンドウにシングルトンを使用しようとしましたが、情報ウィンドウの寿命はメインウィンドウによって制御される必要があるため、あまり満足できません。どうもありがとう!!!