Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Using CAnimDll


Implementing CreateInstanceL()

Consider a hypothetical CAnimDll derived class CExampleAnimDll, declared in a header file as follows:

class CExampleAnimDll : public CAnimDll
 {
public:
 virtual CAnim* CreateInstanceL(TInt aType);
 };

A convenient way to implement CreateInstanceL() is to switch on the TInt aType argument, with each switch constructing a different CAnim derived animation class identified by an aType enum, for example if DShapesAnims is one of those classes:

switch(aType)
 {
 // cases
 case EShapesAnims:
  return new(ELeave) DShapesAnims;
 ...
 default:
  iFunctions -> Panic();
  return NULL; // dummy return to prevent compiler error
  }
 }

It is up to the implementer to decide whether receiving a bad parameter should cause a panic, as here, or a leave. The approach shown is recommended.

The Panic() function is a CAnimFunctions helper function, to which CAnim provides the iFunctions pointer. These functions are implemented by the window server and are available to any CAnim derived class.