contextframework/cfw/inc/cfservices/CFContextQueryImpl.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CFCONTEXTQUERYIMPL_H
       
    20 #define C_CFCONTEXTQUERYIMPL_H
       
    21 
       
    22 #include "cfcontextquery.h"    // defs type & source lengths
       
    23 
       
    24 class RWriteStream;
       
    25 class RReadStream;
       
    26 
       
    27 /**
       
    28 * CCFContextQuery implementation.
       
    29 *
       
    30 * @lib CFServices.lib
       
    31 * @since S60 5.0
       
    32 */
       
    33 NONSHARABLE_CLASS( CCFContextQueryImpl ): public CCFContextQuery
       
    34     {
       
    35             
       
    36     public:
       
    37     
       
    38         /**
       
    39         * Two phased constructor.
       
    40         * Takes a source and type of the queried context as
       
    41         * a parameter.
       
    42         *
       
    43         * @since S60 5.0
       
    44         * @param aSource Context source.
       
    45         * @param aType Context Type.
       
    46         * @return CCFContextQuery*
       
    47         */
       
    48         IMPORT_C static CCFContextQueryImpl* NewL( const TDesC& aSource,
       
    49             const TDesC& aType );
       
    50         IMPORT_C static CCFContextQueryImpl* NewLC( const TDesC& aSource,
       
    51             const TDesC& aType );
       
    52             
       
    53         // Destructor
       
    54         ~CCFContextQueryImpl();
       
    55     
       
    56     public: // From base classes
       
    57     
       
    58         // @see CCFContextQuery
       
    59         void SetTypeL( const TDesC& aType );
       
    60 			
       
    61         // @see CCFContextQuery
       
    62         const TDesC& Type() const;
       
    63 			
       
    64         // @see CCFContextQuery
       
    65         void SetSourceL( const TDesC& aSource );
       
    66 			
       
    67         // @see CCFContextQuery
       
    68         const TDesC& Source() const;
       
    69 			
       
    70         // @see CCFContextQuery
       
    71         void SetSubTypeMatch( TBool aMatchSubTypes );
       
    72 			
       
    73         // @see CCFContextQuery
       
    74         TBool SubTypeMatch() const;
       
    75 			
       
    76     public:
       
    77 
       
    78         /**
       
    79         * Internalizes object.
       
    80         *
       
    81         * @since S60 5.0
       
    82         * @param aStream Stream from which to internalize.
       
    83         * @return None.
       
    84         */
       
    85         IMPORT_C void InternalizeL( RReadStream& aStream );
       
    86 
       
    87         /**
       
    88         * Externalizes object.
       
    89         * 
       
    90         * @since S60 5.0
       
    91         * @param aStream Stream where to externalize.
       
    92         * @return None
       
    93         */
       
    94         IMPORT_C void ExternalizeL( RWriteStream& aStream );
       
    95 
       
    96         /**
       
    97         * Gets object size in bytes.
       
    98         *
       
    99         * @since S60 5.0
       
   100         * @param None
       
   101         * @return TInt
       
   102         */
       
   103         IMPORT_C TInt Size() const;
       
   104 
       
   105         /**
       
   106         * Checks if a context source and context type matches this query.
       
   107         * 
       
   108         * @since S60 5.0
       
   109         * @param aContextType Context type to match.
       
   110         * @param aContextSource Context source to match.
       
   111         * @return ETrue if a match.
       
   112         */
       
   113         IMPORT_C TBool Matches( const TDesC& aContextType, 
       
   114             const TDesC& aContextSource ) const;
       
   115 
       
   116         /**
       
   117         * Checks if a particular query matches a context source,
       
   118         * context type and sub type match.
       
   119         * 
       
   120         * @since S60 5.0
       
   121         * @param aQuery Query to match with.
       
   122         * @param aContextType Context type to match with query.
       
   123         * @param aContextSource Context source to match with query.
       
   124         * @param aMatchSubTypes Match sub types flag.
       
   125         * @return ETrue if a match.
       
   126         */
       
   127         IMPORT_C static TBool MatchesQuery( const CCFContextQuery& aQuery,
       
   128 			const TDesC& aContextType,
       
   129 			const TDesC& aContextSource,
       
   130 			TBool aMatchSubTypes );
       
   131 
       
   132         /**
       
   133         * Checks if tow queries are the same.
       
   134         *
       
   135         * @since S60 5.0
       
   136         * @param aQuery1 First query.
       
   137         * @param aQuery2 Second query.
       
   138         * @return ETrue if a match.
       
   139         */
       
   140         IMPORT_C static TBool IsSame( const CCFContextQuery& aQuery1,
       
   141 			const CCFContextQuery& aQuery2 );
       
   142 			
       
   143     private:
       
   144     
       
   145         CCFContextQueryImpl();
       
   146         void ConstructL( const TDesC& aSource, const TDesC& aType );
       
   147 
       
   148     private: // Data
       
   149 
       
   150         /** 
       
   151         * The (URI or semantic description of the) source from which the
       
   152         * context originates.
       
   153         */
       
   154         HBufC* iSource;
       
   155 
       
   156         /**
       
   157         * One context category description.
       
   158         * Example: <code>Environment.Temperature</code>
       
   159         */
       
   160         HBufC* iType;
       
   161 
       
   162         /**
       
   163         * Are subtypes are matched by this query.
       
   164         */
       
   165         TBool iMatchSubTypes;
       
   166     };
       
   167 
       
   168 #endif