PrevNextUpHome SophiaFramework UNIVERSE 5.3

10.3. Application

10.3.1. What is Application?

The Application class is the main class of SophiaFramework application and is generated automatically by SophiaFramework Appwizard.

The first Window instance is created in the Application class.

Example 10.9. Implement the Application Class

// Constructor
ExampleAppli::ExampleAppli(Void) static_throws
{
    // create the window
    // 1st argument: SFRTitleWindow's parent ( application class )
    new SFRTitleWindow(this, ・・・ arguments are omitted ・・・ );

    return;
}

Since the variables of Application class can be accessed from anywhere using the SFRApplication::GetInstance function, global variables can be defined inside the Application class.

Example 10.10. Method to Access the Instance Variables of Application Class

//
// ExampleAppli Application class is automatically generated by SophiaFramework AppWizard
//
SFMTYPEDEFCLASS(ExampleAppli)
class ExampleAppli : public SFRApplication {
    SFMSEALCOPY(ExampleAppli)
public:
    static SFCInvokerPtr Factory(Void);
private:
    ExampleAppli(Void) static_throws;
    virtual ~ExampleAppli(Void);
    
    // *** added code
    SInt32 global_something_val;
public:
    SInt32 GetGlobalSomethingVal();
};

ExampleAppli::GetGlobalSomethingVal(Void)
{
    return global_something_val;
}

// get global_something_val
static_cast<ExampleAppli>(SFRApplication::GetInstance())->GetGlobalSomethingVal();

Many of functions for Window class are also available in the Application class.

Reference: Development with SFR GUI Framework: Application

10.3.2. Event Handler

The event handler of Aplication class is automatically generated by SophiaFramework Appwizard.

Figure 10.10. Appwizard (Event handler generation part)

Appwizard (Event handler generation part)

The SFEVT_APP_START and SFEVT_APP_STOP are the BREW standard events that occur respectively when the application starts and terminates.