1
我正在開發一個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;
...
};
如何使信息記錄更容易?我嘗試使用單身人士的信息窗口,但不是很滿意,因爲信息窗口的生活應該由主窗口控制。非常感謝!!!