uiaccelerator_plat/alf_visual_api/inc/alf/alfproperty.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2007 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:   Property value for Alfred
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_ALFPROPERTYVALUE_H
       
    21 #define C_ALFPROPERTYVALUE_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <libc/limits.h> // For max and min int sizes.
       
    25 
       
    26 #include <alf/alftimedvalue.h>
       
    27 
       
    28 
       
    29 /** Property types. */
       
    30 enum TAlfPropertyType
       
    31     {
       
    32     /** Property has no value type. */
       
    33     EAlfPropertyTypeUndefined,
       
    34     
       
    35     /** Property is a string. */
       
    36     EAlfPropertyTypeString,
       
    37     
       
    38     /** Property is a TRangedValue. */    
       
    39     EAlfPropertyTypeInteger,
       
    40     
       
    41     /** Property is a CAlfTimedValue. */
       
    42     EAlfPropertyTypeTimedValue
       
    43     };
       
    44 
       
    45 /**
       
    46  * A ranged value with specifiable min/max bounds.
       
    47  */
       
    48 class TRangedValue
       
    49 {
       
    50 public:
       
    51     TRangedValue()
       
    52     {
       
    53     iValue = 0;
       
    54     iMin = INT_MIN;
       
    55     iMax = INT_MAX;
       
    56     }
       
    57     
       
    58     TRangedValue(TInt aValue, TInt aMin, TInt aMax)
       
    59     :
       
    60     iValue(aValue),
       
    61     iMin(aMin),
       
    62     iMax(aMax)
       
    63     {
       
    64     }
       
    65     
       
    66     TInt iValue;
       
    67     TInt iMin;
       
    68     TInt iMax;
       
    69 };
       
    70 
       
    71 
       
    72 
       
    73 /**
       
    74  * Property base class
       
    75  *
       
    76  * A generic property value, it can be derived to create new property types
       
    77  * that can be accessed by name.
       
    78  *
       
    79  * @todo This class should be able to represent a generic property without any type.
       
    80  *
       
    81  * @see CAlfPropertyOwner
       
    82  *
       
    83  */
       
    84 NONSHARABLE_CLASS(CAlfProperty) : public CBase
       
    85     {
       
    86 public:
       
    87 
       
    88     CAlfProperty();
       
    89 
       
    90     ~CAlfProperty();
       
    91 
       
    92     /**
       
    93      * Constructs a new empty property.
       
    94      *
       
    95      * @param aName the name of this property.
       
    96      */
       
    97     void ConstructL(const TDesC8& aName);
       
    98 
       
    99     /**
       
   100      * Returns the type of this property.
       
   101      *
       
   102      * @return Property type.
       
   103      * @see TAlfPropertyType
       
   104      */
       
   105     TAlfPropertyType Type() const;
       
   106 
       
   107     /**
       
   108      * Returns the name of this property.
       
   109      *
       
   110      * @return Property name.
       
   111      */
       
   112     const TDesC8& Name() const;
       
   113     
       
   114     /**
       
   115      * Compare names for sort operations.
       
   116      * Does a letter-by-letter compare of property names.
       
   117      *
       
   118      * @param aA First property.
       
   119      * @param aA Second property.     
       
   120      * @return difference between names.
       
   121      */
       
   122     static TInt CompareByName(const CAlfProperty& aA, const CAlfProperty& aB);
       
   123 
       
   124     /**
       
   125      * Do names match.
       
   126      * Compares the names of two properties.
       
   127      * @param aA First property.
       
   128      * @param aA Second property.     
       
   129      * @return ETrue on a match.
       
   130      */
       
   131     static TBool Matches(const CAlfProperty& aA, const CAlfProperty& aB);
       
   132     
       
   133 protected:
       
   134     HBufC8* iName;   // Owned.        
       
   135     TAlfPropertyType iType;    
       
   136     };
       
   137 
       
   138 /**
       
   139  *  Integer value property base class
       
   140  *
       
   141  *  A single property containing an integer value and its range.
       
   142  *
       
   143  */
       
   144 NONSHARABLE_CLASS(CAlfPropertyInteger) : public CAlfProperty
       
   145     {
       
   146     public:
       
   147     /* Constructors and destructor. */
       
   148 
       
   149     CAlfPropertyInteger();
       
   150 
       
   151     ~CAlfPropertyInteger();    
       
   152     
       
   153     void Set(const TRangedValue& aValue);
       
   154     
       
   155     TRangedValue Data() const;
       
   156         
       
   157     private:
       
   158     TRangedValue iValue;        
       
   159     };
       
   160 
       
   161 /**
       
   162  *  Timed value property base class
       
   163  *
       
   164  *  A single property containing an integer value and its range.
       
   165  *
       
   166  */
       
   167 NONSHARABLE_CLASS(CAlfPropertyTimedValue) : public CAlfProperty
       
   168     {
       
   169     public:
       
   170     /* Constructors and destructor. */
       
   171 
       
   172     CAlfPropertyTimedValue();
       
   173 
       
   174     ~CAlfPropertyTimedValue();    
       
   175     
       
   176     void Set(TAlfTimedValue& aValue);
       
   177     
       
   178     TAlfTimedValue& Data();
       
   179         
       
   180     private:
       
   181     TAlfTimedValue iTimedValue;         
       
   182     };
       
   183     
       
   184     
       
   185 /**
       
   186  *  String property base class
       
   187  *
       
   188  *  A single property containing a string.
       
   189  *
       
   190  */
       
   191 NONSHARABLE_CLASS(CAlfPropertyString) : public CAlfProperty
       
   192     {
       
   193     public:
       
   194     /* Constructors and destructor. */
       
   195 
       
   196     CAlfPropertyString();
       
   197 
       
   198     ~CAlfPropertyString();    
       
   199     
       
   200     void SetL(const TDesC& aValue);
       
   201     
       
   202     TDesC* Data() const;
       
   203         
       
   204     private:
       
   205     HBufC* iString;         
       
   206     };
       
   207 
       
   208 
       
   209 #endif // C_ALFPROPERTYVALUE_H