2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Sensor and channel property container
19 #ifndef SENSRVPROPERTY_H
20 #define SENSRVPROPERTY_H
24 #include <babitflags.h>
29 * Maximum size of the buffer when the property type is ESensrvBufferProperty
30 * @see TSensrvProperty
32 const TInt KSensrvPropertyTextBufferSize = 20;
39 * @see TSensrvProperty
41 enum TSensrvPropertyType
43 /** Default property type */
44 ESensrvUninitializedProperty = 0,
45 /** Integer property type. TInt is used to store property value */
47 /** Real property type. TReal is used to store property value */
50 Descriptor property type. TBuf<KSensrvPropertyTextBufferSize> is used to store
57 * Special index types for iArrayIndex. Any other value indicates that this property is a member of
58 * an array of properties
59 * @see TSensrvProperty
61 enum TSensrvArrayIndex
63 /** This property is a single property and is not a member of an array of properties */
64 ESensrvSingleProperty = -1,
66 This property is the information item for an array of properties. iIntValueMin and iIntValueMax
67 values in a property of this type defines the range of the property array
69 ESensrvArrayPropertyInfo = -2
73 * Identifies the range of values that must be used for TSensrvPropertyId. These ranges are defined so that
74 * any customers wishing to add additional properties not yet supported by Symbian can do so without
75 * causing clashes with Symbian defined properties.
76 * 1-4095 General channel properties owned and defined by Symbian
77 * 4096-8191 Specific Channel properties owned and defined by Symbian
78 * 8192-12287 A range for customers to define their own properties. Usage defined by customer
79 * @see TSensrvPropertyId
80 * @see TSensrvProperty
82 enum TSensrvPropertyRangeUsage
85 ESensrvPropertyRangeNotDefined = 0, // 0x0000
86 ESensrvGeneralPropertyRangeBase = 1, // 0x0001
87 ESensrvGeneralPropertyRangeEnd = 4095, // 0x0FFF
90 ESensrvChannelPropertyRangeBase = 4096, // 0x1000
91 ESensrvChannelPropertyRangeEnd = 8191, // 0x1FFF
93 // A range for licensees to define their own properties. Usage is defined by the licensee.
94 ESensrvLicenseePropertyRangeBase = 8192, // 0x2000
95 ESensrvLicenseePropertyRangeEnd = 12287 // 0x2FFF
99 * Type definition for property identifier.
100 * @see TSensrvProperty
102 typedef TUint32 TSensrvPropertyId;
107 * TSensrvProperty is a simple data class that contains sensor channel property information. The class has
108 * little behaviour and only does sanity checks where it is possible. It is therefore assumed that users of
109 * this class are aware of and conform to a properties definition for a given property identifier.
111 * There are 2 groups of properties, General Channel Properties and Specific Channel Properties.
113 * General Channel Properties are properties that are supported by all channels. These are defined in
114 * sensrvgeneralproperties.h. Specific Channel Properties are properties that are supported by specific
115 * channel types as required. These are defined in the relevant headers files.
117 * The property identifier uniquely identifies the property within a channel. These property ids must fall
118 * into the relevant range specified by TSensrvPropertyRangeUsage. Each property will have a constant
119 * defined for its identifier. e.g. KSensrvPropIdDataRate.
121 * @see TSensrvProperty::SetPropertyId()
122 * @see TSensrvProperty::GetPropertyId()
123 * @see TSensrvPropertyRangeUsage
124 * @see KSensrvPropIdDataRate
126 * The property type is used to determine whether the property is TInt, TReal or Buffer. The property type
127 * is automatically set when the value of the object is set.
129 * @see TSensrvPropertyType
130 * @see TSensrvProperty::PropertyType()
132 * The value fields are used to indicate the value of a property when the property contains a single int,
133 * real or buffer value. The min and max value fields are used when a property has a range of int or real
134 * values. A property cannot have a range of buffer values. The value and min/max values of a property
135 * will never be set at the same time.
137 * @see TSensrvProperty::GetValue()
138 * @see TSensrvProperty::SetValue()
139 * @see TSensrvProperty::GetValueRef()
140 * @see TSensrvProperty::GetMinValue()
141 * @see TSensrvProperty::SetMinValue()
142 * @see TSensrvProperty::GetMaxValue()
143 * @see TSensrvProperty::SetMaxValue()
145 * Properties can be read only which means it cannot be set by CSensrvChannel::SetPropertyL().
147 * @see TSensrvProperty::ReadOnly()
148 * @see TSensrvProperty::SetReadOnly()
149 * @see CSensrvChannel
151 * Properties can either be single properties, or can be a member of an array of properties. The array
152 * index field is set to ESensrvSingleProperty(-1) if the property is single. If a property is part of an
153 * array then the array index field will be set to ESensrvArrayPropertyInfo(-2) or the index for the array.
154 * When the array index is ESensrvArrayPropertyInfo the property uses the iIntValueMin and iIntValueMax fields
155 * to indicate the range of the array. When the array index is an actual index (neither ESensrvArrayPropertyInfo
156 * nor ESensrvArrayPropertyInfo) the property contains data.
160 * A Sensor channel which supports data rates within a given range can use one Data Rate
161 * property. The range is defined using the property's maximum and minimum value. E.g. A
162 * sensor channel supports a data range from 10Hz to 100Hz and all values within this range
163 * are feasible. To implement this use one Data Rate property with a minimum value 10 and a
164 * maximum value of 100.
166 * A Sensor channel which supports discrete data rates can use the Data Rate property as
167 * an array. E.g. A sensor channel supports the following data rates 10Hz, 40Hz and 50Hz.
168 * To implement this four different Data Rate properties are needed. The following table
169 * shows the content of the four properties, only mandatory attributes are shown.
172 * property ID Array index Value Min Value Max Value Read only
173 * ----------- ----------- ----- --------- --------- ---------
174 * 0x00000002 -2 1 0 2 EFalse
175 * 0x00000002 0 10 n/a n/a ETrue
176 * 0x00000002 1 40 n/a n/a ETrue
177 * 0x00000002 2 50 n/a n/a ETrue
180 * The first property (first row in table above) is the header for the property array. It
181 * defines that this property is an array property. The attributes of this property are:
184 * -2 means that the property is an array property
186 * 1 means that current value of the property is defined by the property with an array index of
187 * 1. The value is 40Hz in this example.
189 * 0 is the start index of the property array
191 * 2 is the last index of the property array
193 * EFalse means that the properties current value can be changed,
195 * In this example the possible values of the property are 0, 1, and 2 which corresponds to data
196 * rates of 10Hz, 40Hz and 50Hz.
198 * @see TSensrvArrayIndex
199 * @see TSensrvProperty::SetArrayIndex()
200 * @see TSensrvProperty::GetArraIndex()
202 * The property item index is used to identify a specific item in the channel data structure that the property
203 * refers to. For example the Accelerometer XYZ-axis data structure defines data for the x, y and Z axis.
204 * Individual properties could have been defined for each of these axis. Instead a single property is defined
205 * and the Item Index is used to identify the relevant axis in the channel data structure that the property
206 * applies to. The indexes for these specific items and the channel data structures themselves are defined in
207 * the sensor specific headers files found in epoc32\include\sensors\channels.
211 * Accelerometer data definition. TSensrvAccelerometerAxisDataIndexes is used to provide an index that
212 * relates to each of the class fields.
215 * // ACCELEROMETER RELATED DATATYPES
217 * // Accelerometer axis data type
219 * class TSensrvAccelerometerAxisData
223 * // Channel data type Id number
225 * static const TSensrvChannelDataTypeId KDataTypeId = 0x1020507E;
228 * // Channel data type index numbers
230 * enum TSensrvAccelerometerAxisDataIndexes
239 * // - Item name: Sampling time.
241 * // - Conditions: None
242 * // - Description: Timestamp for a sample.
247 * // - Item name: Accelerometer x-axis
249 * // - Conditions: Single limit and range
250 * // - Description: Accelerometer values from x-axis
255 * // - Item name: Accelerometer y-axis
257 * // - Conditions: Single limit and range
258 * // - Description: Accelerometer values from y-axis
263 * // - Item name: Accelerometer z-axis
265 * // - Conditions: Single limit and range
266 * // - Description: Accelerometer values from z-axis
272 * @see TSensrvProperty::SetItemIndex()
273 * @see TSensrvProperty::PropertyItemIndex()
274 * @lib sensrvutil.lib
277 NONSHARABLE_CLASS( TSensrvProperty )
284 IMPORT_C TSensrvProperty();
287 * Constructor to create complete integer type property.
290 * @param aPropertyId Id of the property
291 * @param aItemIndex Item index of the property. Mapped to a specific item in channel data structure.
292 * @param aValue Value of the property.
293 * @param aMaxValue Maximum value of the property
294 * @param aMinValue Minimum value of the property
295 * @param aReadOnly Readonly-flag of the property
296 * @param aPropertyType Type of the property
298 IMPORT_C TSensrvProperty( const TSensrvPropertyId aPropertyId,
299 const TInt aItemIndex,
301 const TInt aMaxValue,
302 const TInt aMinValue,
303 const TBool aReadOnly,
304 const TSensrvPropertyType aPropertyType );
307 * Constructor to create property object for setting integer property value.
310 * @param aPropertyId Id of the property
311 * @param aItemIndex Item index of the property. Mapped to a specific item in channel data structure.
312 * @param aValue Value of the property.
314 IMPORT_C TSensrvProperty( const TSensrvPropertyId aPropertyId,
315 const TInt aItemIndex,
319 * Constructor to create complete TReal type of property.
322 * @param aPropertyId Id of the property
323 * @param aItemIndex Item index of the property. Mapped to a specific item in channel data structure.
324 * @param aValue Value of the property.
325 * @param aMaxValue Maximum value of the property
326 * @param aMinValue Minimum value of the property
327 * @param aReadOnly Readonly-flag of the property
328 * @param aPropertyType Type of the property
330 IMPORT_C TSensrvProperty( const TSensrvPropertyId aPropertyId,
331 const TInt aItemIndex,
333 const TReal aMaxValue,
334 const TReal aMinValue,
335 const TBool aReadOnly,
336 const TSensrvPropertyType aPropertyType );
339 * Constructor to create property object for setting real property value.
342 * @param aPropertyId Id of the property
343 * @param aItemIndex Item index of the property. Mapped to a specific item in channel data structure.
344 * @param aValue Value of the property.
346 IMPORT_C TSensrvProperty( const TSensrvPropertyId aPropertyId,
347 const TInt aItemIndex,
348 const TReal aValue );
351 * Constructor to create complete buffer property.
354 * @param aPropertyId Id of the property
355 * @param aItemIndex Item index of the property. Mapped to a specific item in channel data structure.
356 * @param aValue Value of the property. Max length is defined in KSensrvPropertyTextBufferSize.
357 * @param aReadOnly Readonly-flag of the property
358 * @param aPropertyType Type of the property
360 IMPORT_C TSensrvProperty( const TSensrvPropertyId aPropertyId,
361 const TInt aItemIndex,
362 const TDesC8& aValue,
363 const TBool aReadOnly,
364 const TSensrvPropertyType aPropertyType );
367 * Constructor to create property object for setting buffer property value.
370 * @param aPropertyId Id of the property
371 * @param aItemIndex Item index of the property. Mapped to a specific item in channel data structure.
372 * @param aValue Value of the property. Max length is defined in KSensrvPropertyTextBufferSize.
374 IMPORT_C TSensrvProperty( const TSensrvPropertyId aPropertyId,
375 const TInt aItemIndex,
376 const TDesC8& aValue );
379 * Set the property Id for the property.
382 * @param aPropertyId Property Id to be set.
384 IMPORT_C void SetPropertyId( TSensrvPropertyId aPropertyId );
390 * @return Property Id
392 IMPORT_C TSensrvPropertyId GetPropertyId() const;
395 * Set the property item index for the property.
398 * @param aItemIndex property item index to be set.
400 IMPORT_C void SetItemIndex( TInt aItemIndex );
403 * Get the property item index number
406 * @return Item index number.
408 IMPORT_C TInt PropertyItemIndex() const;
411 * Return property type
414 * @return Property type's Id
416 IMPORT_C TSensrvPropertyType PropertyType() const;
419 * Checks if the property is readonly
422 * @return ETrue value indicates that property is a read only property.
424 IMPORT_C TBool ReadOnly() const;
427 * Set the readonly information for the property.
430 * @param aReadOnly readonly information to be set. EFalse means that the property is not readonly.
432 IMPORT_C void SetReadOnly( TBool aReadOnly );
435 * Set integer property value
438 * @param aValue Value to be set.
439 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
442 IMPORT_C void SetValue( const TInt aValue );
445 * Set real property value
448 * @param aValue Value to be set.
449 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
452 IMPORT_C void SetValue( const TReal aValue );
455 * Set buffer property value
458 * @param aValue Value to be set.
459 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
462 IMPORT_C void SetValue( const TDesC8& aValue );
465 * Get integer property value
468 * @param aValue Value to get
469 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
472 IMPORT_C void GetValue( TInt& aValue ) const;
475 * Get real property value
478 * @param aValue Value to get
479 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
482 IMPORT_C void GetValue( TReal& aValue ) const;
485 * Get buffer property value
488 * @param aValue Destination where a property value is to be copied
489 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
492 IMPORT_C void GetValue( TDes8& aValue ) const;
495 * Get reference to buffer property value
498 * @return Reference to a property value
499 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
502 IMPORT_C TDes8& GetValueRef();
505 * Get property maximum value of integer property
508 * @param aMaxValue Maximum value to get
509 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
512 IMPORT_C void GetMaxValue( TInt& aMaxValue ) const;
515 * Get property minimum value of integer property
518 * @param aMinValue Minimum value to get
519 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
522 IMPORT_C void GetMinValue( TInt& aMinValue ) const;
525 * Set property maximum value of integer property
528 * @param aMaxValue Maximum value to be set
529 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
532 IMPORT_C void SetMaxValue( TInt aMaxValue );
535 * Set property minimum value of integer property
538 * @param aMinValue Minimum value to be set
539 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
542 IMPORT_C void SetMinValue( TInt aMinValue );
545 * Get property maximum value of real property
548 * @param aMaxValue Maximum value to get
549 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
552 IMPORT_C void GetMaxValue( TReal& aMaxValue ) const;
555 * Get property minimum value of real property
558 * @param aMinValue Minimum value to get
559 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
562 IMPORT_C void GetMinValue( TReal& aMinValue ) const;
565 * Set property maximum value of real property
568 * @param aMaxValue Maximum value to be set.
569 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
572 IMPORT_C void SetMaxValue( const TReal& aMaxValue );
575 * Set property minimum value of real property
578 * @param aMinValue Minimum value to be set.
579 * @panic KSensrvPanicCategory ESensrvPanicInvalidPropertyType Panic if the property object is not
582 IMPORT_C void SetMinValue( const TReal& aMinValue );
585 * Set security info of the property. This should be set to the Security info for the client process
588 * @param aSecurityInfo Security info to be set
590 IMPORT_C void SetSecurityInfo( const TSecurityInfo& aSecurityInfo );
593 * Get security info of the property
596 * @return Security info of the property
598 IMPORT_C TSecurityInfo GetSecurityInfo() const;
601 * Set array index of the property.
604 * @param aArrayIndex Array index to be set
605 * @see TSensrvArrayIndex
606 * @see KSensrvPropIdDataRate for an example
608 IMPORT_C void SetArrayIndex( const TInt aArrayIndex );
611 * Get array index of the property
614 * @return Array index of the property.
615 * @see TSensrvArrayIndex
616 * @see KSensrvPropIdDataRate for an example
618 IMPORT_C TInt GetArrayIndex() const;
621 // property identifier
622 TSensrvPropertyId iPropertyId;
624 // property item index
637 TBuf8<KSensrvPropertyTextBufferSize> iBufValue;
657 TSensrvPropertyType iPropertyType;
659 // property security infomation
660 TSecurityInfo iSecurityInfo;
666 #endif //SENSRVPROPERTY_H