contextframework/cfw/inc/cfserver/CFCacheElement.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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 "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:  CCFCacheElement class declaration.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CFCACHEELEMENT_H
       
    20 #define C_CFCACHEELEMENT_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "cfcontextobject.h"
       
    25 
       
    26 class CCFContextSubscriptionImpl;
       
    27 class MCFContextSource;
       
    28 
       
    29 /**
       
    30 * Encapsulates one cache element.
       
    31 */
       
    32 NONSHARABLE_CLASS( CCFCacheElement ): public CBase
       
    33     {
       
    34     public:
       
    35     
       
    36         static CCFCacheElement* NewL ();
       
    37         static CCFCacheElement* NewLC ();
       
    38         
       
    39         ~CCFCacheElement();
       
    40         
       
    41     public: // New methods
       
    42     
       
    43         /**
       
    44         * Returns context object associated in this cache element.
       
    45         * 
       
    46         * @since S60 5.0
       
    47         * @param None
       
    48         * @return CCFContextObject&
       
    49         */
       
    50         CCFContextObject& Context() const;
       
    51 
       
    52         /**
       
    53         * Adds a new subscription in to the cache element.
       
    54         * 
       
    55         * @since S60 5.0
       
    56         * @param aSubscription New subscription.
       
    57         * @return None
       
    58         */
       
    59         void AddSubscriptionL( CCFContextSubscriptionImpl& aSubscription );
       
    60 
       
    61         /**
       
    62         * Removes a subscription from the cache element.
       
    63         * 
       
    64         * @since S60 5.0
       
    65         * @param aIndex Index to the subscription in the array to remove.
       
    66         * @return None
       
    67         */
       
    68         void RemoveSubscription( TInt aIndex );
       
    69 
       
    70         /**
       
    71         * Nullifies a subscription from the cache element by setting the pointer
       
    72         * NULL.
       
    73         * 
       
    74         * @since S60 5.0
       
    75         * @param aIndex Index to the subscription in the array to nullify.
       
    76         * @return None
       
    77         */
       
    78         void NullifySubscription( TInt aIndex );
       
    79 
       
    80         /**
       
    81         * Removes all NULL subscriptions from the cache element.
       
    82         * 
       
    83         * @since S60 5.0
       
    84         * @return None
       
    85         */
       
    86         void RemoveNullSubscriptions();
       
    87 
       
    88         /**
       
    89         * Returns subscriptions associated in this cache element.
       
    90         * 
       
    91         * @since S60 5.0
       
    92         * @param None
       
    93         * @return RPointerArray<CCFContextSubscriptionImpl>&
       
    94         */
       
    95         const RPointerArray<CCFContextSubscriptionImpl>& Subscriptions() const;
       
    96         
       
    97         /**
       
    98         * Set a read security policy associated in this cache element.
       
    99         * 
       
   100         * @since S60 5.0
       
   101         * @param aSecurityPolicy Security policy associated to
       
   102         *  this cache element.
       
   103         * @return None.
       
   104         */
       
   105         void SetReadSecurityPolicy( const TSecurityPolicy& aSecurityPolicy );
       
   106         
       
   107         /**
       
   108         * Returns read security policy associated in this cache element.
       
   109         * 
       
   110         * @since S60 5.0
       
   111         * @param None
       
   112         * @return const TSecurityPolicy&
       
   113         */
       
   114         const TSecurityPolicy& GetReadSecurityPolicy() const;
       
   115 
       
   116         /**
       
   117          * Set a write security policy associated in this cache element.
       
   118          * 
       
   119          * @since S60 5.0
       
   120          * @param aSecurityPolicy Security policy associated to
       
   121          *  this cache element.
       
   122          * @return None.
       
   123          */
       
   124         void SetWriteSecurityPolicy( const TSecurityPolicy& aSecurityPolicy );
       
   125          
       
   126          /**
       
   127          * Returns write security policy associated in this cache element.
       
   128          * 
       
   129          * @since S60 5.0
       
   130          * @param None
       
   131          * @return const TSecurityPolicy&
       
   132          */
       
   133          const TSecurityPolicy& GetWriteSecurityPolicy() const;
       
   134 
       
   135          /**
       
   136           * Sets the context source of this cache element.
       
   137           * @param aContextPublisher Publisher of the context.
       
   138           * Can also be set to NULL.
       
   139           */
       
   140          void SetContextPublisher( MCFContextSource* aContextPublisher );
       
   141 
       
   142          /**
       
   143           * Sets the context source of this cache element.
       
   144           * @param aContextPublisher Publisher of the context.
       
   145           * Can also be set to NULL.
       
   146           * @param aUid Context publisher's uid.
       
   147           */
       
   148          void SetContextPublisher(
       
   149                 MCFContextSource* aContextPublisher, const TUid& aUid );
       
   150 
       
   151          /**
       
   152           * Get the context source of this cache element.
       
   153           * @return Cache element, may be NULL if not given.
       
   154           */
       
   155          const MCFContextSource* ContextPublisher() const;
       
   156          
       
   157 
       
   158          /**
       
   159           * Get UID of the context publisher process.
       
   160           * @return UID of the context publisher process.
       
   161           */
       
   162          const TUid& PublisherUid() const;
       
   163 
       
   164          
       
   165         /**
       
   166         * Compares two cache elements by source and type.
       
   167         * 
       
   168         * @since S60 5.0
       
   169         * @param aFirst First cache element.
       
   170         * @param aSecond Second cache element.
       
   171         * @return KErrNone if same.
       
   172         */
       
   173         static TInt CompareByTypeAndSource(
       
   174             const CCFCacheElement& aFirst,
       
   175             const CCFCacheElement& aSecond );
       
   176 
       
   177         /**
       
   178         * Compares two cache elements by type.
       
   179         * 
       
   180         * @since S60 5.0
       
   181         * @param aFirst First cache element.
       
   182         * @param aSecond Second cache element.
       
   183         * @return KErrNone if same.
       
   184         */
       
   185         static TInt CompareByType(
       
   186             const CCFCacheElement& aFirst,
       
   187             const CCFCacheElement& aSecond );
       
   188             
       
   189     private:
       
   190 
       
   191         CCFCacheElement();
       
   192         void ConstructL();
       
   193         
       
   194     private: // Data
       
   195     
       
   196         // Own: Context related to the cache element
       
   197         CCFContextObject* iContext;
       
   198         
       
   199         // Own: Subscriptions for the context
       
   200         RPointerArray<CCFContextSubscriptionImpl> iSubscriptions;
       
   201         
       
   202         // Own: Read security policy for the context
       
   203         TSecurityPolicy iReadSecurityPolicy;
       
   204         
       
   205         // Own: Write security policy for the context
       
   206         TSecurityPolicy iWriteSecurityPolicy;
       
   207         
       
   208         // Ref: Reference to the provider of this context
       
   209         MCFContextSource* iPublisher;
       
   210         
       
   211         // Own: UID of the context publisher;
       
   212         TUid iPublisherUid;
       
   213         
       
   214     };
       
   215 
       
   216 #endif