Sample registry: use or not use

I am considering using a registry template in my application to store weak pointers in some windows and application panels. The following is the general structure of the application.

Application diagram

The application has one top-level window MainFrame with a small number of child windows inside it. Tabs like TabPane can have many tabs. I need to reference the ParamsPane panel from all TabPane tabs, so I need a pointer to a ParamsPane object that will be stored somewhere. There may be many options, but the most obvious are (1) saving the pointer inside the application's Singleton object, or (2) creating a simple registry class. Sort of:

class Registry {
public:
    static MainApp* application;
    static MainWindow* mainWindow;
};

Is this a good practice? What are the benefits and caveats of this approach?

+5
3

, ParamsPane. .

ParamsPane, TabPane .

, , , , , . , Model-View-Controller. ParamsPane TabPane . .

, .

, , TabPane, ParamsPane.

, , Singleton "Registry". , , , . , ( , ) - .

+2

, . :

, , . , , , , . PHP 5 ; - . , , .

, , , . , , : , . , , .

0

Your registry class and Singleton are OO methods of global variables. Prefer to make the Params panel in MainFrame and pass it as a tab link.

0
source

All Articles