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