Table Of ContentThe Accredited Symbian
Developer Primer
The Accredited
Symbian Developer
Primer
Fundamentals of Symbian OS
By
Jo Stichbury and Mark Jacobs
Reviewedby
Jehad Al-Ansari, Rosanna Ashworth-Jones, Warren Day,
Ioannis Douros, Graeme Duncan, Adrian Issot, Ashvin Lad,
Rick Martin, Lorin McKay, Chris Notton, John Pagonis,
Antony Pranata, William Roberts, Rahul Singh,
Attila Vamos, Jonathan Yu
SymbianPress
HeadofSymbianPress
Philip Northam
ManagingEditor
Freddie Gjertsen
Copyright2006by JohnWiley&Sons,LtdTheAtrium,SouthernGate,Chichester,
WestSussexPO198SQ,England
Telephone(+44)1243779777
Email(forordersandcustomerserviceenquiries):[email protected]
VisitourHomePageonwww.wiley.com
AllRightsReserved.Nopartofthispublicationmaybereproduced,storedinaretrievalsystemor
transmittedinanyformorbyanymeans,electronic,mechanical,photocopying,recording,scanningor
otherwise,exceptunderthetermsoftheCopyright,DesignsandPatentsAct1988orunderthetermsof
alicenceissuedbytheCopyrightLicensingAgencyLtd,90TottenhamCourtRoad,LondonW1T4LP,
UK,withoutthepermissioninwritingofthePublisher.RequeststothePublishershouldbeaddressedto
thePermissionsDepartment,JohnWiley&SonsLtd,TheAtrium,SouthernGate,Chichester,West
SussexPO198SQ,England,[email protected],orfaxedto(+44)1243770620.
Designationsusedbycompaniestodistinguishtheirproductsareoftenclaimedastrademarks.All
brandnamesandproductnamesusedinthisbookaretradenames,servicemarks,trademarksor
registeredtrademarksoftheirrespectiveowners.ThePublisherisnotassociatedwithanyproductor
vendormentionedinthisbook.
Thispublicationisdesignedtoprovideaccurateandauthoritativeinformationinregardtothesubject
mattercovered.ItissoldontheunderstandingthatthePublisherisnotengagedinrendering
professionalservices.Ifprofessionaladviceorotherexpertassistanceisrequired,theservicesofa
competentprofessionalshouldbesought.
OtherWileyEditorialOffices
JohnWiley&SonsInc.,111RiverStreet,Hoboken,NJ07030,USA
Jossey-Bass,989MarketStreet,SanFrancisco,CA94103-1741,USA
Wiley-VCHVerlagGmbH,Boschstr.12,D-69469Weinheim,Germany
JohnWiley&SonsAustraliaLtd,42McDougallStreet,Milton,Queensland4064,Australia
JohnWiley&Sons(Asia)PteLtd,2ClementiLoop#02-01,JinXingDistripark,Singapore129809
JohnWiley&SonsCanadaLtd,6045FreemontBlvd,Mississauga,ONT,L5R4J3,Canada
Wileyalsopublishesitsbooksinavarietyofelectronicformats.Somecontentthat
appearsinprintmaynotbeavailableinelectronicbooks.
BritishLibraryCataloguinginPublicationData
AcataloguerecordforthisbookisavailablefromtheBritishLibrary
ISBN-13:978-0-470-05827-5
ISBN-10:0-470-05827-7
Typesetin10/12ptOptimabyLaserwordsPrivateLimited,Chennai,India
PrintedandboundinGreatBritainbyBell&Bain,Glasgow
Thisbookisprintedonacid-freepaperresponsiblymanufacturedfromsustainable
forestryinwhichatleasttwotreesareplantedforeachoneusedforpaperproduction.
Contents
Foreword ix
About this Book xiii
About the Authors xv
Acknowledgments xvii
Introduction xxi
Exam Essentials Summary xxv
1 C++ Language Fundamentals 1
Introduction 1
1.1 Types 1
1.2 Statements 8
1.3 ExpressionsandOperators 14
1.4 Functions 17
1.5 DynamicMemoryAllocation 25
1.6 ToolChainBasics 27
2 Classes and Objects 31
Introduction 31
2.1 ScopeandC++Object-OrientedProgramming
(OOP)Support 31
2.2 ConstructorsandDestructors 36
2.3 ClassMembers 40
3 Class Design and Inheritance 49
Introduction 49
vi CONTENTS
3.1 ClassRelationships 49
3.2 Inheritance 52
3.3 DynamicPolymorphism–VirtualMethods 56
3.4 StaticPolymorphismandTemplates 64
4 Symbian OS Types and Declarations 71
Introduction 71
4.1 TheFundamentalSymbianOSTypes 71
4.2 TClasses 73
4.3 CClasses 74
4.4 RClasses 76
4.5 MClasses 77
4.6 StaticClasses 79
4.7 FactorstoConsiderwhenCreatingaSymbianOS
Class 79
4.8 WhyIstheSymbianOSNamingConvention
Important? 80
References 81
5 Leaves and the Cleanup Stack 83
Introduction 83
5.1 Leaves:LightweightExceptionsforSymbianOS 83
5.2 HowtoWorkwithLeaves 86
5.3 ComparingLeavesandPanics 89
5.4 WhatIsaTRAP? 89
5.5 TheCleanupStack 91
5.6 DetectingMemoryLeaks 99
References 100
6 Two-Phase Construction and Object Destruction 101
Introduction 101
6.1 Two-PhaseConstruction 101
6.2 ObjectDestruction 105
References 106
7 Descriptors 107
Introduction 107
7.1 FeaturesofSymbianOSDescriptors 107
7.2 TheSymbianOSDescriptorClasses 109
7.3 TheInheritanceHierarchyoftheDescriptorClasses 116
7.4 UsingtheDescriptorAPIs 117
7.5 DescriptorsasFunctionParameters 120
7.6 CorrectUseoftheDynamicDescriptorClasses 120
7.7 CommonInefficienciesinDescriptorUsage 125
7.8 LiteralDescriptors 126
7.9 DescriptorConversion 128
References 132
CONTENTS vii
8 Dynamic Arrays 133
Introduction 133
8.1 DynamicArraysinSymbianOS 133
8.2 RArray,RPointerArrayorCArrayX? 137
8.3 ArrayGranularities 139
8.4 ArraySortingandSearching 140
8.5 TFixedArray 145
References 146
9 Active Objects 147
Introduction 147
9.1 Event-DrivenMultitaskingonSymbianOS 147
9.2 ClassCActive 150
9.3 TheActiveScheduler 158
9.4 CancelinganOutstandingRequest 161
9.5 BackgroundTasks 163
9.6 CommonProblems 165
References 167
10System Structure 169
Introduction 169
10.1 DLLsinSymbianOS 170
10.2 WritableStaticData 173
10.3 ExecutablesinROMandRAM 176
10.4 ThreadsandProcesses 177
10.5 Inter-ProcessCommunication(IPC) 181
10.6 Recognizers 185
10.7 PanicsandAssertions 186
References 190
11Client–Server Framework 191
Introduction 191
11.1 TheClient–ServerPattern 191
11.2 FundamentalsoftheSymbianOSClient–Server
Framework 192
11.3 SymbianOSClient–ServerClasses 194
11.4 Client–ServerDataTransfer 201
11.5 ImpactoftheClient–ServerFramework 206
References 209
12File Server and Streams 211
Introduction 211
12.1 TheSymbianOSFileSystem 211
12.2 StreamsandStores 217
References 227