Nokia N97 SDK
Example Applications Guide

CShapeListManager Class Reference

#include <shapelistmanager.h>

Inheritance diagram for CShapeListManager:

List of all members.

Detailed Description

CShapeListManager An instance of this class is an engine that manages a list of shapes.

Definition at line 33 of file shapelistmanager.h.


Public Member Functions

virtual IMPORT_C  ~CShapeListManager ()
IMPORT_C void  Clear ()
IMPORT_C void  AddShapeL (NShapes::TShape *aShape)
IMPORT_C NShapes::TShape *  GetNextShape ()
IMPORT_C TStreamId  StoreL (CStreamStore &aStore) const
IMPORT_C void  ExternalizeL (RWriteStream &aStream) const
IMPORT_C void  RestoreL (const CStreamStore &aStore, const TStreamId &aStreamId)
IMPORT_C void  InternalizeL (RReadStream &aStream)

Static Public Member Functions

static IMPORT_C CShapeListManager *  NewL ()
static IMPORT_C CShapeListManager *  NewLC ()

Protected Member Functions

IMPORT_C  CShapeListManager ()
IMPORT_C void  ConstructL ()

Private Attributes

TInt  iNextShapeIndex
RPointerArray< NShapes::TShape >  iShapeList


Constructor & Destructor Documentation

EXPORT_C CShapeListManager::~CShapeListManager (   )  [virtual]
 

~CShapeListManager. Virtual destructor.

Definition at line 78 of file shapelistmanager.cpp.

References iShapeList.

00079     {
00080     iShapeList.ResetAndDestroy();
00081     }

EXPORT_C CShapeListManager::CShapeListManager (   )  [protected]
 

CShapeListManager C++ default constructor.

Definition at line 33 of file shapelistmanager.cpp.

00034     {
00035     //  No implementation required
00036     }


Member Function Documentation

EXPORT_C CShapeListManager * CShapeListManager::NewL (   )  [static]
 

NewL Creates a new instance of the engine.

Returns:
Returns the engine

Definition at line 43 of file shapelistmanager.cpp.

References NewLC().

Referenced by CGuiEngineDocument::ConstructL(), and CGuiEngineDocument::RestoreL().

00044     {
00045     CShapeListManager* self = NewLC();
00046     CleanupStack::Pop( self );
00047     return self;
00048     }

EXPORT_C CShapeListManager * CShapeListManager::NewLC (   )  [static]
 

NewLC Creates a new instance of the engine.

Returns:
Returns the engine

Definition at line 55 of file shapelistmanager.cpp.

References ConstructL().

Referenced by NewL().

00056     {
00057     CShapeListManager* self = new ( ELeave ) CShapeListManager;
00058     CleanupStack::PushL( self );
00059     self->ConstructL();
00060     return self;
00061     }

EXPORT_C void CShapeListManager::Clear (   ) 
 

Clear Clear the list of shapes.

Definition at line 89 of file shapelistmanager.cpp.

References iNextShapeIndex, and iShapeList.

Referenced by CGuiEngineAppView::Clear(), and RestoreL().

00090     {
00091     iNextShapeIndex = 0;    //  The first shape in the list
00092     iShapeList.ResetAndDestroy();
00093     }

EXPORT_C void CShapeListManager::AddShapeL (  NShapes::TShape *  aShape  ) 
 

AddShapeL Add a shape to the list

Parameters:
aShape  the object to add to the list.

Definition at line 100 of file shapelistmanager.cpp.

References iShapeList.

Referenced by CGuiEngineAppView::OfferKeyEventL().

00101     {
00102     User::LeaveIfError( iShapeList.Append( aShape ) );
00103     }

EXPORT_C TShape * CShapeListManager::GetNextShape (   ) 
 

GetNextShape Returns the next shape in the list and increments the next shape index.

Returns:
If there is no such shape, then it returns NULL, and resets the next shape index.

Definition at line 110 of file shapelistmanager.cpp.

References iNextShapeIndex, and iShapeList.

Referenced by CGuiEngineAppView::Draw().

00111     {
00112     if ( iShapeList.Count() > 0)
00113         {
00114         if ( iNextShapeIndex < iShapeList.Count())
00115             {
00116             TShape* shape = iShapeList[ iNextShapeIndex ];
00117             ++iNextShapeIndex;
00118             return shape;
00119             }
00120         //  Gone past the end, so reset the index
00121         iNextShapeIndex = 0;
00122         }
00123     return NULL;
00124     }

