epoc32/include/sensrvchannelcondition.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* 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
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:  Channel condition object
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
#ifndef SENSRVCHANNELCONDITION_H
williamr@2
    20
#define SENSRVCHANNELCONDITION_H
williamr@2
    21
williamr@2
    22
//  INCLUDES
williamr@2
    23
#include <e32base.h>
williamr@2
    24
williamr@2
    25
// FORWARD DECLARATIONS
williamr@2
    26
williamr@2
    27
class CSensrvChannelCondition;
williamr@2
    28
williamr@2
    29
// DATA TYPES
williamr@2
    30
williamr@2
    31
/**
williamr@2
    32
* RPointerArray based channel condition list
williamr@2
    33
*/
williamr@2
    34
typedef RPointerArray<CSensrvChannelCondition> RSensrvChannelConditionList;
williamr@2
    35
williamr@2
    36
/**
williamr@2
    37
* Defines condition type.
williamr@2
    38
* 
williamr@2
    39
* Conditions can be standalone conditions or a part of a two-part condition.
williamr@2
    40
* 
williamr@2
    41
* - ESensrvLimitCondition is a standalone condition which has a limit. This kind of condition
williamr@2
    42
*   is met when the observed value exceeds or equals the condition value, depending on the
williamr@2
    43
*   operator used in the condition.
williamr@2
    44
* - ESensrvRangeConditionLowerLimit is the first part of a two-part range condition. This kind
williamr@2
    45
*   of condition is met when the observed value is between specified lower and upper limits or
williamr@2
    46
*   beyond specified range, depending on the operators used in the two conditions that make up
williamr@2
    47
*   the range.
williamr@2
    48
*   A condition set that contains ESensrvRangeConditionLowerLimit condition must also contain
williamr@2
    49
*   ESensrvRangeConditionUpperLimit condition using the same index. Both lower and upper limit
williamr@2
    50
*   operators must have different direction, i.e. if lower limit has "less than" operator, then
williamr@2
    51
*   upper limit must have "greater than" operator, and vice versa. ESensrvOperatorEquals operator
williamr@2
    52
*   is not valid for range condition.
williamr@2
    53
* - ESensrvRangeConditionUpperLimit is the second part of a two-part range condition.
williamr@2
    54
* - ESensrvBinaryCondition is used for channels that provide bitmask values (typically event
williamr@2
    55
*   channels). ESensrvOperatorBinaryXxx operations can only be used with this condition type.
williamr@2
    56
* 
williamr@2
    57
* @see CSensrvChannelCondition
williamr@2
    58
* @see TSensrvConditionOperator
williamr@2
    59
*/
williamr@2
    60
enum TSensrvConditionType
williamr@2
    61
    {
williamr@2
    62
    /** Standalone condition which has a limit */
williamr@2
    63
    ESensrvSingleLimitCondition = 0,
williamr@2
    64
    /** 1st part of a two-part range condition. 2nd part is ESensrvRangeConditionUpperLimit */
williamr@2
    65
    ESensrvRangeConditionLowerLimit,
williamr@2
    66
    /** 2nd part of a two-part range condition. 1st part is ESensrvRangeConditionLowerLimit */
williamr@2
    67
    ESensrvRangeConditionUpperLimit,
williamr@2
    68
    /** Standalone condition for binary operations */
williamr@2
    69
    ESensrvBinaryCondition
williamr@2
    70
    };
williamr@2
    71
williamr@2
    72
