13.07.2015 Views

Mali GPU User Interface Engine Application Development Guide

Mali GPU User Interface Engine Application Development Guide

Mali GPU User Interface Engine Application Development Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Tutorial on the System ClassesExample 2-3 Reading keyboard input...printf("Press ESC to continue\n");while (true){if (keyboard->getSpecialKeyState(MDE::Keyboard::KEY_ESCAPE)) break;}...keyboard->release();Because the Keyboard object in Example 2-2 on page 2-3 was not created with theManaged template, you must explicitly call release() on the keyboard interface.4. Example 2-4 shows the next stage of the application that deliberately raises an exceptionby trying to create a non-existent file system:Example 2-4 Basic exception handling...try{MDE::Managed fs = system->createFileSystem("non-existing root");fs->createInputStream("non-existing file");}}catch (MDE::Exception& e){printf("An expected exception was thrown:\n%s\n", e.getMessage().getCharString() );}You can put the standard C++ try blocks around code that you are testing.Exceptions generated by the UI <strong>Engine</strong> have types derived from MDE::Exception. Use acatch(MDE::Exception) statement to catch all exceptions generated by the UI <strong>Engine</strong>. Forexample code, ARM recommends putting a try block around all of the code in main() asshown in Example 2-5:Example 2-5 Using a try catch blockmain(){try{// all executable code}catch (MDE::Exception& e){// exception handling code}}5. Compile and run the project to test keyboard input and exception trapping. Figure 2-1 onpage 2-5 shows the system window:ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 2-4ID070710Non-Confidential - Draft - Beta

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!