elementsmain.cpp

来自「series60 应用程序开发的源代码 series60 应用程序开发的源代码」· C++ 代码 · 共 87 行

CPP
87
字号
/**
*
* @brief Main entry point for the Elements project
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDE FILES

// Class include
#include "elementsmain.h"

// System includes
#include <e32cons.h>

// User includes
#include "chemicalelement.h"
#include "elementsengine.h"

// ================= MEMBER FUNCTIONS =======================


namespace //Anonymous namespace has local file scope
{
    CConsoleBase* console;

    void DoExampleL()
    {
        //construct and install the active scheduler
        CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
        CleanupStack::PushL(scheduler);
        CActiveScheduler::Install(scheduler);

        //construct the new element engine
        CElementsEngine* elementEngine = CElementsEngine::NewLC(*console);    //remains on cleanup stack

        elementEngine->LoadFromCsvFilesL();                //Issue the request...
        CActiveScheduler::Start();                        //...then start the scheduler

        CleanupStack::PopAndDestroy(2, scheduler);        //elementEngine, scheduler
    }

    void DoMainL()
    {
        const TSize consoleSize(KConsFullScreen, KConsFullScreen);

        console = Console::NewL(KTxtSeries60Elements, consoleSize);
        CleanupStack::PushL(console);

        TRAPD(error, DoExampleL()); // perform example function

        if (error)
        {
            console->Printf(KFormatTxtFailed, error);
        }
        else
        {
            console->Printf(KTxtOK);
        }

        console->Printf(KTxtPressAnyKey);
        console->Getch(); // get and ignore character

        CleanupStack::PopAndDestroy(console);
    }

};


GLDEF_C TInt E32Main() // main function called by E32
{
    __UHEAP_MARK;

    CTrapCleanup* cleanup = CTrapCleanup::New(); // get clean-up stack
    TRAPD(error, DoMainL()); // more initialization, then do example
    delete cleanup; // destroy clean-up stack
    __ASSERT_ALWAYS(!error, User::Panic(KTxtElements, error));

    __UHEAP_MARKEND;
    return 0; // and return
}


// End of File

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?