sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: sl@0: sl@0: #ifndef __ATTRIBUTESET_H__ sl@0: #define __ATTRIBUTESET_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: class RReadStream; sl@0: class RWriteStream; sl@0: sl@0: namespace ContentAccess sl@0: { sl@0: sl@0: /** Holds the values of a predefined set of attributes based upon sl@0: ContentAccess::TAttribute sl@0: sl@0: It is also possible for an agent to provide an extended set of these sl@0: attributes beyond EAgentSpecificAttributeBase but only applications written sl@0: to support that particular agent will support this. sl@0: sl@0: No duplicate attributes are allowed in the set sl@0: */ sl@0: class RAttributeSet sl@0: { sl@0: /** Holds the value of an attribute along with any error encountered sl@0: while retrieving the attribute sl@0: */ sl@0: class TAttributeValue sl@0: { sl@0: public: sl@0: TInt iAttribute; sl@0: TInt iValue; sl@0: TInt iError; sl@0: }; sl@0: sl@0: public: sl@0: IMPORT_C RAttributeSet(); sl@0: sl@0: /** Release all resources used by the RAttributeSet sl@0: sl@0: This must be called before the RAttribute set goes out of scope sl@0: */ sl@0: IMPORT_C void Close(); sl@0: sl@0: /** Add a new attribute to the set sl@0: The attribute is initalised with a default value of EAttributeNotSupported sl@0: sl@0: @param aAttribute The attribute to add to the set sl@0: */ sl@0: IMPORT_C void AddL(TInt aAttribute); sl@0: sl@0: /** Get the value of a specified attribute sl@0: @param aAttribute The attribute to query sl@0: @param aValue The value of the attribute sl@0: @return Whether the value parameter was updated sl@0: @return KErrNone The attribute value was updated sl@0: @return KErrNotFound The attribute is not part of the set sl@0: */ sl@0: IMPORT_C TInt GetValue(TInt aAttribute, TInt& aValue) const; sl@0: sl@0: /** Set the value of an attribute within the set sl@0: @param aAttribute The attribute to set sl@0: @param aValue The value of the attribute sl@0: @param aErrorCode The error code to return when this attribute is requested via the GetValue() function sl@0: @return Whether the new attribute value was set sl@0: @return KErrNone if the value was set sl@0: @return KErrNotFound if the attribute is not part of the set sl@0: */ sl@0: IMPORT_C TInt SetValue(TInt aAttribute, TInt aValue, TInt aErrorCode); sl@0: sl@0: /** Find the attribute stored at a particular index in the set sl@0: @param aIndex The index of the attribute sl@0: @return The attribute, NOT the value of the attribute sl@0: */ sl@0: IMPORT_C TInt operator [] (TInt aIndex) const; sl@0: sl@0: /** The number of attributes in the set sl@0: @return The number of attributes in the set sl@0: */ sl@0: IMPORT_C TInt Count() const; sl@0: sl@0: /** Write the RAttributeSet to a stream sl@0: @param aStream The stream to write the attribute set to sl@0: */ sl@0: IMPORT_C void ExternalizeL(RWriteStream& aStream) const; sl@0: sl@0: /** Read the RAttributeSet from a stream sl@0: This does not clear the contents of the attribute set before reading. The sl@0: values of any attributes already in the set are updated with new values sl@0: from the stream. New attributes from the stream and their values are added sl@0: to the set. sl@0: @param aStream The stream to read the attribute set from sl@0: */ sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: sl@0: private: sl@0: void AddL(TInt aAttribute, TInt aValue, TInt aErrorCode); sl@0: sl@0: RArray iAttributes; sl@0: }; sl@0: } sl@0: #endif