EXPORT_C TStreamId CShapeListManager::StoreL (  CStreamStore &  aStore  )  const
 

StoreL Store the instance to the specified store

Parameters:
aStore  the store to stream the object to
Returns:
Returns the id of the store within the stream.

Definition at line 131 of file shapelistmanager.cpp.

References ExternalizeL().

Referenced by CGuiEngineDocument::StoreL().

00132     {
00133 
00134     RStoreWriteStream stream;
00135 
00136     // Create a stream within the store
00137     TStreamId id = stream.CreateLC( aStore );
00138 
00139     // Write the data to the stream
00140     ExternalizeL( stream );
00141     stream.CommitL();
00142 
00143     CleanupStack::PopAndDestroy(); // the stream
00144 
00145     return id; // return the stream ID
00146     }

EXPORT_C void CShapeListManager::ExternalizeL (  RWriteStream &  aStream  )  const
 

ExternalizeL Virtual method that writes the shape to the specified write stream.

Parameters:
aStream  the stream to write the shape to.

Definition at line 153 of file shapelistmanager.cpp.

References NShapes::TShape::ExternalizeL(), and iShapeList.

Referenced by StoreL().

00154     {
00155 
00156     TInt count = iShapeList.Count();
00157     aStream.WriteInt16L( static_cast<TInt16>( count ) );
00158 
00159     for ( TInt index = 0; index < count; ++index )
00160         {
00161         const TShape* shape = static_cast<TShape*>( iShapeList[ index ] );
00162         shape->ExternalizeL( aStream );
00163         }
00164     }

EXPORT_C void CShapeListManager::RestoreL (  const CStreamStore &  aStore,
const TStreamId &  aStreamId
) 
 

RestoreL Restore the instance from the specified stream within the specified store

Parameters:
aStore  the store containing the data
aStreamId  the id of the stream within the store

Definition at line 171 of file shapelistmanager.cpp.

References Clear(), and InternalizeL().

Referenced by CGuiEngineDocument::RestoreL().

00173     {
00174 
00175     Clear();
00176     RStoreReadStream stream;
00177 
00178     // Open the stream
00179     stream.OpenLC( aStore, aStreamId );
00180 
00181     // Read the data from the stream
00182     InternalizeL( stream );
00183 
00184     CleanupStack::PopAndDestroy(); // the stream
00185     }

EXPORT_C void CShapeListManager::InternalizeL (  RReadStream &  aStream  ) 
 

InternalizeL Restore the instance from the specified stream

Parameters:
aStream  the stream to stream the object from

Definition at line 192 of file shapelistmanager.cpp.

References NShapes::TShape::InternalizeL(), and iShapeList.

Referenced by RestoreL().

00193     {
00194 
00195     TInt count = aStream.ReadInt16L();
00196     for ( TInt index = 0; index < count; ++index )
00197         {
00198 
00199         TShape* shape = NULL;
00200         switch ( TShape::ReadShapeTypeL( aStream ) )
00201             {
00202             case KRectangle:
00203                 shape = new ( ELeave ) TRectangle();
00204                 break;
00205 
00206             case KCircle:
00207                 shape = new ( ELeave ) TCircle();
00208                 break;
00209 
00210             default:
00211                 User::Leave( KErrCorrupt );
00212             }
00213 
00214 
00215         CleanupStack::PushL( shape );
00216         shape->InternalizeL( aStream );
00217         User::LeaveIfError( iShapeList.Append( shape ) );
00218 
00219         CleanupStack::Pop( shape ); //  Now owned by iShapeList
00220         }
00221     }

EXPORT_C void CShapeListManager::ConstructL (   )  [protected]
 

ConstructL 2nd phase constructor.

Definition at line 68 of file shapelistmanager.cpp.

Referenced by NewLC().

00069     {
00070     //  No implementation required
00071     }


Member Data Documentation

TInt CShapeListManager::iNextShapeIndex [private]
 

iNextShapeIndex The index of the next shape

Definition at line 137 of file shapelistmanager.h.

Referenced by Clear(), and GetNextShape().

RPointerArray<NShapes::TShape> CShapeListManager::iShapeList [private]
 

iShapeList The list of shapes

Definition at line 140 of file shapelistmanager.h.

Referenced by AddShapeL(), Clear(), ExternalizeL(), GetNextShape(), InternalizeL(), and ~CShapeListManager().


The documentation for this class was generated from the following files:

© Nokia 2009

Back to top