Creating a light instance

Create an instance of CHWRMLight instance using NewL() or NewLC() methods. After creating the instance, lights can be directly controlled via the provided class methods.

Without notify handling

Create an instance of the CHWRMLight implementation class using the NewL() or NewLC() constructor without a parameter.

The following code snippet demonstrates how to create an instance without notify handling to control the lights of the device:

       CHWRMLight* light = CHWRMLight::NewLC(); // No callbacks
      

With notify handling

Derive a class from the MHWRMLightObserver interface and implement the LightStatusChanged() method.

The following code snippet is an example of the header of the class implemented by the client:

       // INCLUDES
#include HWRMLight.h // Link against HWRMLightClient.lib.
class CLightStatusObserver : public CBase,
                             public MHWRMLightObserver
    {
    public:
        CLightStatusObserver();
        ~CLightStatusObserver();
        void ConstructL();
        static CLightStatusObserver* NewL();
        //from MHWRMLightObserver
        virtual void LightStatusChanged( TInt aTarget,
                                         CHWRMLight::TLightStatus aStatus );
    private:
        CHWRMLight* iLight;
    };
      

Create an instance of the CHWRMLight implementation class using the NewL() or NewLC() constructor with a parameter. This parameter is a pointer to an object that is derived from MHWRMLightObserver . After this, lights can be directly controlled through the provided class methods. Every light status change causes a notification using MHWRMLightObserver::LightStatusChanged() .

The following code snippet demonstrates how to create an instance with notify handling to control the lights of the device:

       void CLightStatusObserver::ConstructL()
    {
    iLight = CHWRMLight::NewL( this )
    }