/*
williamr@2
    73
* Defines condition operator
williamr@2
    74
* 
williamr@2
    75
* For a range condition a ConditionSet must contain 2 Conditions each with an operator in a
williamr@2
    76
* different direction. i.e. There must be matching greater than and less than pair. Also the pair
williamr@2
    77
* of conditions must have the same index in the ConditionSet.
williamr@2
    78
* 
williamr@2
    79
* - ESensrvOperatorEquals checks if the value got from the sensor is equal to the set value. This is
williamr@2
    80
*   not a valid operator for a range condition.
williamr@2
    81
* - ESensrvOperatorGreaterThan checks if the value got from the sensor is greater than the set limit. 
williamr@2
    82
*   This is not a valid operator for a binary condition.
williamr@2
    83
* - ESensrvOperatorGreaterThanOrEquals checks if the value got from the sensor is greater than or equal
williamr@2
    84
*   to the set limit. This is not a valid operator for a binary condition.
williamr@2
    85
* - ESensrvOperatorLessThan checks if the value got from the sensor is less than the set limit. This is
williamr@2
    86
*   not a valid operator for a binary condition.
williamr@2
    87
* - ESensrvOperatorLessThanOrEquals checks if the value got from the sensor is less than or equal to the
williamr@2
    88
*   set limit. This is not a valid operator for a binary condition.
williamr@2
    89
* - ESensrvOperatorBinaryAnd checks if a bitmask data value got from the sensor has set at least one of
williamr@2
    90
*   the bits set in the condition value. In other words, if result of datavalue & conditionvalue != 0,
williamr@2
    91
*   there is a match. This is not a valid operator for a single limit or range conditions.
williamr@2
    92
* 
williamr@2
    93
*   Example: 
williamr@2
    94
*   Condition value: 01101101
williamr@2
    95
*   Data value:      10001010
williamr@2
    96
*   Resulting value: 00001000 -> Non-zero, which indicates a match.
williamr@2
    97
* - ESensrvOperatorBinaryAll checks if a bitmask data value got from the sensor has set all of the bits
williamr@2
    98
*   set in the condition value. The rest of the data value bits are ignored. In other words, if
williamr@2
    99
*   datavalue & conditionvalue == conditionvalue, there is a match. Not a valid operator for a single limit
williamr@2
   100
*   or range conditions.
williamr@2
   101
*   Example: 
williamr@2
   102
*   Condition value: 01101101
williamr@2
   103
*   Data value:      10001010
williamr@2
   104
*   Resulting value: 00001000 -> Not equal to condition value -> Not a match.
williamr@2
   105
* 
williamr@2
   106
* @see CSensrvChannelCondition
williamr@2
   107
* @see TSensrvConditionType
williamr@2
   108
*/
williamr@2
   109
enum TSensrvConditionOperator
williamr@2
   110
    {
williamr@2
   111
    ESensrvOperatorEquals = 0,
williamr@2
   112
    ESensrvOperatorGreaterThan,
williamr@2
   113
    ESensrvOperatorGreaterThanOrEquals,
williamr@2
   114
    ESensrvOperatorLessThan,
williamr@2
   115
    ESensrvOperatorLessThanOrEquals,
williamr@2
   116
    ESensrvOperatorBinaryAnd,
williamr@2
   117
    ESensrvOperatorBinaryAll    
williamr@2
   118
    };
williamr@2
   119
williamr@2
   120
// CLASS DECLARATION
williamr@2
   121
williamr@2
   122
/**
williamr@2
   123
* CSensrvChannelCondition represents a channel condition item. Channel conditions are added to a channel
williamr@2
   124
* condition set. A channel condition set is met when all channel conditions are met at the same time, if it
williamr@2
   125
* is AND-type set, or when single condition is met if it is OR-type set. Only one channel condition can be
williamr@2
   126
* set for each data item in single channel condition set. Certain condition types (range conditions) require
williamr@2
   127
* two condition objects (upper and lower limit) in a condition set for the set to be valid. The pair of
williamr@2
   128
* conditions must both have the same index in the condition set and they are considered a single channel
williamr@2
   129
* condition. 
williamr@2
   130
* 
williamr@2
   131
* Each Condition has an ItemIndex associated with it. When a Condition is added to a Condition Set using
williamr@2
   132
* CSensrvChannelConditionSet::AddChannelConditionL() this index must be different to all other conditions
williamr@2
   133
* added to the set with the exception of range conditions as described above. If the index supplied already
williamr@2
   134
* exists and the condition is not part of a range condition then
williamr@2
   135
* CSensrvChannelConditionSet::AddChannelConditionL() leaves with KErrArgument.  
williamr@2
   136
* 
williamr@2
   137
* @see CSensrvChannelConditionSet
williamr@2
   138
* @see TSensrvConditionType
williamr@2
   139
* @see TSensrvConditionOperator
williamr@2
   140
* @lib sensrvutil.lib
williamr@2
   141
* @since S60 5.0
williamr@2
   142
*/
williamr@2
   143
