epoc32/include/sensrvchannelcondition.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/sensrvchannelcondition.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/sensrvchannelcondition.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,236 @@
     1.4 -sensrvchannelcondition.h
     1.5 +/*
     1.6 +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description:  Channel condition object
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +#ifndef SENSRVCHANNELCONDITION_H
    1.24 +#define SENSRVCHANNELCONDITION_H
    1.25 +
    1.26 +//  INCLUDES
    1.27 +#include <e32base.h>
    1.28 +
    1.29 +// FORWARD DECLARATIONS
    1.30 +
    1.31 +class CSensrvChannelCondition;
    1.32 +
    1.33 +// DATA TYPES
    1.34 +
    1.35 +/**
    1.36 +* RPointerArray based channel condition list
    1.37 +*/
    1.38 +typedef RPointerArray<CSensrvChannelCondition> RSensrvChannelConditionList;
    1.39 +
    1.40 +/**
    1.41 +* Defines condition type.
    1.42 +* 
    1.43 +* Conditions can be standalone conditions or a part of a two-part condition.
    1.44 +* 
    1.45 +* - ESensrvLimitCondition is a standalone condition which has a limit. This kind of condition
    1.46 +*   is met when the observed value exceeds or equals the condition value, depending on the
    1.47 +*   operator used in the condition.
    1.48 +* - ESensrvRangeConditionLowerLimit is the first part of a two-part range condition. This kind
    1.49 +*   of condition is met when the observed value is between specified lower and upper limits or
    1.50 +*   beyond specified range, depending on the operators used in the two conditions that make up
    1.51 +*   the range.
    1.52 +*   A condition set that contains ESensrvRangeConditionLowerLimit condition must also contain
    1.53 +*   ESensrvRangeConditionUpperLimit condition using the same index. Both lower and upper limit
    1.54 +*   operators must have different direction, i.e. if lower limit has "less than" operator, then
    1.55 +*   upper limit must have "greater than" operator, and vice versa. ESensrvOperatorEquals operator
    1.56 +*   is not valid for range condition.
    1.57 +* - ESensrvRangeConditionUpperLimit is the second part of a two-part range condition.
    1.58 +* - ESensrvBinaryCondition is used for channels that provide bitmask values (typically event
    1.59 +*   channels). ESensrvOperatorBinaryXxx operations can only be used with this condition type.
    1.60 +* 
    1.61 +* @see CSensrvChannelCondition
    1.62 +* @see TSensrvConditionOperator
    1.63 +*/
    1.64 +enum TSensrvConditionType
    1.65 +    {
    1.66 +    /** Standalone condition which has a limit */
    1.67 +    ESensrvSingleLimitCondition = 0,
    1.68 +    /** 1st part of a two-part range condition. 2nd part is ESensrvRangeConditionUpperLimit */
    1.69 +    ESensrvRangeConditionLowerLimit,
    1.70 +    /** 2nd part of a two-part range condition. 1st part is ESensrvRangeConditionLowerLimit */
    1.71 +    ESensrvRangeConditionUpperLimit,
    1.72 +    /** Standalone condition for binary operations */
    1.73 +    ESensrvBinaryCondition
    1.74 +    };
    1.75 +
    1.76 +/*
    1.77 +* Defines condition operator
    1.78 +* 
    1.79 +* For a range condition a ConditionSet must contain 2 Conditions each with an operator in a
    1.80 +* different direction. i.e. There must be matching greater than and less than pair. Also the pair
    1.81 +* of conditions must have the same index in the ConditionSet.
    1.82 +* 
    1.83 +* - ESensrvOperatorEquals checks if the value got from the sensor is equal to the set value. This is
    1.84 +*   not a valid operator for a range condition.
    1.85 +* - ESensrvOperatorGreaterThan checks if the value got from the sensor is greater than the set limit. 
    1.86 +*   This is not a valid operator for a binary condition.
    1.87 +* - ESensrvOperatorGreaterThanOrEquals checks if the value got from the sensor is greater than or equal
    1.88 +*   to the set limit. This is not a valid operator for a binary condition.
    1.89 +* - ESensrvOperatorLessThan checks if the value got from the sensor is less than the set limit. This is
    1.90 +*   not a valid operator for a binary condition.
    1.91 +* - ESensrvOperatorLessThanOrEquals checks if the value got from the sensor is less than or equal to the
    1.92 +*   set limit. This is not a valid operator for a binary condition.
    1.93 +* - ESensrvOperatorBinaryAnd checks if a bitmask data value got from the sensor has set at least one of
    1.94 +*   the bits set in the condition value. In other words, if result of datavalue & conditionvalue != 0,
    1.95 +*   there is a match. This is not a valid operator for a single limit or range conditions.
    1.96 +* 
    1.97 +*   Example: 
    1.98 +*   Condition value: 01101101
    1.99 +*   Data value:      10001010
   1.100 +*   Resulting value: 00001000 -> Non-zero, which indicates a match.
   1.101 +* - ESensrvOperatorBinaryAll checks if a bitmask data value got from the sensor has set all of the bits
   1.102 +*   set in the condition value. The rest of the data value bits are ignored. In other words, if
   1.103 +*   datavalue & conditionvalue == conditionvalue, there is a match. Not a valid operator for a single limit
   1.104 +*   or range conditions.
   1.105 +*   Example: 
   1.106 +*   Condition value: 01101101
   1.107 +*   Data value:      10001010
   1.108 +*   Resulting value: 00001000 -> Not equal to condition value -> Not a match.
   1.109 +* 
   1.110 +* @see CSensrvChannelCondition
   1.111 +* @see TSensrvConditionType
   1.112 +*/
   1.113 +enum TSensrvConditionOperator
   1.114 +    {
   1.115 +    ESensrvOperatorEquals = 0,
   1.116 +    ESensrvOperatorGreaterThan,
   1.117 +    ESensrvOperatorGreaterThanOrEquals,
   1.118 +    ESensrvOperatorLessThan,
   1.119 +    ESensrvOperatorLessThanOrEquals,
   1.120 +    ESensrvOperatorBinaryAnd,
   1.121 +    ESensrvOperatorBinaryAll    
   1.122 +    };
   1.123 +
   1.124 +// CLASS DECLARATION
   1.125 +
   1.126 +/**
   1.127 +* CSensrvChannelCondition represents a channel condition item. Channel conditions are added to a channel
   1.128 +* condition set. A channel condition set is met when all channel conditions are met at the same time, if it
   1.129 +* is AND-type set, or when single condition is met if it is OR-type set. Only one channel condition can be
   1.130 +* set for each data item in single channel condition set. Certain condition types (range conditions) require
   1.131 +* two condition objects (upper and lower limit) in a condition set for the set to be valid. The pair of
   1.132 +* conditions must both have the same index in the condition set and they are considered a single channel
   1.133 +* condition. 
   1.134 +* 
   1.135 +* Each Condition has an ItemIndex associated with it. When a Condition is added to a Condition Set using
   1.136 +* CSensrvChannelConditionSet::AddChannelConditionL() this index must be different to all other conditions
   1.137 +* added to the set with the exception of range conditions as described above. If the index supplied already
   1.138 +* exists and the condition is not part of a range condition then
   1.139 +* CSensrvChannelConditionSet::AddChannelConditionL() leaves with KErrArgument.  
   1.140 +* 
   1.141 +* @see CSensrvChannelConditionSet
   1.142 +* @see TSensrvConditionType
   1.143 +* @see TSensrvConditionOperator
   1.144 +* @lib sensrvutil.lib
   1.145 +* @since S60 5.0
   1.146 +*/
   1.147 +NONSHARABLE_CLASS( CSensrvChannelCondition ): public CBase
   1.148 +    {
   1.149 +public:
   1.150 +    /**
   1.151 +    * Two-phase constructor
   1.152 +    * 
   1.153 +    * @param   aConditionType Defines the type of the condition
   1.154 +    * @param   aConditionOperator Defines the operator used in the condition
   1.155 +    * @param   aItemIndex Item index to be used in the condition evaluation
   1.156 +    * @param   aValue Value to be used in condition evaluation. By default this should be a packaged data
   1.157 +    *         object of the channel. See the channel specific headers in \epoc32\include\sensors\channels.
   1.158 +    *         If the channel type requires a different type of value, that must be indicated clearly in
   1.159 +    *        the channel specific header defining the channel.
   1.160 +    * @return Pointer to created object
   1.161 +    * @leave  KErrNoMemory
   1.162 +    * @leave  KErrArgument if parameters are invalid or are less than 0
   1.163 +    * @leave  One of the system-wide error codes
   1.164 +    */  
   1.165 +    IMPORT_C static CSensrvChannelCondition* NewL
   1.166 +                ( TInt aConditionType, 
   1.167 +                  TInt aConditionOperator,
   1.168 +                  TInt aItemIndex,
   1.169 +                  TDesC8& aValue );
   1.170 +                  
   1.171 +    /**
   1.172 +    * Two-phase constructor
   1.173 +    * 
   1.174 +    * @param   aConditionType Defines the type of the condition
   1.175 +    * @param   aConditionOperator Defines the operator used in the condition
   1.176 +    * @param   aItemIndex Item index to be used in the condition evaluation
   1.177 +    * @param   aValue Value to be used in condition evaluation. By default this should be a packaged data
   1.178 +    *         object of the channel. See the channel specific headers in \epoc32\include\sensors\channels.
   1.179 +    *         If the channel type requires a different type of value, that must be indicated clearly in
   1.180 +    *         the channel specific header defining the channel.
   1.181 +    * @return Pointer to created object
   1.182 +    * @leave  KErrNoMemory
   1.183 +    * @leave  KErrArgument if parameters are invalid or are less than 0
   1.184 +    * @leave  One of the system-wide error codes
   1.185 +    */  
   1.186 +    IMPORT_C static CSensrvChannelCondition* NewLC
   1.187 +                ( TInt aConditionType, 
   1.188 +                  TInt aConditionOperator,
   1.189 +                  TInt aItemIndex,
   1.190 +                  TDesC8& aValue );
   1.191 +public:  
   1.192 +    
   1.193 +    /**
   1.194 +    * Get condition type
   1.195 +    *  
   1.196 +    * @return Condition Type
   1.197 +    */    
   1.198 +    virtual TInt ConditionType() const = 0;
   1.199 +
   1.200 +    /**
   1.201 +    * Get condition operator
   1.202 +    *
   1.203 +    * @return TInt Condition operator
   1.204 +    */      
   1.205 +    virtual TInt ConditionOperator() const = 0;
   1.206 +  
   1.207 +    /**
   1.208 +    * Get condition item index
   1.209 +    *
   1.210 +    * @return TInt Condition item index
   1.211 +    */      
   1.212 +    virtual TInt ConditionItemIndex() const = 0;
   1.213 +
   1.214 +    /**
   1.215 +    * Get condition value.
   1.216 +    *
   1.217 +    * @param  aValue Value of the condition is copied to the supplied descriptor
   1.218 +    * @return KErrOverflow if aData is the wrong size for data item or one of the system-wide error codes
   1.219 +    */      
   1.220 +    virtual TInt GetConditionValue( TDes8& aValue ) const = 0;        
   1.221 +
   1.222 +    /**
   1.223 +    * Get condition value as reference.
   1.224 +    * 
   1.225 +    * @return Reference to condition value descriptor.
   1.226 +    */      
   1.227 +    virtual const TDesC8& ConditionValue() const = 0;        
   1.228 +
   1.229 +public:
   1.230 +    /**
   1.231 +    * Default constructor. 
   1.232 +    */
   1.233 +    CSensrvChannelCondition();
   1.234 +    };
   1.235 +
   1.236 +#endif //SENSRVCHANNELCONDITION_H
   1.237 +
   1.238 +// End of File
   1.239 +
   1.240 +