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