Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DMBasicGUI by
Application/App.h@38:1b7c79a10e14, 2016-03-14 (annotated)
- Committer:
- redbird
- Date:
- Mon Mar 14 20:14:06 2016 -0600
- Revision:
- 38:1b7c79a10e14
- Parent:
- 10:651861441108
revert programming
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| embeddedartists | 1:46c8df4608c8 | 1 | /* |
| embeddedartists | 1:46c8df4608c8 | 2 | * Copyright 2014 Embedded Artists AB |
| embeddedartists | 1:46c8df4608c8 | 3 | * |
| embeddedartists | 1:46c8df4608c8 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| embeddedartists | 1:46c8df4608c8 | 5 | * you may not use this file except in compliance with the License. |
| embeddedartists | 1:46c8df4608c8 | 6 | * You may obtain a copy of the License at |
| embeddedartists | 1:46c8df4608c8 | 7 | * |
| embeddedartists | 1:46c8df4608c8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| embeddedartists | 1:46c8df4608c8 | 9 | * |
| embeddedartists | 1:46c8df4608c8 | 10 | * Unless required by applicable law or agreed to in writing, software |
| embeddedartists | 1:46c8df4608c8 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| embeddedartists | 1:46c8df4608c8 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| embeddedartists | 1:46c8df4608c8 | 13 | * See the License for the specific language governing permissions and |
| embeddedartists | 1:46c8df4608c8 | 14 | * limitations under the License. |
| embeddedartists | 1:46c8df4608c8 | 15 | */ |
| embeddedartists | 0:4977187e90c7 | 16 | |
| embeddedartists | 0:4977187e90c7 | 17 | #ifndef APP_H |
| embeddedartists | 0:4977187e90c7 | 18 | #define APP_H |
| embeddedartists | 0:4977187e90c7 | 19 | |
| embeddedartists | 0:4977187e90c7 | 20 | /** |
| embeddedartists | 1:46c8df4608c8 | 21 | * Base class for all Apps. The idea is that you can have multiple |
| embeddedartists | 1:46c8df4608c8 | 22 | * Apps in your program. Each App has three funtions: |
| embeddedartists | 0:4977187e90c7 | 23 | * |
| embeddedartists | 1:46c8df4608c8 | 24 | * setup() is called to let the App load all needed resources |
| embeddedartists | 0:4977187e90c7 | 25 | * |
| embeddedartists | 1:46c8df4608c8 | 26 | * runToCompletion() is called and will not return until the App exits |
| embeddedartists | 0:4977187e90c7 | 27 | * |
| embeddedartists | 1:46c8df4608c8 | 28 | * teardown() is called to let the App free allocated resources |
| embeddedartists | 0:4977187e90c7 | 29 | * |
| embeddedartists | 1:46c8df4608c8 | 30 | * For an example of Apps in use, see the AppLauncher class |
| embeddedartists | 0:4977187e90c7 | 31 | */ |
| embeddedartists | 0:4977187e90c7 | 32 | class App { |
| embeddedartists | 0:4977187e90c7 | 33 | public: |
| embeddedartists | 10:651861441108 | 34 | virtual ~App() {}; |
| embeddedartists | 0:4977187e90c7 | 35 | |
| embeddedartists | 1:46c8df4608c8 | 36 | /** Prepare the App before it is started. |
| embeddedartists | 1:46c8df4608c8 | 37 | * |
| embeddedartists | 1:46c8df4608c8 | 38 | * This function can be implemented to allocate memory, load startup |
| embeddedartists | 1:46c8df4608c8 | 39 | * images or other time consuming preparations. |
| embeddedartists | 1:46c8df4608c8 | 40 | * |
| embeddedartists | 1:46c8df4608c8 | 41 | * The return value is to let the caller now if the application can |
| embeddedartists | 1:46c8df4608c8 | 42 | * be started or not. |
| embeddedartists | 1:46c8df4608c8 | 43 | * |
| embeddedartists | 1:46c8df4608c8 | 44 | * @param x the touched x coordinate |
| embeddedartists | 1:46c8df4608c8 | 45 | * @param y the touched y coordinate |
| embeddedartists | 1:46c8df4608c8 | 46 | * @param pressed true if the user pressed the display |
| embeddedartists | 1:46c8df4608c8 | 47 | * |
| embeddedartists | 1:46c8df4608c8 | 48 | * @returns |
| embeddedartists | 1:46c8df4608c8 | 49 | * true if the app can be started |
| embeddedartists | 1:46c8df4608c8 | 50 | * false if the setup failed |
| embeddedartists | 1:46c8df4608c8 | 51 | */ |
| embeddedartists | 0:4977187e90c7 | 52 | virtual bool setup() { return true; } |
| embeddedartists | 1:46c8df4608c8 | 53 | |
| embeddedartists | 1:46c8df4608c8 | 54 | /** Runs the App to completion |
| embeddedartists | 1:46c8df4608c8 | 55 | * |
| embeddedartists | 1:46c8df4608c8 | 56 | * This function should not return until the App has finished. |
| embeddedartists | 1:46c8df4608c8 | 57 | */ |
| embeddedartists | 0:4977187e90c7 | 58 | virtual void runToCompletion() = 0; |
| embeddedartists | 1:46c8df4608c8 | 59 | |
| embeddedartists | 1:46c8df4608c8 | 60 | /** Cleanup |
| embeddedartists | 1:46c8df4608c8 | 61 | * |
| embeddedartists | 1:46c8df4608c8 | 62 | * Implement to free up the memory allocated in setup(). |
| embeddedartists | 1:46c8df4608c8 | 63 | * |
| embeddedartists | 1:46c8df4608c8 | 64 | * @returns |
| embeddedartists | 1:46c8df4608c8 | 65 | * true if the teardown finished successfully |
| embeddedartists | 1:46c8df4608c8 | 66 | * false if the teardown failed |
| embeddedartists | 1:46c8df4608c8 | 67 | */ |
| embeddedartists | 0:4977187e90c7 | 68 | virtual bool teardown() { return true; } |
| embeddedartists | 0:4977187e90c7 | 69 | }; |
| embeddedartists | 0:4977187e90c7 | 70 | |
| embeddedartists | 0:4977187e90c7 | 71 | #endif |
