classicui_plat/avkon_testability_api/inc/TasDataModelInterface.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2008 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:  ECom plugin interface for testability data model for passing ui 
       
    15 *                data from avkon to pc
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __TASDATAMODELINTERFACE_H__
       
    21 #define __TASDATAMODELINTERFACE_H__
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <ecom/ecom.h>
       
    26 
       
    27 // CONSTANTS
       
    28 const static TUid KTasDataModelInterfaceUid = { 0x2001950D };
       
    29 const static TUid KTasDataModelImplementationUid = { 0x2001950E };
       
    30 
       
    31 // MACROS
       
    32 
       
    33 // DATA TYPES
       
    34 
       
    35 // FUNCTION PROTOTYPES
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 
       
    39 class MTasObject;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 /**
       
    44  * Represents an attribute in tas data 
       
    45  * model. Attribute can have values or 
       
    46  * object as members.
       
    47  * 
       
    48  * Attribute in the tas data model represents an attribute of an object.
       
    49  * Attributes can be simple name value pairs or more complicated structures.
       
    50  * Complicated attribute values are represented as tasobjects.
       
    51  * 
       
    52  * The object does not have to contain all elements. Implementations of serialize
       
    53  * have to take this fact into consideration.
       
    54  * 
       
    55  */
       
    56 class MTasAttribute
       
    57     {
       
    58     public:
       
    59         
       
    60         /**
       
    61           * Set an id for the attribute. Used to identify objects.
       
    62           *   
       
    63           * @param aName Name of the attribute. 
       
    64           */
       
    65          virtual void SetIdL( const TDesC& aId )=0;
       
    66         
       
    67          /**
       
    68           * Set an id for the attribute. Used to identify objects.
       
    69           *   
       
    70           * @param aName Name of the attribute. 
       
    71           */
       
    72          virtual void SetIdL( const TInt& aId )=0;
       
    73                   
       
    74         /**
       
    75          * Set the name of the attribute. A new copy of the given descriptor is made.
       
    76          * The value is copied simply to avoid a scenario where the data model 
       
    77          * would remove a buffer which would still be needed by the calling 
       
    78          * component.  
       
    79          * @param aName Name of the attribute. 
       
    80          */
       
    81         virtual void SetNameL( const TDesC& aName )=0;
       
    82         
       
    83         /**
       
    84          * Set the type of the attribute.  A new copy of the given descriptor is made.
       
    85          * The value is copied simply to avoid a scenario where the data model 
       
    86          * would remove a buffer which would still be needed by the calling 
       
    87          * component.         
       
    88          * 
       
    89          * @param aType Type of the attribute. 
       
    90          */
       
    91         virtual void SetTypeL( const TDesC& aName  )=0;
       
    92         
       
    93         /**
       
    94          * Add a simple value to the attribute. Simple values are 
       
    95          * can be repserented as string. If a more complicated 
       
    96          * value is required use AddObject.  
       
    97          * A new copy of the given descriptor is made. 
       
    98          * The value is copied simply to avoid a scenario where the data model 
       
    99          * would remove a buffer which would still be needed by the calling 
       
   100          * component.
       
   101          * 
       
   102          * @param aValue New value for the attribute.
       
   103          */
       
   104         virtual void AddValueL( const TDesC& aValue  )=0;
       
   105         
       
   106           
       
   107                 
       
   108         /**
       
   109          * Deep copy the data from the given attribute to this attribute.
       
   110          * 
       
   111          * @param aAttribute Data from the given attribute will be deep 
       
   112          *                   copied into this attribute.
       
   113          */
       
   114         virtual void CloneL( MTasAttribute &aAttribute )=0;
       
   115         
       
   116         /**
       
   117          * Destructor for MTasAttribute.
       
   118          * Needs to be defined here in case some implementations use
       
   119          * arrays to avoid user 42 panic.         
       
   120          * 
       
   121          */
       
   122         virtual ~MTasAttribute(){};
       
   123 
       
   124     };
       
   125 
       
   126 /**
       
   127  * Represents an object in tas data model. MTasObjects are derived from MTasAttribute.
       
   128  * MTasObject can contains a handle to its parent, children and derivation tree.
       
   129  *  
       
   130  * The object does not have to contain all elements. Implementations of serialize
       
   131  * have to take this fact into consideration. 
       
   132  * 
       
   133  */
       
   134 class MTasObject : public MTasAttribute
       
   135     {
       
   136     public:
       
   137       
       
   138         /**
       
   139          * Add new attribute to the MTasObject.
       
   140          * A reference to a new empty MTasAttribute instance is returned.          
       
   141          * 
       
   142          * @return Reference to a new MTasAttribute.
       
   143          */
       
   144         virtual MTasAttribute& AddAttributeL()=0;
       
   145         
       
   146         /**
       
   147          * Add new attribute to the MTasObject.
       
   148          * A reference to a new empty MTasAttribute instance is returned.          
       
   149          * 
       
   150          * @param aName Name of the attribute. 
       
   151          * @param aValue Value of the attribute. 
       
   152          * 
       
   153          * @return Reference to a new MTasAttribute.
       
   154          */
       
   155         virtual MTasAttribute& AddAttributeL( const TDesC& aName, const TDesC& aValue)=0;
       
   156         
       
   157         /**
       
   158          * Add new attribute to the MTasObject.
       
   159          * A reference to a new empty MTasAttribute instance is returned.          
       
   160          * 
       
   161          * @param aName Name of the attribute. 
       
   162          * @param aValue Value of the attribute.
       
   163          * 
       
   164          * @return Reference to a new MTasAttribute.
       
   165          */
       
   166         virtual MTasAttribute& AddAttributeL( const TDesC& aName, const TInt& aValue)=0;
       
   167                 
       
   168         /**
       
   169          * Set the parent of this object. Parent is not the object that this object derives
       
   170          * from but an object that this object belongs to e.g ui component in a window.
       
   171          * 
       
   172          * The parent will be added to model as a deep copy of the given object. This is done to make
       
   173          * sure that the parent object which may also reside in a different location in the model
       
   174          * is not deleted too early by some party. This means that the parent given will not be deleted 
       
   175          * by this model.
       
   176          * 
       
   177          * @param aParent Parent of this object.
       
   178          */
       
   179         virtual void SetParentL( MTasObject& aParent )=0;
       
   180 
       
   181         
       
   182         /**
       
   183           * Add a complicated value to the object.
       
   184           * Returns a reference new empty MTasObject which has been 
       
   185           * added to the attribute.         
       
   186           * 
       
   187           * @return A reference to a new empty MTasObject instance.
       
   188           */
       
   189          virtual MTasObject& AddObjectL( )=0;                      
       
   190         
       
   191         /**
       
   192          * Add the object that this object derives from.
       
   193          * A reference to a new MTasObject instance is retuned.
       
   194          * 
       
   195          * @return A reference to a new MTasObject instance.
       
   196          */        
       
   197         virtual MTasObject& AddSuperClassL()=0;
       
   198 
       
   199         /**
       
   200          * Deep copy the data from the given object to this object.
       
   201          * 
       
   202          * @param aObject Data from the given object will be deep 
       
   203          *                   copied into this object.
       
   204          */
       
   205         virtual void CloneL( MTasObject& aObject)=0;        
       
   206         
       
   207         /**
       
   208          * Destructor for MTasObject
       
   209          * Needs to be defined here in case some implementations use
       
   210          * arrays to avoid user 42 panic.         
       
   211          * 
       
   212          */
       
   213         virtual ~MTasObject(){};
       
   214     };
       
   215 
       
   216 /**
       
   217  * The container can represent an application for instance that contains 
       
   218  * the objects.   
       
   219  * 
       
   220  */
       
   221 class MTasObjectContainer 
       
   222     {
       
   223     public:
       
   224         /**
       
   225          * Set an id for the attribute. Used to identify objects.
       
   226          *   
       
   227          * @param aName Name of the attribute. 
       
   228          */
       
   229         virtual void SetIdL( const TDesC& aId )=0;
       
   230     
       
   231         /**
       
   232          * Set the name of the attribute. A new copy of the given descriptor is made.
       
   233          * The value is copied simply to avoid a scenario where the data model 
       
   234          * would remove a buffer which would still be needed by the calling 
       
   235          * component.  
       
   236          * @param aName Name of the attribute. 
       
   237          */
       
   238         virtual void SetNameL( const TDesC& aName )=0;
       
   239     
       
   240         /**
       
   241          * Set the type of the attribute.  A new copy of the given descriptor is made.
       
   242          * The value is copied simply to avoid a scenario where the data model 
       
   243          * would remove a buffer which would still be needed by the calling 
       
   244          * component.         
       
   245          * 
       
   246          * @param aType Type of the attribute. 
       
   247          */
       
   248         virtual void SetTypeL( const TDesC& aName  )=0;    
       
   249     
       
   250         /**
       
   251          * Add new object to the container.
       
   252          * 
       
   253          * @return New MTasObject added to the storage.
       
   254          */
       
   255         virtual MTasObject& AddNewObjectL()=0;
       
   256         
       
   257         /**
       
   258          * Add new object to the container.
       
   259          * The container can represent an application for instance that contains 
       
   260          * the objects.
       
   261          * 
       
   262          * @param aName Name of the object.
       
   263          * @param aValue Value of the object.
       
   264          * @return New MTasObject added to the storage.
       
   265          */
       
   266         virtual MTasObject& AddNewObjectL( const TDesC& aName, const TDesC& aType, const TDesC& aId )=0;                                
       
   267 
       
   268         /**
       
   269          * Deep copy the data from the given container to this container.
       
   270          * 
       
   271          * @param aContainer Data from the given container will be deep 
       
   272          *                   copied into this container.
       
   273          */
       
   274         virtual void CloneL( MTasObjectContainer& aContainer )=0;           
       
   275         
       
   276         /**
       
   277          * Destructor for MTasObjectContainer
       
   278          * Needs to be defined here in case some implementations use
       
   279          * arrays to avoid user 42 panic.         
       
   280          * 
       
   281          */
       
   282         virtual ~MTasObjectContainer(){};
       
   283     };
       
   284 
       
   285 /**
       
   286 * Interface to the TasDataModel. The tas data model contains the ui data collected 
       
   287 * From avkon. The data format and internal data model implementation are the responsibility of
       
   288 * intarface implementations.
       
   289 * 
       
   290 * Some implementation considerations:
       
   291 * All attributes of MTasAttribute and MTasObject are optional. This means that serialize 
       
   292 * implementations must take this fact into consideration. 
       
   293 * The model must be responsible for freeing all memory it has reserved. 
       
   294 * The buffer passed to the SerializeTasDataL is naturally the responsibility 
       
   295 * of the caller.
       
   296 */
       
   297 class CTasDataModelInterface : public CBase
       
   298     {
       
   299     public:
       
   300         /**
       
   301          * Symbian constructor
       
   302          */ 
       
   303         static CTasDataModelInterface* NewL();
       
   304 
       
   305         /**
       
   306         * Wraps ECom object instantitation
       
   307         * plug-in loaded by its UID
       
   308         *
       
   309         * @param aUID service plugin implementation UDI
       
   310         */
       
   311         static CTasDataModelInterface* NewL(const TUid aUID);
       
   312 
       
   313         /**
       
   314         * Wraps ECom object instantitation
       
   315         * default resovler is used
       
   316         *
       
   317         * @param aMatchString service plugin name
       
   318         */
       
   319         static CTasDataModelInterface* NewL(const TDesC8& aMatchString);        
       
   320         
       
   321         /**
       
   322          * Destructor
       
   323          */
       
   324         virtual ~CTasDataModelInterface();
       
   325         
       
   326 
       
   327     public: //Comm plugin interface methods        
       
   328         
       
   329         /**
       
   330          * Add new Object to the data model.
       
   331          * Objects added directly to the DataModel 
       
   332          * will be serialized to the top level.
       
   333          * 
       
   334          * @return A reference to a new TasObject, which will be added to the data model.
       
   335          */
       
   336         virtual MTasObjectContainer& AddNewObjectContainerL() = 0;
       
   337         
       
   338         /**
       
   339          * Clean and destroy the added objects from the data model.
       
   340          * 
       
   341          */
       
   342         virtual void CleanObjectData() = 0;
       
   343 
       
   344         /**
       
   345          * Make a deep copy of the given CTasDataModelInterface
       
   346          * object to this CTasDataModelInterface object.
       
   347          * Any existing data will be removed berofe the clone is performed.
       
   348          * For merging models use MergeL.
       
   349          * All data is copied so the original model can be destroyed 
       
   350          * freely after the clone.
       
   351          * 
       
   352          * @param aModel CTasDataModelInterface to be copied into this object.
       
   353          */
       
   354         virtual void CloneL( CTasDataModelInterface& aModel )=0;         
       
   355 
       
   356         /**
       
   357          * Merges two TasDataModel structures into one model.
       
   358          * Merging is done by appending the TasObjectContainers 
       
   359          * from the given model to this model. Merged data is copied
       
   360          * so that the given model can be deleted with no affect to this 
       
   361          * instance.
       
   362          * 
       
   363          * @param aModel CTasDataModelInterface to be merged to this object.
       
   364          */
       
   365         virtual void MergeL( CTasDataModelInterface& aModel )=0;
       
   366         
       
   367         /**
       
   368          * Serialize the datamodel structure into the given buffer.
       
   369          * 
       
   370          * Implementing classes must consider the following facts when implementing:
       
   371          * All variables in MTasObject and MTasAttribute are optional. Existence of
       
   372          * data can not be assumed.
       
   373          * All memory reserved by the model is to be removed once model deleted.
       
   374          * aDataBuffer is considered not part of the model so its is the responsibility
       
   375          * of the calling module.          
       
   376          *          
       
   377          * @param The target buffer to where to serialize the data model.         
       
   378          * @return Amount of bytes updated to the buffer.
       
   379          */
       
   380         virtual TInt SerializeTasDataL( 
       
   381                 RBuf8& aDataBuffer, 
       
   382                 TBool aCompressionOn = EFalse ) = 0;
       
   383         
       
   384         /**
       
   385          * Serialize the datamodel structure into a file.
       
   386          * 
       
   387          * Implementing classes must consider the following facts when implementing:
       
   388          * All variables in MTasObject and MTasAttribute are optional. Existence of
       
   389          * data can not be assumed.
       
   390          *           
       
   391          *          
       
   392          * @param The target buffer to where to serialize the data model.
       
   393          * @return Number of byte written          
       
   394          */
       
   395         virtual TInt SerializeTasDataL( 
       
   396                 RFs& aRFs, 
       
   397                 const TDesC& aFileName, 
       
   398                 TBool aCompressionOn = EFalse ) = 0;
       
   399         
       
   400         
       
   401     private: // Data
       
   402         /// Current instance identifier
       
   403         TUid iImplementation;
       
   404 
       
   405     };
       
   406 
       
   407 #include <TasDataModelInterface.inl>
       
   408 
       
   409 #endif // __TasDataModelInterface_H__
       
   410 
       
   411 // End of File