internetradio2.0/uiinc/irchangeobserver.h
changeset 3 ee64f059b8e1
parent 2 2e1adbfc62af
child 4 3f2d53f144fe
child 5 0930554dc389
equal deleted inserted replaced
2:2e1adbfc62af 3:ee64f059b8e1
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef IRCHANGEOBSERVER_H
       
    20 #define IRCHANGEOBSERVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32property.h>
       
    24 
       
    25 /**
       
    26  * MIRChangeObserver
       
    27  * Abstract interface for handling property change events.
       
    28  */
       
    29 class MIRChangeObserver
       
    30 	{
       
    31 	public:
       
    32 	/**
       
    33 	 * This is a callback function which is called when a property value of type int is changed.
       
    34 	 * @param aCategory UID of Publish And Subscribe category
       
    35 	 * @param aKey subkey to specify the category event; to be used with Publish And Subscribe
       
    36 	 * @param aValue the new value
       
    37 	 */
       
    38 	 virtual void HandleChangeL(const TUid& aCategory, const TUint aKey, 
       
    39 	 	const TInt aValue) = 0;
       
    40 	};
       
    41 
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 /**
       
    46  * CIRObserver Observer class that observes changes of Property values and propogates them further.
       
    47  * The class defines a handle to a property, a single data value representing
       
    48  * an item of state information.
       
    49  *
       
    50  * @Code
       
    51  *
       
    52  * Updates an int value reference in correspondence 
       
    53  * with the current Property value
       
    54  * CIRObserver::GetValue(TInt& aValue)
       
    55  *
       
    56  * @endcode
       
    57  */
       
    58 class CIRObserver:public CActive
       
    59 	{
       
    60 public:
       
    61 	/**
       
    62      * Two-phased constructor.
       
    63      * @param aObserver a reference to the observer interface implementer
       
    64      * @param aCategory UID of Publish And Subscribe category
       
    65      * @param aKey subkey to specify the category event; to be used with Publish And Subscribe
       
    66      * @param aPropertyType property type to observe
       
    67      */
       
    68 	static CIRObserver* NewL(MIRChangeObserver& aObserver,const TUid& aCategory, 
       
    69 		const TUint aKey,const RProperty::TType aPropertyType);
       
    70 		
       
    71 	/**
       
    72      * Destructor.
       
    73      */	
       
    74 	~CIRObserver();
       
    75 	
       
    76 	/**
       
    77      * Updates an int value reference in correspondence with the current Property value
       
    78      * @param aValue handle to a value which will be updated
       
    79      */
       
    80 	void GetValue(TInt& aValue) const;
       
    81 	
       
    82 protected:  // Functions from base classes
       
    83 
       
    84     /**
       
    85      * From CActive
       
    86      * Handles an active object’s request completion event
       
    87      */
       
    88     void RunL();
       
    89 
       
    90     /**
       
    91      * From CActive, 
       
    92      * Cancels and outstanding request
       
    93      */
       
    94     void DoCancel();
       
    95 
       
    96 private:
       
    97 	/**
       
    98      * C++ default constructor.
       
    99      * @param aObserver a reference to the observer interface implementer
       
   100      * @param aCategory UID of Publish And Subscribe category
       
   101      * @param aKey subkey to specify the category event; to be used with Publish And Subscribe
       
   102      * @param aPropertyType property type to observe
       
   103      **/
       
   104 	CIRObserver(MIRChangeObserver& aObserver, const TUid& aCategory, 
       
   105 		const TUint aKey, const RProperty::TType aPropertyType);
       
   106 		
       
   107 	/**
       
   108      * default Symbian 2nd phase constructor.
       
   109      */
       
   110 	void ConstructL();
       
   111 	
       
   112 
       
   113 private:
       
   114 
       
   115 	//Value of a subscribed category property of type int.
       
   116  	TInt                        iValueInt;
       
   117 	
       
   118 	// handle to Publish And Subscribe component
       
   119     RProperty                   iProperty;
       
   120 
       
   121 	MIRChangeObserver&  iObserver;
       
   122     // UID of Publish And Subscribe category
       
   123     TUid                        iCategory;
       
   124     // subkey to be used with Publish And Subscribe
       
   125     TUint                       iKey;
       
   126     //Type of the observed property.
       
   127     RProperty::TType            iPropertyType;
       
   128 
       
   129 	};
       
   130 
       
   131 #endif // IRCHANGEOBSERVER_H