os/security/contentmgmt/contentaccessfwfordrm/inc/attributeset.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2004-2009 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 the License "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: 
    15 *
    16 */
    17 
    18 
    19 /**
    20  @file
    21  @publishedAll
    22  @released
    23 */
    24 
    25 
    26 #ifndef __ATTRIBUTESET_H__
    27 #define __ATTRIBUTESET_H__
    28 
    29 #include <e32base.h>
    30 #include <caf/caftypes.h>
    31 
    32 class RReadStream;
    33 class RWriteStream;
    34 
    35 namespace ContentAccess
    36 	{
    37 	
    38 	/** Holds the values of a predefined set of attributes based upon 
    39 	ContentAccess::TAttribute
    40 	
    41 	It is also possible for an agent to provide an extended set of these 
    42 	attributes beyond EAgentSpecificAttributeBase but only applications written 
    43 	to support that particular agent will support this.
    44 
    45 	No duplicate attributes are allowed in the set
    46 	*/
    47 	class RAttributeSet
    48 		{
    49 		/** Holds the value of an attribute along with any error encountered
    50 		while retrieving the attribute
    51 		*/
    52 		class TAttributeValue 
    53 			{
    54 		public:
    55 			TInt iAttribute;
    56 			TInt iValue;
    57 			TInt iError;
    58 			};
    59 
    60 	public:
    61 		IMPORT_C RAttributeSet();
    62 		
    63 		/** Release all resources used by the RAttributeSet
    64 		
    65 		This must be called before the RAttribute set goes out of scope
    66 		*/
    67 		IMPORT_C void Close();
    68 
    69 		/** Add a new attribute to the set
    70 		The attribute is initalised with a default value of EAttributeNotSupported
    71 		
    72 		@param aAttribute The attribute to add to the set
    73 		*/
    74 		IMPORT_C void AddL(TInt aAttribute);
    75 
    76 		/** Get the value of a specified attribute
    77 		@param aAttribute The attribute to query
    78 		@param aValue The value of the attribute
    79 		@return Whether the value parameter was updated
    80 		@return KErrNone The attribute value was updated
    81 		@return KErrNotFound The attribute is not part of the set
    82 		*/
    83 		IMPORT_C TInt GetValue(TInt aAttribute, TInt& aValue) const;
    84 
    85 		/** Set the value of an attribute within the set
    86 		@param aAttribute The attribute to set
    87 		@param aValue The value of the attribute
    88 		@param aErrorCode The error code to return when this attribute is requested via the GetValue() function
    89 		@return Whether the new attribute value was set
    90 		@return KErrNone if the value was set
    91 		@return KErrNotFound if the attribute is not part of the set
    92 		*/
    93 		IMPORT_C TInt SetValue(TInt aAttribute, TInt aValue, TInt aErrorCode);
    94 		
    95 		/** Find the attribute stored at a particular index in the set
    96 		@param aIndex The index of the attribute
    97 		@return The attribute, NOT the value of the attribute
    98 		*/
    99 		IMPORT_C TInt operator [] (TInt aIndex) const;
   100 
   101 		/** The number of attributes in the set
   102 		@return The number of attributes in the set
   103 		*/
   104 		IMPORT_C TInt Count() const;
   105 		
   106 		/** Write the RAttributeSet to a stream
   107 		@param aStream The stream to write the attribute set to
   108 		*/
   109 		IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
   110 
   111 		/** Read the RAttributeSet from a stream
   112 		This does not clear the contents of the attribute set before reading. The 
   113 		values of any attributes already in the set are updated with new values 
   114 		from the stream. New attributes from the stream and their values are added
   115 		to the set.
   116 		@param aStream The stream to read the attribute set from
   117 		*/
   118 		IMPORT_C void InternalizeL(RReadStream& aStream);
   119 
   120 	private:
   121 		void AddL(TInt aAttribute, TInt aValue, TInt aErrorCode);
   122 
   123 		RArray <TAttributeValue> iAttributes;
   124 		};
   125 	}
   126 #endif