contextframework/cfw/inc/basicoperationsplugin/cfcontextoperation.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2004-2008 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:  CCFContextOperation class declaration.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_CFCONTEXTOPERATION_H
       
    21 #define C_CFCONTEXTOPERATION_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <cfcontextobject.h>
       
    26 
       
    27 #include "cfoperationnode.h"
       
    28 #include "cfscriptlistener.h"
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 *  CCFContextOperation class is the base class for all Context Framework script
       
    36 *  operations that operate on contexts.
       
    37 *  All instances of this class are leaf nodes in operation tree.
       
    38 *
       
    39 *  @lib CFScriptEngine
       
    40 *  @since Series 60 2.6
       
    41 */
       
    42 NONSHARABLE_CLASS( CCFContextOperation ): public CCFOperationNode,
       
    43     public MCFScriptListener
       
    44     {
       
    45 public: // Constructors and destructor
       
    46 
       
    47     /**
       
    48     * Destructor.
       
    49     */
       
    50     virtual ~CCFContextOperation();
       
    51 
       
    52 public: // Enumerations
       
    53 
       
    54     enum TCmpType
       
    55         {
       
    56         EInvalidCmpType = -1,
       
    57         EIntCmp,
       
    58         EFloatCmp,
       
    59         EPositionCmp,
       
    60         ETimeCmp,
       
    61         EStringCmp
       
    62         };
       
    63 
       
    64 
       
    65 public: // From MCFScriptListener
       
    66 
       
    67     /**
       
    68     * Performs evaluation based on a context.
       
    69     * @param aContext is the context for evaluation.
       
    70     * @param aContextLevelDelay is storage for context level delay required by
       
    71     *   the evaluation.
       
    72     * @return ETrue if evaluation was performed and firing actions should be
       
    73     *   considered based on clause conditions, EFalse otherwise.
       
    74     */
       
    75     TBool Evaluate( const CCFContextObject& aContext,
       
    76             TInt& aContextLevelDelay );
       
    77 
       
    78     /**
       
    79     * Returns a context source this listener is interested in.
       
    80     * @returns the source of the context.
       
    81     */
       
    82     TPtrC Source() const;
       
    83 
       
    84     /**
       
    85     * Returns a context type this listener is interested in.
       
    86     * @returns the type of the context.
       
    87     */
       
    88     TPtrC Type() const;
       
    89 
       
    90     /**
       
    91     * Tests if this listener requires notification of all contexts.
       
    92     * @returns ETrue if this listener is interested in all contexts,
       
    93     *   EFalse otherwise.
       
    94     */
       
    95     TBool IsAllRequired() const;
       
    96 
       
    97 protected:
       
    98 
       
    99     /**
       
   100     * C++ default constructor.
       
   101     */
       
   102     CCFContextOperation( MCFOperationServices& aServices,
       
   103             CCFOperationNode* aParent,
       
   104             HBufC* aType,
       
   105             HBufC* aSource );
       
   106 
       
   107 protected: // New functions
       
   108 
       
   109     /**
       
   110     * All concrete classes must implement this method.
       
   111     * @param aContext is context that has changed.
       
   112     * @return the result of the comparison.
       
   113     */
       
   114     virtual TBool IsTrueL( const CCFContextObject& aContext ) = 0;
       
   115 
       
   116     /**
       
   117     * Updates the previous value the operation was evaluated with.
       
   118     * @param aNewValue is the new previous value.
       
   119     * @return KErrNone when update was successful, KErrNoMemory if update failed
       
   120     *   due to low memory.
       
   121     */
       
   122     TInt UpdatePreviousValue( const TDesC& aNewValue );
       
   123 
       
   124     /**
       
   125     * Gets the previous value the operation was evaluated with.
       
   126     * @return the previous value the operation was evaluated with.
       
   127     */
       
   128     const TDesC& PreviousValue();
       
   129 
       
   130 protected: // From CCFOperationNode
       
   131 
       
   132     /**
       
   133     * Activates this node by subscribing to a context.
       
   134     * @return None.
       
   135     */
       
   136     void ActivateL();
       
   137 
       
   138     /**
       
   139     * Deactivates this node by removing context subscription.
       
   140     * @return None.
       
   141     */
       
   142     void Deactivate();
       
   143 
       
   144     /**
       
   145     * Asks this node to check its security (via services interface). For
       
   146     * example, the security of contexts to be subscribed.
       
   147     * @return KErrNone if security check passed, otherwise any of the system
       
   148     *   wide error codes.
       
   149     */
       
   150     TInt CheckSecurity();
       
   151 
       
   152 private: // From CCFOperationNode
       
   153 
       
   154     /**
       
   155     * Called by child node, to ask the parent to re-evaluate its value,
       
   156     * since the child's value has changed.
       
   157     */
       
   158     void Evaluate();
       
   159 
       
   160 protected: // Data
       
   161 
       
   162     /**
       
   163     * Context level delay for firing actions after evaluation
       
   164     * (defined by contextRef).
       
   165     */
       
   166     TInt iContextLevelDelay;
       
   167 
       
   168 private: // Data
       
   169 
       
   170     /**
       
   171     * Context source and type as defined by contextRef for the operation.
       
   172     */
       
   173     HBufC* iSource;
       
   174     HBufC* iType;
       
   175 
       
   176     /** Previous context value. */
       
   177     HBufC* iPreviousValue;
       
   178     };
       
   179 
       
   180 #endif // C_CFCONTEXTOPERATION_H