NONSHARABLE_CLASS( CSensrvChannelCondition ): public CBase
williamr@2
   144
    {
williamr@2
   145
public:
williamr@2
   146
    /**
williamr@2
   147
    * Two-phase constructor
williamr@2
   148
    * 
williamr@2
   149
    * @param   aConditionType Defines the type of the condition
williamr@2
   150
    * @param   aConditionOperator Defines the operator used in the condition
williamr@2
   151
    * @param   aItemIndex Item index to be used in the condition evaluation
williamr@2
   152
    * @param   aValue Value to be used in condition evaluation. By default this should be a packaged data
williamr@2
   153
    *         object of the channel. See the channel specific headers in \epoc32\include\sensors\channels.
williamr@2
   154
    *         If the channel type requires a different type of value, that must be indicated clearly in
williamr@2
   155
    *        the channel specific header defining the channel.
williamr@2
   156
    * @return Pointer to created object
williamr@2
   157
    * @leave  KErrNoMemory
williamr@2
   158
    * @leave  KErrArgument if parameters are invalid or are less than 0
williamr@2
   159
    * @leave  One of the system-wide error codes
williamr@2
   160
    */  
williamr@2
   161
    IMPORT_C static CSensrvChannelCondition* NewL
williamr@2
   162
                ( TInt aConditionType, 
williamr@2
   163
                  TInt aConditionOperator,
williamr@2
   164
                  TInt aItemIndex,
williamr@2
   165
                  TDesC8& aValue );
williamr@2
   166
                  
williamr@2
   167
    /**
williamr@2
   168
    * Two-phase constructor
williamr@2
   169
    * 
williamr@2
   170
    * @param   aConditionType Defines the type of the condition
williamr@2
   171
    * @param   aConditionOperator Defines the operator used in the condition
williamr@2
   172
    * @param   aItemIndex Item index to be used in the condition evaluation
williamr@2
   173
    * @param   aValue Value to be used in condition evaluation. By default this should be a packaged data
williamr@2
   174
    *         object of the channel. See the channel specific headers in \epoc32\include\sensors\channels.
williamr@2
   175
    *         If the channel type requires a different type of value, that must be indicated clearly in
williamr@2
   176
    *         the channel specific header defining the channel.
williamr@2
   177
    * @return Pointer to created object
williamr@2
   178
    * @leave  KErrNoMemory
williamr@2
   179
    * @leave  KErrArgument if parameters are invalid or are less than 0
williamr@2
   180
    * @leave  One of the system-wide error codes
williamr@2
   181
    */  
williamr@2
   182
    IMPORT_C static CSensrvChannelCondition* NewLC
williamr@2
   183
                ( TInt aConditionType, 
williamr@2
   184
                  TInt aConditionOperator,
williamr@2
   185
                  TInt aItemIndex,
williamr@2
   186
                  TDesC8& aValue );
williamr@2
   187
public:  
williamr@2
   188
    
williamr@2
   189
    /**
williamr@2
   190
    * Get condition type
williamr@2
   191
    *  
williamr@2
   192
    * @return Condition Type
williamr@2
   193
    */    
williamr@2
   194
    virtual TInt ConditionType() const = 0;
williamr@2
   195
williamr@2
   196
    /**
williamr@2
   197
    * Get condition operator
williamr@2
   198
    *
williamr@2
   199
    * @return TInt Condition operator
williamr@2
   200
    */      
williamr@2
   201
    virtual TInt ConditionOperator() const = 0;
williamr@2
   202
  
williamr@2
   203
    /**
williamr@2
   204
    * Get condition item index
williamr@2
   205
    *
williamr@2
   206
    * @return TInt Condition item index
williamr@2
   207
    */      
williamr@2
   208
    virtual TInt ConditionItemIndex() const = 0;
williamr@2
   209
williamr@2
   210
    /**
williamr@2
   211
    * Get condition value.
williamr@2
   212
    *
williamr@2
   213
    * @param  aValue Value of the condition is copied to the supplied descriptor
williamr@2
   214
    * @return KErrOverflow if aData is the wrong size for data item or one of the system-wide error codes
williamr@2
   215
    */      
williamr@2
   216
    virtual TInt GetConditionValue( TDes8& aValue ) const = 0;        
williamr@2
   217
williamr@2
   218
    /**
williamr@2
   219
    * Get condition value as reference.
williamr@2
   220
    * 
williamr@2
   221
    * @return Reference to condition value descriptor.
williamr@2
   222
    */      
williamr@2
   223
    virtual const TDesC8& ConditionValue() const = 0;        
williamr@2
   224
williamr@2
   225
public:
williamr@2
   226
    /**
williamr@2
   227
    * Default constructor. 
williamr@2
   228
    */
williamr@2
   229
    CSensrvChannelCondition();
williamr@2
   230
    };
williamr@2
   231
williamr@2
   232
#endif //SENSRVCHANNELCONDITION_H
williamr@2
   233
williamr@2
   234
// End of File
williamr@2
   235
williamr@2
   236