PrevNextUpHome BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1

8.2. Starting up of Application

The Onlybootup application do nothing except starting up. The code below is used to explain the processing when application is starting up.

Example 8.5. Onlybootup : .cpp file ( Boot Loader and Factory function )

//
//      Onlybootup.cpp
//
//      This source code was automatically
//      generated by SophiaFramework 4.1.
//

#include "Onlybootup.hpp"

// Boot Loader
SFCApplet::FactorySPP SFCApplet::Boot(AEECLSID id, SFXAnsiStringPtr license)
{
    *license = "heap://";

    return (id == AEECLSID_ONLYBOOTUP) ? (&Onlybootup::Factory) : (null);
}

// Factory function
SFCInvokerPtr Onlybootup::Factory(Void)
{
    return ::new Onlybootup;
}

// Constructor
Onlybootup::Onlybootup(Void) static_throws
{
    return;
}

// Destructor
Onlybootup::~Onlybootup(Void)
{
    return;
}

The Onlybootup class which inherits from SFRApplication class is the main part of application processing.

The Onlybootup application starts up by invoking the SFCApplet::Boot function called "Boot loader".

In the SFCApplet::Boot function, the license code corresponding to the ClassID is set, the address of Onlybootup::Factory function which generates the instance of Onlybootup class is then returned.

Next, the Onlybootup::Factory function is invoked, the instance of Onlybootup class is generated only once by the constructor of Onlybootup::Onlybootup function. Afterwards, the SFEVT_APP_START event is transmitted to the Onlybootup application, and the starting up of Onlybootup application is completed. When the Onlybootup application terminates, the instance of Onlybootup class is automatically destroyed.

* In SophiaFramework an Application class can be bound with two or more ClassIDs. The code in which multiple ClassIDs switches and binds with an application is shown below.

Example 8.6. Multiple applications boot up : .hpp file (class definition)

//
//      Twin.hpp
//
//      This source code was automatically
//      generated by SophiaFramework 4.1.
//

#ifndef __TWIN_HPP
#define __TWIN_HPP

#include <SophiaFramework.hpp>
#include "TwinA.bid"
#include "TwinB.bid"

SFMTYPEDEFCLASS(TwinA)
class TwinA : public SFRApplication {
    SFMSEALCOPY(TwinA)
public:
    static SFCInvokerPtr Factory(Void);
private:
    TwinA(Void) static_throws;
    virtual ~TwinA(Void);
};

SFMTYPEDEFCLASS(TwinB)
class TwinB : public SFRApplication {
    SFMSEALCOPY(TwinB)
public:
    static SFCInvokerPtr Factory(Void);
private:
    TwinB(Void) static_throws;
    virtual ~TwinB(Void);
};

#endif // __TWIN_HPP //

Example 8.7. Multiple applications start up : .cpp file (Boot Loader and Factory function)

//
//      Twin.cpp
//
//      This source code was automatically
//      generated by SophiaFramework 4.1.
//

#include "Twin.hpp"

// Boot Loader
SFCApplet::FactorySPP SFCApplet::Boot(AEECLSID id, SFXAnsiStringPtr license)
{
    SFCApplet::FactorySPP result(null);

    switch (id) {
    	case AEECLSID_TWINA:
             result = &TwinA::Factory;
             *license = "heap://"
                        "TIXDRQXNU5WHU8 .........
                        ......... LUGEW3U98TLDR8";
             break;
        case AEECLSID_TWINB:
             result = &TwinB::Factory;
             *license = "heap://"
                        "DHDV5CR1S4XASC ...........
                        ......... TQS6UHVFVEVLU3R";
             break;
	}
    return result;
}

// Factory function
SFCInvokerPtr TwinA::Factory(Void)
{
    return ::new TwinA;
}

// Constructor
TwinA::TwinA(Void) static_throws
{
    return;
}

// Destructor
TwinA::~TwinA(Void)
{
    return;
}

// Factory function
SFCInvokerPtr TwinB::Factory(Void)
{
    return ::new TwinB;
}

// Constructor
TwinB::TwinB(Void) static_throws
{
    return;
}

// Destructor
TwinB::~TwinB(Void)
{
    return;
}