contextframework/cfw/inc/basicoperationsplugin/cfinrange.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:  CCFInRange class declaration. Currently supports the following
       
    15 *                (cep) types:
       
    16 *                                       "cep:int"
       
    17 *                                       "cep:string"
       
    18 *                                       "cep:double"
       
    19 *                                       "cep:position"
       
    20 *                                       "cep:date"
       
    21 *
       
    22 */
       
    23 
       
    24 
       
    25 
       
    26 #ifndef C_CFINRANGE_H
       
    27 #define C_CFINRANGE_H
       
    28 
       
    29 
       
    30 // INCLUDES
       
    31 #include "cfcontextoperation.h"
       
    32 
       
    33 #include <e32base.h>
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 class CCFContextObject;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41 *   This class implements InRange -operation on Context Framework Scripts.
       
    42 *
       
    43 *  @lib CFScriptEngine
       
    44 *  @since Series 60 2.6
       
    45 */
       
    46 NONSHARABLE_CLASS( CCFInRange ): public CCFContextOperation
       
    47     {
       
    48 public: // Constructors and destructor
       
    49 
       
    50     /**
       
    51     * Creates a CCFInRange object
       
    52     * @param aServices is the operation services interface for nodes.
       
    53     * @param aParent is parent node for this node.
       
    54     * @param aName is name of the context object this operation operates on.
       
    55     * @param aSource is the source of the context object this operation
       
    56     *   operates on.
       
    57     * @param aType is the interpretation of aCmpVal
       
    58     * @param aMinVal is a string representation of the minimum comparison value
       
    59     * @param aMinVal is a string representation of the maximum comparison value
       
    60     * @return a pointer to the created instance of CCFInRange
       
    61     */
       
    62     static CCFInRange* NewL( MCFOperationServices& aServices,
       
    63             CCFOperationNode* aParent,
       
    64             TDesC& aName,
       
    65             TDesC& aSource,
       
    66             const CCFContextOperation::TCmpType aType,
       
    67             const TDesC& aMinVal,
       
    68             const TDesC& aMaxVal );
       
    69 
       
    70     /**
       
    71     * Creates a CCFInRange object
       
    72     * @param aServices is the operation services interface for nodes.
       
    73     * @param aParent is parent node for this node.
       
    74     * @param aName is name of the context object this operation operates on.
       
    75     * @param aSource is the source of the context object this operation
       
    76     *   operates on.
       
    77     * @param aType is the interpretation of aCmpVal
       
    78     * @param aMinVal is a string representation of the minimum comparison value
       
    79     * @param aMinVal is a string representation of the maximum comparison value
       
    80     * @return a pointer to the created instance of CCFInRange
       
    81     */
       
    82     static CCFInRange* NewLC( MCFOperationServices& aServices,
       
    83             CCFOperationNode* aParent,
       
    84             TDesC& aName,
       
    85             TDesC& aSource,
       
    86             const CCFContextOperation::TCmpType aType,
       
    87             const TDesC& aMinVal,
       
    88             const TDesC& aMaxVal );
       
    89 
       
    90     /**
       
    91     * Creates and parses a CCFInRange instance from an xml node.
       
    92     * @param aServices is the operation services interface for nodes.
       
    93     * @param aParent is the parent of this node or NULL if this is a root.
       
    94     *   The ownership of the parent is not transferred.
       
    95     * @param aNode is the node to be parsed.
       
    96     * @return a pointer to the created instance of CCFInRange, or NULL if the
       
    97     *   node is not this in range node. May leave with any system wide error
       
    98     *   code.
       
    99     */
       
   100     static CCFInRange* ParseL( MCFOperationServices& aServices,
       
   101             CCFOperationNode* aParent,
       
   102             CMDXMLNode& aNode );
       
   103 
       
   104     /**
       
   105     * Destructor.
       
   106     */
       
   107     ~CCFInRange();
       
   108 
       
   109 private:
       
   110 
       
   111     /**
       
   112     * C++ default constructor.
       
   113     */
       
   114     CCFInRange( MCFOperationServices& aServices,
       
   115             CCFOperationNode* aParent,
       
   116             HBufC* aName,
       
   117             HBufC* aSource,
       
   118             const CCFContextOperation::TCmpType aType );
       
   119 
       
   120     /**
       
   121     * By default Symbian 2nd phase constructor is private.
       
   122     */
       
   123     void ConstructL( const TDesC& aMinVal, const TDesC& aMaxVal );
       
   124 
       
   125 protected: // From CCFContextOperation
       
   126 
       
   127     /**
       
   128     * Returns ETrue if this operation is true.
       
   129     */
       
   130     TBool IsTrueL( const CCFContextObject& aContextObject );
       
   131 
       
   132 private: // New functions
       
   133 
       
   134     /**
       
   135     * Method that takes two GPS positions as (latitude,longitude)-pairs
       
   136     * (units==DEGREES) and calculates their ellipsoid distance.
       
   137     * This is used in calculation of the value for cep:position types.
       
   138     * NOTE: This algorithm can be found from the following book:
       
   139     *       "Astronomical Algorithms" by Jean Meeus.
       
   140     * @param aPos1Latitude latitude of point one in degrees.
       
   141     * @param aPos1Longitude longitude of point one in degrees.
       
   142     * @param aPos2Latitude latitude of point two in degrees.
       
   143     * @param aPos2Longitude longitude of point two in degrees.
       
   144     * @return calculated distance (in meters) if successful,
       
   145     *   otherwise KErrGeneral.
       
   146     */
       
   147     TReal EllipsoidDistanceBetweenTwoPositions(
       
   148             TReal aPos1Latitude, TReal aPos1Longitude,
       
   149             TReal aPos2Latitude, TReal aPos2Longitude );
       
   150 
       
   151 private: // Data
       
   152 
       
   153     CCFContextOperation::TCmpType iType;
       
   154     HBufC*                        iMinVal;
       
   155     HBufC*                        iMaxVal;
       
   156     };
       
   157 
       
   158 #endif // C_CFINRANGE_H