epoc32/include/mw/aiwgenericparam.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2003-2005 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:     A generic parameter class.
    15 *
    16 */
    17 
    18 
    19 
    20 
    21 
    22 #ifndef AIW_GENERIC_PARAM_H
    23 #define AIW_GENERIC_PARAM_H
    24 
    25 // INCLUDES
    26 #include <e32base.h>
    27 #include "AiwGenericParam.hrh"
    28 #include "AiwVariant.h"
    29 
    30 /**
    31  * AIW generic parameter id. This data type should always be used when dealing 
    32  * with AIW generic parameters. UIDs can be used as AIW generic parameter IDs. 
    33  * However, values from 0 to 131071 are reserved.
    34  * @see TAiwGenericParam 
    35  * @see TGenericParamIdValue
    36  */ 
    37 typedef TInt TGenericParamId;
    38 
    39 // CLASS DECLARATION
    40 
    41 /**
    42 * Generic parameter class for passing data between applications.
    43 * A generic parameter is a pair of semantic ID and
    44 * variant value. The semantic ID tells the purpose of the parameter,
    45 * for example a file name, URL or phone number. The variant value contains
    46 * the data format and actual value. This class does not implement any
    47 * consistency checks between the semantic ID and value's data format.
    48 * So one semantic ID can be expressed as alternative data formats.
    49 *
    50 * @lib ServiceHandler.lib
    51 * @since Series 60 2.6
    52 * @see TAiwVariant
    53 * @see CAiwGenericParamList
    54 */
    55 class TAiwGenericParam
    56     {
    57     public:  // Constructors and destructor
    58         /**
    59         * Constructs a generic parameter.
    60         */
    61         inline TAiwGenericParam();
    62         
    63         /**
    64         * Constructs a generic parameter.
    65         *
    66         * @param aSemanticId The semantic ID of the parameter, one of TGenericParamId values.
    67         */        
    68         inline TAiwGenericParam(TGenericParamId aSemanticId);
    69         
    70         /**
    71         * Constructs a generic parameter.
    72         *
    73         * @param aSemanticId The semantic ID of the parameter, one of TGenericParamId values.
    74         * @param aValue The parameter value.
    75         */        
    76         inline TAiwGenericParam(TGenericParamId aSemanticId, const TAiwVariant& aValue);
    77 
    78     public:  // Interface
    79         /**
    80         * Sets the semantic ID. Possibly set previous ID is overwritten.
    81         *
    82         * @param aSemanticId The semantic ID of the parameter.
    83         */
    84         inline void SetSemanticId(TGenericParamId aSemanticId);
    85 
    86         /**
    87         * Returns the semantic ID of this parameter.
    88         *
    89         * @return The semantic ID.
    90         */
    91         inline TGenericParamId SemanticId() const;
    92 
    93         /**
    94         * Returns the value of this parameter.
    95         *
    96         * @return The value of the parameter.        
    97         */
    98         inline TAiwVariant& Value();
    99 
   100         /**
   101         * Returns the const value of this parameter.
   102         *
   103         * @return The const value of the parameter.        
   104         */
   105         inline const TAiwVariant& Value() const;
   106 
   107         /**
   108         * Resets the semantic ID and the value of this parameter.
   109         */
   110         inline void Reset();
   111 
   112     private:  // Interface for friend classes
   113         void Destroy();
   114         void CopyLC(const TAiwGenericParam& aParam);
   115         static void CleanupDestroy(TAny* aObj);
   116         operator TCleanupItem();
   117         void InternalizeL(RReadStream& aStream);
   118         void ExternalizeL(RWriteStream& aStream) const;
   119         TInt Size() const; 
   120 
   121     private:  // Data
   122         /// Own: semantic ID of this parameter
   123         TGenericParamId iSemanticId;
   124         /// Own: value of this parameter
   125         TAiwVariant iValue;
   126         /// Reserved member
   127         TAny* iReserved;
   128 
   129     private:  // friend declarations
   130         friend class CAiwGenericParamList;
   131     };
   132 
   133 
   134 // FUNCTIONS
   135 
   136 /**
   137 * Returns ETrue if two generic params are equal.
   138 *
   139 * @param aLhs Left hand side.
   140 * @param aRhs Right hand side.
   141 * @return ETrue if equal, EFalse otherwise.
   142 */ 
   143 IMPORT_C TBool operator==(const TAiwGenericParam& aLhs, const TAiwGenericParam& aRhs);
   144 
   145 /**
   146 * Returns ETrue if two generic params are not equal.
   147 *
   148 * @param aLhs Left hand side.
   149 * @param aRhs Right hand side.
   150 * @return ETrue if not equal, EFalse otherwise.
   151 */
   152 inline TBool operator!=(const TAiwGenericParam& aLhs, const TAiwGenericParam& aRhs);
   153         
   154 
   155 /**
   156  * Generic parameter list.
   157  * A list containing TAiwGenericParam objects. Used for passing parameters 
   158  * between consumers and providers.
   159  *
   160  * @lib ServiceHandler.lib
   161  * @since Series 60 2.6
   162  */
   163 NONSHARABLE_CLASS(CAiwGenericParamList): public CBase
   164     {
   165     public:   // Constructors and destructor
   166         /**
   167         * Creates an instance of this class.
   168         *
   169         * @return A pointer to the new instance.
   170         */
   171         IMPORT_C static CAiwGenericParamList* NewL();
   172         
   173         /**
   174         * Creates an instance of this class.
   175         *
   176         * @param aReadStream A stream to initialize this parameter list from.
   177         * @return A pointer to the new instance.
   178         */        
   179         IMPORT_C static CAiwGenericParamList* NewL(RReadStream& aReadStream);
   180 
   181         /**
   182         * Creates an instance of this class. Leaves the created instance on the
   183         * cleanup stack.
   184         *
   185         * @return A pointer to the new instance.
   186         */
   187         IMPORT_C static CAiwGenericParamList* NewLC();
   188         
   189         /**
   190         * Creates an instance of this class. Leaves the created instance on the
   191         * cleanup stack.
   192         *
   193         * @param aReadStream A stream to initialize this parameter list from.
   194         * @return A pointer to the new instance.
   195         */        
   196         IMPORT_C static CAiwGenericParamList* NewLC(RReadStream& aReadStream);
   197 
   198         /**
   199         * Destructor.
   200         */
   201         virtual ~CAiwGenericParamList();
   202         
   203     public:  // Interface
   204         /**
   205         * Returns the number of parameters in the list. 
   206         *
   207         * @return The number of parameters in the list. 
   208         */
   209         IMPORT_C TInt Count() const;
   210         
   211         /**
   212         * Returns the number of the parameters in the list by semantic id and datatype.
   213         *
   214         * @param aSemanticId The semantic ID of the parameter.
   215         * @param aDataType The type id of data. Default is any type.
   216         * @return The number of parameters in the list by semantic id and datatype.
   217         */
   218         IMPORT_C TInt Count(TGenericParamId aSemanticId, 
   219                 TVariantTypeId aDataType = EVariantTypeAny) const;  
   220             
   221         /**
   222         * Returns a parameter from this list.
   223         *
   224         * @param aIndex Index of the parameter.
   225         * @return The parameter at the aIndex position.
   226         * @pre aIndex>=0 && aIndex<Count()
   227         */
   228         IMPORT_C const TAiwGenericParam& operator[](TInt aIndex) const;
   229 
   230         /**
   231         * Appends a parameter to this list.
   232         *
   233         * @param aParam The parameter to append to this list. This object takes
   234         *               an own copy of the data in aParam.
   235         */
   236         IMPORT_C void AppendL(const TAiwGenericParam& aParam);
   237 
   238         /**
   239         * Copies the given list and appends it to end of this list.
   240         *
   241         * @since Series 60 2.8        
   242         * @param aList A list to be copied and appended.
   243         */
   244         IMPORT_C void AppendL(const CAiwGenericParamList& aList);
   245         
   246         /**
   247         * Removes the first found item with given semantic id from the list.
   248         * 
   249         * @param aSemanticId Semantic id for the item to be removed.
   250         * @return  ETrue  if an item for the given semantic id was found and removed.
   251         *          EFalse otherwise.
   252         */
   253         IMPORT_C TBool Remove(TInt aSemanticId);
   254 
   255         /**
   256         * Deletes all parameters in the list and resets the list.
   257         */
   258         IMPORT_C void Reset();
   259 
   260         /**
   261         * Returns the first item matching the given semantic ID.
   262         *
   263         * @param aIndex Position in which to start searching. On return it contains 
   264         *               the position of the found parameter. It is set to KErrNotFound, 
   265         *               if no matching items were found.
   266         * @param aSemanticId The semantic ID of the parameter.
   267         * @param aDataType The type id of data. Default is any type.
   268         * @return The first matching item.
   269         */
   270         IMPORT_C const TAiwGenericParam* FindFirst(
   271             TInt& aIndex, 
   272             TGenericParamId aSemanticId,
   273             TVariantTypeId aDataType = EVariantTypeAny) const;
   274         /**
   275         * Returns the next item matching the given semantic ID.
   276         * 
   277         * @param aIndex Position after which to start searching. On return it contains 
   278         *               the position of the found parameter. It is set to KErrNotFound, 
   279         *               if no matching items were found.
   280         * @param aSemanticId The semantic ID of the parameter.
   281         * @param aDataType The type id of data. Default is any type. 
   282         * @return The next matching item.       
   283         */
   284         IMPORT_C const TAiwGenericParam* FindNext(
   285             TInt& aIndex, 
   286             TGenericParamId aSemanticId,
   287             TVariantTypeId aDataType = EVariantTypeAny) const;
   288         
   289         /**
   290         * Externalizes this parameter list to a stream.
   291         *
   292         * @param aStream The stream. 
   293         * @see NewL(RReadStream& aStream)
   294         * @see NewLC(RReadStream& aStream)
   295         */
   296         IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   297 
   298         /**
   299         * Returns the externalized size of the parameter list in bytes.
   300         *
   301         * @return The size.
   302         */
   303         IMPORT_C TInt Size() const;
   304 
   305         /**
   306         * Internalizes the parameter list from a stream.
   307         *
   308         * @since Series60 2.8
   309         * @param aStream The stream.
   310         */
   311         IMPORT_C void InternalizeL(RReadStream& aStream);
   312 
   313         /**
   314         * Packs the parameter list to TIpcArgs structure for
   315         * passing the generic param list to server over process boundary.
   316         * Only one RFile handle parameter can be passed over process boundary.
   317         *
   318         * @since Series60 3.0
   319         * @param aArgs Inter process call arguments.
   320         * @return Packed parameter list.
   321         */
   322         IMPORT_C HBufC8* PackForServerL(TIpcArgs& aArgs);
   323 
   324         /**
   325         * Unpacks the list from client message structure.
   326         *
   327         * @since Series60 3.0
   328         * @param aArgs The list to be unpacked. 
   329         */
   330         IMPORT_C void UnpackFromClientL(const RMessage2& aArgs);
   331         
   332     private:  // Implementation
   333         CAiwGenericParamList();
   334         void ConstructL();
   335         void AppendL(RReadStream& aReadStream);
   336         
   337     private:  // Data
   338         /// Own: the parameter list
   339         RArray<TAiwGenericParam> iParameters;
   340     };
   341 
   342 
   343 // INLINE FUNCTIONS
   344 #include "AiwGenericParam.inl"
   345 
   346 #endif // AIW_GENERIC_PARAM_H
   347 
   348 // End of File