Using array properties

A property which defines multiple discrete values inside one property ID is called an array property.

Array properties can be identified with array index which can be queried from property with the GetArrayIndex() method. For array properties the array index is something else than ESensrvSingleProperty.

An example of an array property is illustrated in the KSensrvPropIdDataRate property documentation in the file sensorgeneralproperties.h.

The following example shows how to get the current data rate of the channel for which the data rate is declared as an array property.

First, the KSensrvPropIdDataRate property is read with the GetPropertyL() method. If the property is an array property the result of the GetPropertyL() call is a property with array index ESensrvArrayPropertyInfo , otherwise the array information index is ESensrvSingleProperty. In case of an array property, the value of the current data rate is in the KSensrvPropIdDataRate property for which the array index is the same as the array property's value.

    TSensrvProperty property;
    TInt err( KErrNone );
    TInt datarate( 0 );

    iSensorChannel->GetPropertyL( KSensrvPropIdDataRate,
                                  KSensrvItemIndexNone,
                                  property );

    if( ESensrvArrayPropertyInfo == property.GetArrayIndex() )
        {
        //Current data rate in use is in the KSensrvPropIdDataRate property
        //for which the array index is declared in the array property's value.
        TInt arrayIndex( 0 );
        property.GetValue( arrayIndex );

        iSensorChannel->GetPropertyL( KSensrvPropIdDataRate,
                                      KSensrvItemIndexNone,
                                      arrayIndex,
                                      property );
                                      
        property.GetValue( datarate );
        }
    else
        {
        //KSensrvPropIdDataRate is a single property and current data rate can be read diretly from it.
        property.GetValue( datarate );
        }