mmhais/dvbhreceiverhai/hai/dvbh/teststubs/dvbhreceiverinfoobserver.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Declares the internal observer classes used by CDvbhReceiverInfo.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21  @prototype
       
    22 */
       
    23 
       
    24 #ifndef DVBHRECEIVERINFOOBSERVER_H
       
    25 #define DVBHRECEIVERINFOOBSERVER_H
       
    26 
       
    27 #include "dvbhstubcommon.h"
       
    28 #include <e32property.h>
       
    29 #include <e32cons.h>
       
    30 
       
    31 class MDvbhStateObserver;
       
    32 class MDvbhSignalQualityObserver;
       
    33 class MDvbhPlatformObserver;
       
    34 class MDvbhNetworkTimeObserver;
       
    35 class MDvbhFrequencyObserver;
       
    36 class MDvbhCellIdObserver;
       
    37 class MDvbhNetworkIdObserver;
       
    38 class MDvbhExtBatteryStateObserver;
       
    39 class MDvbhExtConnectionObserver;
       
    40 class MDvbhExtAntennaConnectionObserver;
       
    41 
       
    42 /**
       
    43 * Interface to abstract the callback to be called when an RProperty changes. 
       
    44 */
       
    45 class MPropertyNotifier
       
    46 	{
       
    47 public:
       
    48 	/**
       
    49 	* Callback to be called when an RProperty changes.
       
    50 	* Implementations will probably want to call the appropriate callback on an external observer object.
       
    51 	* @param aProperty A handle to the RProperty that has just changed.
       
    52 	*/
       
    53 	virtual void NotifyPropertyChanged(RProperty& aProperty) = 0;
       
    54 	
       
    55 	/**
       
    56 	* Called to get the key of the property of interest.
       
    57 	* @return the key value.
       
    58 	*/
       
    59 	virtual TInt GetPropertyKey() const = 0;
       
    60 	};
       
    61 
       
    62 /**
       
    63 * CDvbhPropertyObserver is the class used to observer changes to an RProperty.
       
    64 *
       
    65 * To observer changes to a particular RProperty, users must call 
       
    66 * CDvbhPropertyObserver::SetObserver() passing in an MPropertyNotifier 
       
    67 * implementation corresponding to the RProperty of interest.  
       
    68 * When the RProperty changes, CDvbhPropertyObserver::RunL() will call 
       
    69 * MPropertyNotifier::NotifyPropertyChanged() of the implementation. 
       
    70 */
       
    71 NONSHARABLE_CLASS(CDvbhPropertyObserver) : public CActive
       
    72 	{
       
    73 public:
       
    74 	CDvbhPropertyObserver();
       
    75 	~CDvbhPropertyObserver();
       
    76 	TInt SetObserver(MPropertyNotifier* aPropertyNotifier);
       
    77 
       
    78 private: 
       
    79 	void RunL();
       
    80 	void DoCancel();
       
    81 	
       
    82 private:
       
    83 	MPropertyNotifier* iPropertyNotifier; //Not owned
       
    84 	RProperty iProperty;
       
    85 	};
       
    86 
       
    87 /**
       
    88 * Thin template base class for the RProperty notifiers.
       
    89 */
       
    90 NONSHARABLE_CLASS(TDvbhNotifierBase)
       
    91 	{
       
    92 protected:
       
    93 	TDvbhNotifierBase();
       
    94 	void SetExternalObserver(TAny* aObserver);
       
    95 protected:
       
    96 	TAny* iExternalObserver; //Not owned
       
    97 	};
       
    98 
       
    99 /**
       
   100 * Template on which RProperty Notifiers are based.  Contains all the
       
   101 * code common to a Notifier for any RProperty.
       
   102 *
       
   103 * The template parameter OBSERVER must be one of the observer M-classes declard in dvbhreceiverinfo.h.
       
   104 */
       
   105 template<class OBSERVER>
       
   106 NONSHARABLE_CLASS(TDvbhNotifier) : protected TDvbhNotifierBase
       
   107 	{
       
   108 public:
       
   109 	inline void SetExternalObserver(OBSERVER* aObserver);
       
   110 	};
       
   111 	
       
   112 /**
       
   113 * The state notifier for CDvbhReceiverInfo::CPrivateData. 
       
   114 */	
       
   115 NONSHARABLE_CLASS(TDvbhStateNotifier) : public TDvbhNotifier<MDvbhStateObserver>,
       
   116 										public MPropertyNotifier
       
   117 	{
       
   118 public:
       
   119 	virtual TInt GetPropertyKey() const;
       
   120 	virtual void NotifyPropertyChanged(RProperty& aProperty);
       
   121 	};
       
   122 
       
   123 /**
       
   124 * The SignalQuality notifier for CDvbhReceiverInfo::CPrivateData. 
       
   125 */	
       
   126 NONSHARABLE_CLASS(TDvbhSignalQualityNotifier) : public TDvbhNotifier<MDvbhSignalQualityObserver>,
       
   127 												public MPropertyNotifier
       
   128 	{
       
   129 public:
       
   130 	virtual TInt GetPropertyKey() const;
       
   131 	virtual void NotifyPropertyChanged(RProperty& aProperty);
       
   132 	};
       
   133 
       
   134 /**
       
   135 * The Platform notifier for CDvbhReceiverInfo::CPrivateData. 
       
   136 */	
       
   137 NONSHARABLE_CLASS(TDvbhPlatformNotifier) : public TDvbhNotifier<MDvbhPlatformObserver>,
       
   138 										   public MPropertyNotifier
       
   139 	{
       
   140 public:
       
   141 	virtual TInt GetPropertyKey() const;
       
   142 	virtual void NotifyPropertyChanged(RProperty& aProperty);
       
   143 	};
       
   144 
       
   145 /**
       
   146 * The NetworkTime notifier for CDvbhReceiverInfo::CPrivateData. 
       
   147 */	
       
   148 NONSHARABLE_CLASS(TDvbhNetworkTimeNotifier) : public TDvbhNotifier<MDvbhNetworkTimeObserver>,
       
   149 											  public MPropertyNotifier
       
   150 	{
       
   151 public:
       
   152 	virtual TInt GetPropertyKey() const;
       
   153 	virtual void NotifyPropertyChanged(RProperty& aProperty);
       
   154 	};
       
   155 
       
   156 /**
       
   157 * The Frequency notifier for CDvbhReceiverInfo::CPrivateData. 
       
   158 */	
       
   159 NONSHARABLE_CLASS(TDvbhFrequencyNotifier) : public TDvbhNotifier<MDvbhFrequencyObserver>,
       
   160 											public MPropertyNotifier
       
   161 	{
       
   162 public:
       
   163 	virtual TInt GetPropertyKey() const;
       
   164 	virtual void NotifyPropertyChanged(RProperty& aProperty);
       
   165 	};
       
   166 
       
   167 /**
       
   168 * The CellId notifier for CDvbhReceiverInfo::CPrivateData. 
       
   169 */	
       
   170 NONSHARABLE_CLASS(TDvbhCellIdNotifier) : public TDvbhNotifier<MDvbhCellIdObserver>,
       
   171 										 public MPropertyNotifier
       
   172 	{
       
   173 public:
       
   174 	virtual TInt GetPropertyKey() const;
       
   175 	virtual void NotifyPropertyChanged(RProperty& aProperty);
       
   176 	};
       
   177 
       
   178 /**
       
   179 * The NetworkId notifier for CDvbhReceiverInfo::CPrivateData. 
       
   180 */	
       
   181 NONSHARABLE_CLASS(TDvbhNetworkIdNotifier) : public TDvbhNotifier<MDvbhNetworkIdObserver>,
       
   182 											public MPropertyNotifier
       
   183 	{
       
   184 public:
       
   185 	virtual TInt GetPropertyKey() const;
       
   186 	virtual void NotifyPropertyChanged(RProperty& aProperty);
       
   187 	};
       
   188 
       
   189 /**
       
   190 * The battery state for CDvbhReceiverInfo::CPrivateData. 
       
   191 */	
       
   192 NONSHARABLE_CLASS(TDvbhExtBatteryStateNotifier) : public TDvbhNotifier<MDvbhExtBatteryStateObserver>,
       
   193 											     public MPropertyNotifier
       
   194 	{
       
   195 public:
       
   196 	virtual TInt GetPropertyKey() const;
       
   197 	virtual void NotifyPropertyChanged(RProperty& aProperty);
       
   198 	};
       
   199 
       
   200 /**
       
   201 * The connection state for CDvbhReceiverInfo::CPrivateData. 
       
   202 */	
       
   203 NONSHARABLE_CLASS(TDvbhExtConnectionStateNotifier) : public TDvbhNotifier<MDvbhExtConnectionObserver>,
       
   204 											         public MPropertyNotifier
       
   205 	{
       
   206 public:
       
   207 	virtual TInt GetPropertyKey() const;
       
   208 	virtual void NotifyPropertyChanged(RProperty& aProperty);
       
   209 	};
       
   210     
       
   211 /**
       
   212 * The connection state for CDvbhReceiverInfo::CPrivateData. 
       
   213 */	
       
   214 NONSHARABLE_CLASS(TMtvAccConnectionStateNotifier) : public TDvbhNotifier<MDvbhExtConnectionObserver>,
       
   215 											        public MPropertyNotifier
       
   216 	{
       
   217 public:
       
   218 	virtual TInt GetPropertyKey() const;
       
   219 	virtual void NotifyPropertyChanged(RProperty& aProperty);
       
   220 	};
       
   221 
       
   222 /**
       
   223 * The antenna connection state for CDvbhReceiverInfo::CPrivateData. 
       
   224 */	
       
   225 NONSHARABLE_CLASS(TMtvAccAntennaConnectionStateNotifier) : public TDvbhNotifier<MDvbhExtAntennaConnectionObserver>,
       
   226 											               public MPropertyNotifier
       
   227 	{
       
   228 public:
       
   229 	virtual TInt GetPropertyKey() const;
       
   230 	virtual void NotifyPropertyChanged(RProperty& aProperty);
       
   231 	};
       
   232 
       
   233 
       
   234 #include "dvbhreceiverinfoobserver.inl"
       
   235  
       
   236 #endif //DVBHRECEIVERINFOOBSERVER_H
       
   237 
       
   238 
       
   239 
       
   240 
       
   241