Introduction to Symbian C++ development

Qt applications can use Symbian APIs directly. This section is an accelerated introduction to Symbian C++ for application developers with a working knowledge of standard C++.

How different is Symbian C++?

As a C++ developer your skills will be used and extended if you choose to program in Symbian C++. You will find full support for the 'Big Three' of object oriented programming: encapsulation, inheritance, and polymorphism. In addition Symbian complements C++ language basics by providing:Standard C++ is a general purpose programming language and the designers of Symbian C++ decided that some language features were less useful for coding on constrained devices. For example:
  • Symbian encourages only single inheritance of implementation ('subclassing') , but allows multiple interface inheritance ('subtyping').

  • Class and function templates are not used extensively in Symbian C++. Examples of using templates in Symbian include the dynamic array class templates such as RArray and RPointerArray. The Thin Template idiom is used to prevent code bloat. See Thin templates for details.

  • Standard C++ exception handling was not originally supported due to the overhead involved. It is now possible to use standard exception syntax but this is primarily to make porting existing C++ code easier.

  • The smart pointer idiom is not widely used in Symbian code. Exception safety is achieved through the leave mechanism and the cleanup stack instead of releasing resources in the destructors of local variables.

Using a Symbian server

The device resources and services that you are most likely to use in your application are provided by Symbian servers. A Symbian server is a system program that runs in the background and manages access by applications to the resources of the device, such as the file system, multimedia, and networking. Individual servers control shared access to key device components, for example the camera.

The QtMobility package offers convenient access to much of the functionality provided by Symbian servers. In cases where a particular server is not yet accessible using QtMobility, you can interact with the server directly from Symbian code.

A server is typically a separate executable with a client side API defined in a Symbian DLL, so you link against the .LIB of the DLL to use the server. In addition, using a server may involve:
  • creating active objects to make asynchronous requests of the server. Active objects are managed by a component called the active scheduler. The application framework creates an active scheduler to which you can add your active objects.

  • passing data to and receiving data from the server in the form of descriptors. Descriptors are how strings are represented in Symbian code. There are 16 bit and 8 bit descriptor classes. For serializing objects across the client server boundary 8 bit package descriptors are used.

If your application uses QtMobility and also creates a session with a Symbian server, you may choose to create a component to act as the application controller. The controller handles interactions between the user interface and the service providers. It encapsulates the logic for routing requests either to the QtMobility APIs or to the Symbian DLL that interacts with the server, allowing an easy migration to a pure Qt solution in future.

For further information on developing an application using both Qt and Symbian C++, see Mixing Qt and Symbian C++ in your application.

Figure: Application architecture for using a Symbian server