Developing Series 60 Applications: A Guide for Symbian OS C++ Developers: A Guide for Symbian OS C++ Developers
Covering the essential aspects of Symbian OS, upon which Series 60 is based
This chapter introduces the basic concepts, APIs, and data structures that you need to understand in order to develop for Symbian OS and therefore Series 60. All of the topics discussed in this chapter will be used throughout the book, usually without further explanation. It is therefore essential that you understand them fully before proceeding further.
Symbian OS is written almost entirely in C++, but developing applications for it is not trivial, and so this chapter requires the reader to have a solid background in advanced use of C++ and object-oriented design. Readers with previous Symbian OS development experience may wish to skip this chapter, as no Series 60-specific elements will be covered here. However, it may still prove to be a useful refresher course.
Although Symbian OS provides part of the User Interface ( UI ) implementation of the platform, Series 60 provides many of the concrete UI controls ”so UI features will not be covered here. In fact the contents of this chapter could easily apply to any platform that is based on Symbian OS.
Topics covered are:
-
Naming Conventions ” Symbian OS uses naming conventions to increase readability and consistency. Following these conventions allows other Symbian OS developers to more easily follow your code and also allows for some automatic verification of code.
-
Basic Types ” How Symbian OS manages basic variable types such as integers and floating-point numbers .
-
Exception Handling and Resource Management ” Resource management is a key element when developing applications for devices that have small amounts of available memory and are infrequently rebooted. Symbian OS has its own efficient paradigms for handling resource allocation and deallocation. This also impacts object construction and exception handling.
-
Descriptors ” Symbian OS defines its own efficient types for handling text strings, in both Unicode and narrow (8-bit) formats. Descriptors can also be used for storing arbitrary binary data.
-
Collection Classes ” Symbian OS does not support the Standard Template Library (STL). Instead, it provides a set of small, efficient collection classes, the most commonly used of which are covered here.
-
Using Asynchronous Services with Active Objects ” it is uncommon for Symbian OS applications to use multiple threads. Instead, a cooperative multitasking paradigm is used through the Active Object API. This section will cover why and how Active Objects are used to interact with the asynchronous services provided by Symbian OS servers.
-
Files, Streams and Stores ” This section covers how to use the Symbian OS file system and how to read and write to files. Streams and Stores provide an elegant and efficient way to persist any data.
-
Client/Server Architecture ” Symbian OS uses Client/Server architecture throughout in order to provide safe, efficient, extensible and typically asynchronous services to multiple client applications. This section will focus on client-side interaction with Symbian OS Servers.
Each of these fundamental topics builds on information given earlier in the chapter, so you are advised to approach each topic in turn : The naming conventions and basic types are used throughout; descriptors and collection classes require resource management; file handling and Client/Server architecture use Active Objects, and so on.
All of the topics covered in this chapter are illustrated using code snippets, mostly taken from an example application called Elements , and the details of how to download the full buildable source of this, along with the other example applications, are given in the Preface.
For the sake of simplicity, this example is implemented as a console application ”in other words it has no Graphical User Interface ( GUI ). Using a console application allows the focus to be placed on the underlying principles of the topics being explained, rather than having to examine the Series 60 UI framework at this early stage.
The Elements application is a contrived example that stores and manipulates lists of chemical elements. The elements can be loaded in from a standard comma-separated value ( CSV ) text file, or from a Symbian OS stream-based binary file (this will be explained further in the section Files, Streams and Stores ). Once loaded, the list can then be sorted, searched and written out to the console display, or back to a file.
Note that lines of code are sometimes omitted for clarity in the book listings, and while it is unusual for a console application to be run on a real Series 60 device, details are provided with the full source to allow you to run the application on target hardware.