1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/caf/attributeset.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,131 @@
1.4 +/*
1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +
1.24 +/**
1.25 + @file
1.26 + @publishedPartner
1.27 + @released
1.28 +*/
1.29 +
1.30 +
1.31 +#ifndef __ATTRIBUTESET_H__
1.32 +#define __ATTRIBUTESET_H__
1.33 +
1.34 +#include <e32base.h>
1.35 +#include <caf/caftypes.h>
1.36 +
1.37 +class RReadStream;
1.38 +class RWriteStream;
1.39 +
1.40 +namespace ContentAccess
1.41 + {
1.42 +
1.43 + /** Holds the values of a predefined set of attributes based upon
1.44 + ContentAccess::TAttribute
1.45 +
1.46 + It is also possible for an agent to provide an extended set of these
1.47 + attributes beyond EAgentSpecificAttributeBase but only applications written
1.48 + to support a that particular agent will support this.
1.49 +
1.50 + No duplicate attributes are allowed in the set
1.51 +
1.52 + @publishedPartner
1.53 + @released
1.54 + */
1.55 + class RAttributeSet
1.56 + {
1.57 + /** Holds the value of an attribute along with any error encountered
1.58 + while retrieving the attribute
1.59 + */
1.60 + class TAttributeValue
1.61 + {
1.62 + public:
1.63 + TInt iAttribute;
1.64 + TInt iValue;
1.65 + TInt iError;
1.66 + };
1.67 +
1.68 + public:
1.69 + IMPORT_C RAttributeSet();
1.70 +
1.71 + /** Release all resources used by the RAttributeSet
1.72 +
1.73 + This must be called before the RAttribute set goes out of scope
1.74 + */
1.75 + IMPORT_C void Close();
1.76 +
1.77 + /** Add a new attribute to the set
1.78 + The attribute is initalised with a default value of EAttributeNotSupported
1.79 +
1.80 + @param aAttribute The attribute to add to the set
1.81 + */
1.82 + IMPORT_C void AddL(TInt aAttribute);
1.83 +
1.84 + /** Get the value of a specified attribute
1.85 + @param aAttribute The attribute to query
1.86 + @param aValue The value of the attribute
1.87 + @return Whether the value parameter was updated
1.88 + @return KErrNone The attribute value was updated
1.89 + @return KErrNotFound The attribute is not part of the set
1.90 + */
1.91 + IMPORT_C TInt GetValue(TInt aAttribute, TInt& aValue) const;
1.92 +
1.93 + /** Set the value of an attribute within the set
1.94 + @param aAttribute The attribute to set
1.95 + @param aValue The value of the attribute
1.96 + @param aErrorCode The error code to return when this attribute is requested via the GetValue() function
1.97 + @return Whether the new attribute value was set
1.98 + @return KErrNone if the value was set
1.99 + @return KErrNotFound if the attribute is not part of the set
1.100 + */
1.101 + IMPORT_C TInt SetValue(TInt aAttribute, TInt aValue, TInt aErrorCode);
1.102 +
1.103 + /** Find the attribute stored at a particular index in the set
1.104 + @param aIndex The index of the attribute
1.105 + @return The attribute, NOT the value of the attribute
1.106 + */
1.107 + IMPORT_C TInt operator [] (TInt aIndex) const;
1.108 +
1.109 + /** The number of attributes in the set
1.110 + @return The number of attributes in the set
1.111 + */
1.112 + IMPORT_C TInt Count() const;
1.113 +
1.114 + /** Write the RAttributeSet to a stream
1.115 + @param aStream The stream to write the attribute set to
1.116 + */
1.117 + IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
1.118 +
1.119 + /** Read the RAttributeSet from a stream
1.120 + This does not clear the contents of the attribute set before reading. The
1.121 + values of any attributes already in the set are updated with new values
1.122 + from the stream. New attributes from the stream and their values are added
1.123 + to the set.
1.124 + @param aStream The stream to read the attribute set from
1.125 + */
1.126 + IMPORT_C void InternalizeL(RReadStream& aStream);
1.127 +
1.128 + private:
1.129 + void AddL(TInt aAttribute, TInt aValue, TInt aErrorCode);
1.130 +
1.131 + RArray <TAttributeValue> iAttributes;
1.132 + };
1.133 + }
1.134 +#endif