An Introduction to   Symbian O.S. Presented By: Deepak Rathi PGDWTA-IV-2008 [C-DAC NOIDA]
Outline <ul><li>Symbian OS overview </li></ul><ul><li>Symbian OS structure </li></ul><ul><li>Setting up a development envi...
Outline <ul><li>Symbian OS overview </li></ul><ul><ul><li>Definition </li></ul></ul><ul><ul><li>History </li></ul></ul><ul...
Definition <ul><li>Symbian OS(v9.5) is the advanced,  open operating   system  designed for the specific requirements of a...
History <ul><li>1997: Psion’s EPOC OS Launched(2 MB memory) </li></ul><ul><li>1998: Symbian consortium and Symbian OS </li...
Market Share <ul><li>Symbian OS runs on ~75% of all smartphones </li></ul><ul><ul><li>Nokia expects the smartphone market ...
Symbian Device Classes/Platforms <ul><li>Same Basis, different feel and look due to difference at UI layer : </li></ul><ul...
Symbian OS Features <ul><li>Symbian OS from the  developer‘s point of view  = {operating system for handheld devices with ...
Outline <ul><li>Symbian OS overview </li></ul><ul><li>Symbian OS structure </li></ul><ul><ul><li>Hardware resources </li><...
Hardware resources <ul><li>CPU:  ARM, 32-bit, 36-220 MHz </li></ul><ul><li>ROM:  contains the OS and all the built-in midd...
Memory Organization and Disk Drives <ul><li>RAM: </li></ul><ul><ul><li>runtime memory (stack, heap) </li></ul></ul><ul><li...
Software components <ul><li>Kernel: </li></ul><ul><ul><li>manage and controls access to hardware resources </li></ul></ul>...
Processes, Threads, and Context Switching <ul><li>Process: fundamental unit of protection </li></ul><ul><ul><li>own addres...
Kernel and User Library... 1  <ul><li>Kernel :   The core of OS. It manages memory, loads processes and libraries and sche...
Kernel and User Library... 2 <ul><li>The kernel itself has two major components: </li></ul><ul><ul><li>Kernel Executive : ...
Event handling and active objects... 1 <ul><li>Symbian OS optimized for efficient event handling using: </li></ul><ul><ul>...
Event handling and active objects... 2 <ul><li>Cascade of events which occurs on pressing of a key when using say Symbian ...
Event handling and active objects... 3 <ul><ul><li>The window server then works out for the application that is currently ...
Client-server framework
Client-server framework... 2 <ul><li>A  server  thread is responsible for managing one or more related resources. </li></u...
Outline <ul><li>Symbian OS overview </li></ul><ul><li>Symbian OS structure </li></ul><ul><li>Setting up a development envi...
Symbian Series 60 and UIQ Development Tools <ul><li>Microsoft Visual Studio – C++ IDE (MSVS) </li></ul><ul><li>Metrowerks ...
Installation directories created <ul><li>Epoc32 –  gcc compiler, emulator, include files, etc. </li></ul><ul><li>Examples ...
Using the Application Wizard...1
Using the Application Wizard...2
Using the Application Wizard...3 Application title will appear on the device Each application has a unique identifier
Using the Application Wizard...4 Generated classes: - Application - Document - User interface - Container
Using the Application Wizard...5 Generated directories: - C++ include files - C++ source files - group: Symbian project fi...
Debugging Programs in the Emulator <ul><li>Set breakpoints(F9) </li></ul><ul><li>Debug (F5) </li></ul>Breakpoint Inspect v...
Generated Files GUI resources Project definition file Package definition file Source files
Outline <ul><li>Symbian OS overview </li></ul><ul><li>Symbian OS structure </li></ul><ul><li>Symbian OS structure </li></u...
Naming Conventions for Class Types...1 Category  Examples  Description  T (“data type”) classes TDesC, TPoint, TFileName  ...
Naming Conventions for Class Types...2 Category  Examples  Description  R (“resource/remote”) classes RFile, RTimer, RWrit...
Naming Conventions for Variables and Constants <ul><li>One character prefix for consistency, readability </li></ul><ul><li...
Basic Data Types – Integers, Void, Boolean Boolean Void Signed Integer Unsigned Integer Name Size (bytes) Tint >=4 Tint8 1...
Basic Data Types-Floating Point, Characters Floating Point (avoid it) Character Name Size (bytes)  TReal 8 TReal32 4 TReal...
Error Handling and Cleanup <ul><li>Error handling is about producing reliable programs,  on continuously running resource ...
Exception Handling…1 <ul><li>Exception is an indication of some error or problem during </li></ul><ul><li>execution. </li>...
Exception Handling…2 <ul><li>Symbian OS exception mechanism differs from standard C++ </li></ul><ul><li>Symbian OS does us...
Exception Handling…3 <ul><li>Symbian’s own variant of C++ try, catch, throw </li></ul><ul><li>C++ throw Symbian User::Leav...
Resource Management:   Exceptions, Panics, Leaves, and Traps <ul><li>Exception : runtime error that  is not  the programme...
Throw Exceptions: User::Leave() <ul><li>void DoExampleL() </li></ul><ul><li>{ </li></ul><ul><li>CExample* example = new CE...
Cleanup Stack: Avoid Memory Leaks <ul><li>CleanupStack is a stack where you can store pointers of allocated objects e.g. m...
Two Phase Constructor <ul><li>Two phased construction: </li></ul><ul><li>1. Allocate the object itself without creating th...
Descriptors: Containers for (16-bit) Text and (8-bit) Binary Data <ul><li>Runtime bounds checking </li></ul><ul><li>API fo...
Descriptor Classes Name Instatiable Modifiable Description TDesC No No abstract base class; argument passing and return va...
Descriptor API: Search, Extract, Insert, Delete, Replace, Format <ul><li>Nonmodifiable </li></ul><ul><ul><li>TInt  Length ...
Heap Buffer Descriptors HBufC: heap: (size, max size, data) <ul><li>Used if descriptor size unknown at compile time  </li>...
Descriptors as Arguments and Return Types <ul><li>Abstract base classes TDes and TDesC as formal parameters for flexibilit...
Outline d <ul><li>Symbian overview </li></ul><ul><li>Symbian OS structure </li></ul><ul><li>Setting up a development envir...
Any Queries!!! ☺
Thank you for your endurance! ☺
Upcoming SlideShare
Loading in...5
×

Symbian Os Introduction

4,456

Published on

Brief Intro to Symbian OS

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,456
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
139
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Symbian Os Introduction

  1. 1. An Introduction to Symbian O.S. Presented By: Deepak Rathi PGDWTA-IV-2008 [C-DAC NOIDA]
  2. 2. Outline <ul><li>Symbian OS overview </li></ul><ul><li>Symbian OS structure </li></ul><ul><li>Setting up a development environment </li></ul><ul><li>Creating a “Hello World” example </li></ul><ul><li>Basic Symbian OS and Symbian C++ concepts </li></ul>
  3. 3. Outline <ul><li>Symbian OS overview </li></ul><ul><ul><li>Definition </li></ul></ul><ul><ul><li>History </li></ul></ul><ul><ul><li>Market Share </li></ul></ul><ul><ul><li>Device Classes </li></ul></ul><ul><ul><li>Symbian OS Characteristics </li></ul></ul><ul><li>Symbian OS structure </li></ul><ul><li>Setting up a development environment </li></ul><ul><li>Creating a “Hello World” example </li></ul><ul><li>Basic Symbian OS and Symbian C++ concepts </li></ul>
  4. 4. Definition <ul><li>Symbian OS(v9.5) is the advanced, open operating system designed for the specific requirements of advanced 2.5G and 3G mobile phones. Symbian OS combines the power of an integrated applications environment with mobile telephony, bringing advanced data services to the smartphones . </li></ul><ul><li>Symbian OS (in general) is a multitasking operating system with features that include a file system, a graphical user interface framework, multimedia support, a TCP/IP stack and libraries for all the communication features found on smartphones . </li></ul>
  5. 5. History <ul><li>1997: Psion’s EPOC OS Launched(2 MB memory) </li></ul><ul><li>1998: Symbian consortium and Symbian OS </li></ul><ul><ul><li>independent of Psion </li></ul></ul><ul><ul><li>Ericsson, Nokia, Motorola, Psion (founders) </li></ul></ul><ul><ul><li>Panasonic, Sony Ericsson, Siemens, Samsung (shareholders) </li></ul></ul><ul><li>2000: First Symbian OS phone </li></ul><ul><ul><li>Ericsson R380 </li></ul></ul>
  6. 6. Market Share <ul><li>Symbian OS runs on ~75% of all smartphones </li></ul><ul><ul><li>Nokia expects the smartphone market to exceed 250 million units in 2008 </li></ul></ul><ul><ul><li>82.8 million cumulative Symbian OS phone shipments since the formation of Symbian (as of Q2 2006). </li></ul></ul><ul><li>Symbian C++ gives </li></ul><ul><ul><li>Maximum flexibility </li></ul></ul><ul><ul><li>Speed </li></ul></ul><ul><li> Market share in smartphones </li></ul>
  7. 7. Symbian Device Classes/Platforms <ul><li>Same Basis, different feel and look due to difference at UI layer : </li></ul><ul><li>S 60: Smartphones with numeric keypad, “phone centric” </li></ul><ul><li>e.g.: Nokia 6600 </li></ul><ul><li>S 80: Organizers with full keyboard, “information centric” </li></ul><ul><li>e.g. : Nokia 9300 </li></ul><ul><li>UIQ: smartphones with pen input, “information centric” </li></ul><ul><li>e.g.: Sony Ericssion P910 </li></ul>
  8. 8. Symbian OS Features <ul><li>Symbian OS from the developer‘s point of view = {operating system for handheld devices with limited resources </li></ul><ul><li> + user interface framework </li></ul><ul><li> + APIs (C++) </li></ul><ul><li> + tools} </li></ul><ul><li>Operating system: </li></ul><ul><ul><li>pre-emptive multitasking, multithreading, memory </li></ul></ul><ul><li> protection, event-based </li></ul><ul><ul><li>special features: conserving memory, reliability, CPU switched off when applications are not dealing with events </li></ul></ul><ul><li>Symbian OS from the user‘s view: </li></ul><ul><ul><li>consistent user interface, comprehensive set of PIM applications, extensible by 3rd party applications </li></ul></ul>
  9. 9. Outline <ul><li>Symbian OS overview </li></ul><ul><li>Symbian OS structure </li></ul><ul><ul><li>Hardware resources </li></ul></ul><ul><ul><li>Software components </li></ul></ul><ul><ul><li>Processes, threads, and context switching </li></ul></ul><ul><ul><li>Kernel and user library </li></ul></ul><ul><ul><li>Event handling and active objects </li></ul></ul><ul><ul><li>Client-server framework </li></ul></ul><ul><li>Setting up a development environment </li></ul><ul><li>Creating a “Hello World” example </li></ul><ul><li>Basic Symbian OS and Symbian C++ concepts </li></ul>
  10. 10. Hardware resources <ul><li>CPU: ARM, 32-bit, 36-220 MHz </li></ul><ul><li>ROM: contains the OS and all the built-in middleware and applications . Symbian OS v7.0 machines use around 20 MB of ROM. Z: drive. </li></ul><ul><li>RAM: system RAM is used for two purposes: </li></ul><ul><ul><li>RAM for use by active programs and the system kernel </li></ul></ul><ul><ul><li>RAM used as 'disk' space accessed as the c: drive. </li></ul></ul><ul><li>I/O Devices: keypad, pen input, card slot, CCD camera, serial port for RS232. </li></ul><ul><li>Communication: GSM/GPRS/UMTS, infrared, Bluetooth. </li></ul><ul><li>Power source: rechargable battery 2000-3000 mWh (600-900 mAh, 3.5 V). </li></ul><ul><li>Display: 176x208 pixels, 65536 colors for smartphones. </li></ul>
  11. 11. Memory Organization and Disk Drives <ul><li>RAM: </li></ul><ul><ul><li>runtime memory (stack, heap) </li></ul></ul><ul><li>C: System flash, or RAM, disk; full read/write file system </li></ul><ul><ul><li>application files, user files </li></ul></ul><ul><li>D, E, ...: Compact flash cards, memory sticks; removable read/write media </li></ul><ul><ul><li>application files, user files </li></ul></ul><ul><li>Z: contain ROM i.e.; read only file system </li></ul><ul><ul><li>operating system files </li></ul></ul>
  12. 12. Software components <ul><li>Kernel: </li></ul><ul><ul><li>manage and controls access to hardware resources </li></ul></ul><ul><ul><li>hardware-supported privileges, kernel mode </li></ul></ul><ul><li>Application: </li></ul><ul><ul><li>program with a user interface </li></ul></ul><ul><ul><li>runs in user mode in its own process </li></ul></ul><ul><li>Server: </li></ul><ul><ul><li>program without a user interface </li></ul></ul><ul><ul><li>manages resources, provides interface to clients; applications or other servers </li></ul></ul><ul><li>Engine: </li></ul><ul><ul><li>application part that manipulates data, often separate DLL </li></ul></ul>
  13. 13. Processes, Threads, and Context Switching <ul><li>Process: fundamental unit of protection </li></ul><ul><ul><li>own address space </li></ul></ul><ul><ul><li>virtual addresses – MMU  physical addresses </li></ul></ul><ul><ul><li>It may contain one or more threads </li></ul></ul><ul><li>Thread: fundamental unit of execution </li></ul><ul><ul><li>one or more per process </li></ul></ul><ul><ul><li>preemptively scheduled by the kernel </li></ul></ul><ul><ul><li>The consequent interruption of the running thread by the higher-priority thread is called preemption, giving rise to the term preemptive multitasking in Symbian OS </li></ul></ul><ul><ul><li>executes independently of the others, but within the same address space </li></ul></ul><ul><li>Context switching: switching b/w one thread to another </li></ul><ul><ul><li>expensive between two threads in different processes </li></ul></ul><ul><ul><li>typically just one thread per process  active objects </li></ul></ul>
  14. 14. Kernel and User Library... 1 <ul><li>Kernel : The core of OS. It manages memory, loads processes and libraries and schedules threads for execution. </li></ul><ul><li>Most fundamental component of Symbian OS E32 & consists of the kernel and user library . </li></ul><ul><li>Kernel runs in privileged mode </li></ul><ul><li>The user library, euser.lib , is the lowest-level user-mode code </li></ul>
  15. 15. Kernel and User Library... 2 <ul><li>The kernel itself has two major components: </li></ul><ul><ul><li>Kernel Executive : runs privileged code on behalf of a user thread & runs in the context of that user thread. </li></ul></ul><ul><ul><li>Kernel Server : highest-priority thread in system. It allocates and deallocates kernel-side resources needed by the system and by user programs </li></ul></ul><ul><li>User library (euser.lib), basic library for kernel access, perform 3 functions: </li></ul><ul><ul><li>functions executing entirely at user-side (e.g. descriptors, arrays) </li></ul></ul><ul><ul><li>Function requiring privilege hence cross into kernel executive mode (e.g. time checking) </li></ul></ul><ul><ul><li>Functions that require the services of the kernel server: these go through the user library, via the executive, to the server </li></ul></ul>
  16. 16. Event handling and active objects... 1 <ul><li>Symbian OS optimized for efficient event handling using: </li></ul><ul><ul><li>Active Objects & Active Schedulers: </li></ul></ul><ul><ul><ul><li>non-preemptive event handling within a single thread </li></ul></ul></ul><ul><ul><ul><li>well-suited for GUI systems </li></ul></ul></ul><ul><ul><ul><li>Active objects responsible for issuing requests to asynchronous service providers and handling those requests on completion. Derives from CActive class. </li></ul></ul></ul><ul><ul><ul><li>Active scheduler calls RunL method of active object. Responsible for scheduling events to the active objects in an event-handling program. </li></ul></ul></ul>
  17. 17. Event handling and active objects... 2 <ul><li>Cascade of events which occurs on pressing of a key when using say Symbian OS word application: </li></ul><ul><ul><li>The I/O device controlling the keyboard generates an interrupt( press PGDWTA ) </li></ul></ul><ul><ul><li>ISR/DFC (Delayed Fn Call) , translates this to an event & generates ASCII code corresponding to PGDWTA </li></ul></ul>
  18. 18. Event handling and active objects... 3 <ul><ul><li>The window server then works out for the application that is currently receiving keystrokes and sends the event to the application, in this case Symbian OS Word. </li></ul></ul><ul><ul><li>Symbian OS Word then handles the key – by adding text: PGDWTA to the document and then updating the display. </li></ul></ul><ul><ul><li>The window server updates the display in response to the application's requests by displaying PGDWTA on the Smartphone's display screen . </li></ul></ul>
  19. 19. Client-server framework
  20. 20. Client-server framework... 2 <ul><li>A server thread is responsible for managing one or more related resources. </li></ul><ul><li>One or more client threads may use the server to perform functions that use those resources. </li></ul><ul><li>Most critical servers in Symbian OS: </li></ul><ul><ul><li>File Server: which handles all files related operations. </li></ul></ul><ul><ul><li>Window Server: which handles user inputs and drawings to screen. </li></ul></ul><ul><ul><li>Other servers: communications, databases, schedule, contacts, etc. </li></ul></ul><ul><li>Key elements of Client-server interface are: </li></ul><ul><ul><li>The client interface : each server provides an API to its clients – the client interface, which disguises all the client-server communications </li></ul></ul><ul><ul><li>Kernel-supported message passing : implementing a server (along with its client interface), this is the main method by which you pass requests from the client to the server, and handle them. </li></ul></ul><ul><ul><li>Kernel-supported inter-thread read/write : server can read from, or write to, a client's address space </li></ul></ul>
  21. 21. Outline <ul><li>Symbian OS overview </li></ul><ul><li>Symbian OS structure </li></ul><ul><li>Setting up a development environment </li></ul><ul><ul><li>Development tools </li></ul></ul><ul><ul><li>Installation issues </li></ul></ul><ul><ul><li>Application wizard </li></ul></ul><ul><ul><li>Debugging Programs in Emulator </li></ul></ul><ul><li>Creating a “Hello World” example </li></ul><ul><li>Basic Symbian OS and Symbian C++ concepts </li></ul>
  22. 22. Symbian Series 60 and UIQ Development Tools <ul><li>Microsoft Visual Studio – C++ IDE (MSVS) </li></ul><ul><li>Metrowerks Code Warrior – C++ IDE (alternative) </li></ul><ul><li>[Makmake – makefiles for Windows and ARM, project files for MSVS] </li></ul><ul><li>Bldmake – generates abld.bat from bld.inf </li></ul><ul><li>Abld – Perl tool, creates makefiles, compiles project </li></ul><ul><li>Makesis – creates installation file “.sis” from “.pkg” file </li></ul>
  23. 23. Installation directories created <ul><li>Epoc32 – gcc compiler, emulator, include files, etc. </li></ul><ul><li>Examples – SDK examples </li></ul><ul><li>Series60Doc – SDK documentation </li></ul><ul><li>Series60Ex – Series 60 specific examples </li></ul><ul><li>Series60Tools – tools </li></ul>
  24. 24. Using the Application Wizard...1
  25. 25. Using the Application Wizard...2
  26. 26. Using the Application Wizard...3 Application title will appear on the device Each application has a unique identifier
  27. 27. Using the Application Wizard...4 Generated classes: - Application - Document - User interface - Container
  28. 28. Using the Application Wizard...5 Generated directories: - C++ include files - C++ source files - group: Symbian project files - data, aif: resource files - install: installation files
  29. 29. Debugging Programs in the Emulator <ul><li>Set breakpoints(F9) </li></ul><ul><li>Debug (F5) </li></ul>Breakpoint Inspect variables
  30. 30. Generated Files GUI resources Project definition file Package definition file Source files
  31. 31. Outline <ul><li>Symbian OS overview </li></ul><ul><li>Symbian OS structure </li></ul><ul><li>Symbian OS structure </li></ul><ul><li>Setting up a development environment </li></ul><ul><li>Creating a “Hello World” example </li></ul><ul><li>Basic Symbian OS and Symbian C++ concepts </li></ul><ul><ul><li>Naming conventions </li></ul></ul><ul><ul><li>Basic types </li></ul></ul><ul><ul><li>Exception handling </li></ul></ul><ul><ul><li>Resource management </li></ul></ul><ul><ul><li>Descriptors </li></ul></ul>
  32. 32. Naming Conventions for Class Types...1 Category Examples Description T (“data type”) classes TDesC, TPoint, TFileName T classes don't have a destructor. They act like built-in types. No pointers, no resources C (“cleanup”) classes CConsoleBase, CActive, CBase Any class derived from CBase. C classes are allocated on heap. CBase also includes a virtual destructor, so that by calling delete on a CBase* pointer any C object it points to is properly destroyed.
  33. 33. Naming Conventions for Class Types...2 Category Examples Description R (“resource/remote”) classes RFile, RTimer, RWriteStream, RWindow Client-side handle to an OS resource (file server, message server, etc.) M (“mixin”) classes/interface classes MGraphicsDevice-Map,MGameViewCmd-Handler, MEikMenuObserver An interface consisting of pure virtual functions. A class implementing this interface should derive from it. M classes are the only approved use of multiple inheritance in Symbian OS.
  34. 34. Naming Conventions for Variables and Constants <ul><li>One character prefix for consistency, readability </li></ul><ul><li>i : member (instance) variables i Document </li></ul><ul><li>a : method arguments a Index </li></ul><ul><li>no prefix : local variables on the stack size </li></ul><ul><li>K : constants K Pi </li></ul><ul><li>Method names: capitalized S etName </li></ul>
  35. 35. Basic Data Types – Integers, Void, Boolean Boolean Void Signed Integer Unsigned Integer Name Size (bytes) Tint >=4 Tint8 1 Tint16 2 Tint32 4 Tint64 8 Name Size (bytes) TUint >=4 TUint8 1 TUint16 2 TUint32 4 Name Size TBool 4 Name Type TAny Void
  36. 36. Basic Data Types-Floating Point, Characters Floating Point (avoid it) Character Name Size (bytes) TReal 8 TReal32 4 TReal64 8 TRealX 12 Name Size (bytes) TText8 1 TText 2 TText16 2 TChar 4
  37. 37. Error Handling and Cleanup <ul><li>Error handling is about producing reliable programs, on continuously running resource constrained devices running Symbian OS </li></ul><ul><ul><li>Memory leaks must not occur! </li></ul></ul><ul><ul><li>Use memory efficiently and safely </li></ul></ul><ul><ul><li>Release resources as early as possible </li></ul></ul><ul><ul><li>Cope with out-of-memory and other errors and roll back to a consistent state when they occur </li></ul></ul><ul><ul><li>The Symbian OS error handling and cleanup framework is good for more than OOM errors. Many operations can fail because of other environment conditions – reading and writing to files, opening files, sending and receiving over communications sessions to name a few. </li></ul></ul>
  38. 38. Exception Handling…1 <ul><li>Exception is an indication of some error or problem during </li></ul><ul><li>execution. </li></ul><ul><li>The bigger the application, the more probable it may have </li></ul><ul><li>problem situations. </li></ul><ul><li>Typical problems are e.g. out of memory situations or lack of </li></ul><ul><li>some resource, e.g. network not available. </li></ul><ul><li>In e.g. Java, exceptions are used in many kinds of erroneous </li></ul><ul><li>situations, e.g. overindexing table, divide by zero etc. </li></ul><ul><li>In Symbian OS, exceptions are used in “ lack of resource ” </li></ul><ul><li>situations. </li></ul><ul><li>Symbian OS “exception” is called a leave . </li></ul>
  39. 39. Exception Handling…2 <ul><li>Symbian OS exception mechanism differs from standard C++ </li></ul><ul><li>Symbian OS does use standard C++ throw-catch mechanism (so it does not matter if you never coded C++ exceptions). </li></ul><ul><li>The C++ standardization was in progress while Symbian OS was developed so they created their own mechanism. </li></ul>
  40. 40. Exception Handling…3 <ul><li>Symbian’s own variant of C++ try, catch, throw </li></ul><ul><li>C++ throw Symbian User::Leave() </li></ul><ul><li>C++ try, catch Symbian TRAP macro </li></ul><ul><li>Cleanup stack </li></ul><ul><ul><li>clean up heap when exception occurs </li></ul></ul><ul><li>Two-phase construction of complex objects </li></ul><ul><ul><li>1st phase constructors never leave </li></ul></ul><ul><ul><li>2nd phase constructors can </li></ul></ul>
  41. 41. Resource Management: Exceptions, Panics, Leaves, and Traps <ul><li>Exception : runtime error that is not the programmer’s fault </li></ul><ul><li>Panic : A run-time exception on Symbian OS that terminates the current thread. Panics tend to be caused when assertion statements fail. </li></ul><ul><ul><li>It is programmatic error that is the programmer’s fault </li></ul></ul><ul><li>Leave : Symbian OS exception handling. Execution leaves the method and jumps up the call stack to the closest exception handler </li></ul><ul><ul><li>A function leaves when User::Leave()is called. </li></ul></ul><ul><li>Trap / trap harness : central exception handler </li></ul><ul><ul><li>Symbian OS provides two macros, TRAP and TRAPD, to trap a leave. </li></ul></ul><ul><ul><li>A variation on TRAP is TRAPD (the D is for declare). TRAPD is the same as TRAP except the TRAPD macro will declare the first argument (the leave code variable) so you do not have to. For example: </li></ul></ul><ul><ul><li>TRAPD(LeaveError,MyFunctionL()); </li></ul></ul><ul><li>is equivalent to: </li></ul><ul><li>TInt LeaveError; </li></ul><ul><li>TRAP(LeaveError,MyFunctionL()); </li></ul>
  42. 42. Throw Exceptions: User::Leave() <ul><li>void DoExampleL() </li></ul><ul><li>{ </li></ul><ul><li>CExample* example = new CExample; </li></ul><ul><li>if (example == NULL) </li></ul><ul><li>{ </li></ul><ul><li>User::Leave(KErrNoMemory); </li></ul><ul><li>} </li></ul><ul><li>// do something with example </li></ul><ul><li>delete example; </li></ul><ul><li>} </li></ul>] L indicates that method may leave (naming convention) ] throw exception with reason code
  43. 43. Cleanup Stack: Avoid Memory Leaks <ul><li>CleanupStack is a stack where you can store pointers of allocated objects e.g. myObject1 pointer in the scenario in previous slide. </li></ul><ul><li>If a leave occurs, TRAP macro frees the memory deleting the pointers in CleanupStack </li></ul><ul><li>You can store pointers by pushing them to CleanupStack as follows: </li></ul><ul><ul><li>CleanupStack::PushL( myObject1 ), pushes object </li></ul></ul><ul><li> myObject1 to the CleanupStack. </li></ul><ul><li>You can remove pointers by popping them from the CleanupStack as follows: </li></ul><ul><ul><li>CleanupStack::Pop() </li></ul></ul><ul><li>You can pop and destroy objects in cleanup stack by calling: CleanupStack::PopAndDestroy() </li></ul><ul><li>Pop and PopAnDestroy operations are always for the last object put on the CleanupStack. </li></ul>
  44. 44. Two Phase Constructor <ul><li>Two phased construction: </li></ul><ul><li>1. Allocate the object itself without creating the dynamically allocated instances. Now we have a </li></ul><ul><li>pointer to this object. </li></ul><ul><ul><li>This is done in the ’normal’ constructor. </li></ul></ul><ul><li>2. After that we create the dynamical members. </li></ul><ul><ul><li>This is done in ConstructL method. </li></ul></ul><ul><li>If something goes wrong, we have the pointer so we can delete all allocated memory. </li></ul><ul><li>This is done in the NewL() and NewLC() –methods . </li></ul>
  45. 45. Descriptors: Containers for (16-bit) Text and (8-bit) Binary Data <ul><li>Runtime bounds checking </li></ul><ul><li>API for buffer modification </li></ul><ul><li>Used extensively in Symbian OS APIs </li></ul><ul><li>Modifiable and nonmodifiable </li></ul>
  46. 46. Descriptor Classes Name Instatiable Modifiable Description TDesC No No abstract base class; argument passing and return values (const TDesC&) TDes No Yes abstract base class; argument passing return values (const TDes&) TBufC Yes No templated buffer descriptor: (size, data) stored together TPtrC Yes No pointer descriptor: (size, pointer) separate from data, data not owned TBuf Yes Yes templated buffer descriptor: (size, maximum size, data) stored together TPtr Yes Yes pointer descriptor: (size, maximum size, pointer) separate from data, data not owned HBufC Yes No heap descriptor: (size, maximum size, data) stored together on the heap
  47. 47. Descriptor API: Search, Extract, Insert, Delete, Replace, Format <ul><li>Nonmodifiable </li></ul><ul><ul><li>TInt Length () </li></ul></ul><ul><ul><li>TInt Size () </li></ul></ul><ul><ul><li>const TUint* Ptr () </li></ul></ul><ul><ul><li>HBufC* Alloc () </li></ul></ul><ul><ul><li>TPtrC Left (TInt aLength) </li></ul></ul><ul><ul><li>TPtrC Mid (TInt aPos, </li></ul></ul><ul><ul><li>TInt aLength) </li></ul></ul><ul><ul><li>TInt Find (const TDesC& aDes) </li></ul></ul><ul><ul><li>const TUint16& operator[] () </li></ul></ul><ul><li>Modifiable </li></ul><ul><ul><li>TInt MaxLength () </li></ul></ul><ul><ul><li>TInt MaxSize () </li></ul></ul><ul><ul><li>void SetLength (Tint aLength) </li></ul></ul><ul><ul><li>void Append (const TDesC& aDes) </li></ul></ul><ul><ul><li>void Insert (TInt aPos, const TDesC& aDes) </li></ul></ul><ul><ul><li>void Delete (TInt aPos,Tint aLength); </li></ul></ul>
  48. 48. Heap Buffer Descriptors HBufC: heap: (size, max size, data) <ul><li>Used if descriptor size unknown at compile time </li></ul><ul><li>Change to pointer descriptor to modify </li></ul><ul><li>HBufC* buf16 = HBufC::NewLC(buf8.Length()); </li></ul><ul><li>TPtr ptr16 = buf16->Des(); </li></ul><ul><li>ptr16.Copy(buf8); </li></ul><ul><li>buf16 = buf16->ReAlloc(4 * buf8.Length()); </li></ul><ul><li>CleanupStack::Pop(); </li></ul><ul><li>CleanupStack::Push(buf16); </li></ul><ul><li>... </li></ul><ul><li>CleanupStack::PopAndDestroy(buf16); </li></ul>
  49. 49. Descriptors as Arguments and Return Types <ul><li>Abstract base classes TDes and TDesC as formal parameters for flexibility </li></ul><ul><li>void SetName(const TDesC& aName); </li></ul><ul><li>const TDesC& Symbol() const ; </li></ul>
  50. 50. Outline d <ul><li>Symbian overview </li></ul><ul><li>Symbian OS structure </li></ul><ul><li>Setting up a development environment </li></ul><ul><li>Creating a “Hello World” example </li></ul><ul><li>Basic Symbian OS and Symbian C++ concepts </li></ul>
  51. 51. Any Queries!!! ☺
  52. 52. Thank you for your endurance! ☺
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×