ncdengine/provider/server/inc/ncdnodefactory.h
changeset 4 32704c33136d
equal deleted inserted replaced
-1:000000000000 4:32704c33136d
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Contains CNcdNodeFactory class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NCD_NODE_FACTORY_H
       
    20 #define NCD_NODE_FACTORY_H
       
    21 
       
    22 
       
    23 // For streams
       
    24 #include <s32mem.h>
       
    25 
       
    26 // For CBase
       
    27 #include <e32base.h>
       
    28 
       
    29 #include "ncdnodeclassids.h"
       
    30 
       
    31 class CNcdNodeIdentifier;
       
    32 class CNcdNodeManager;
       
    33 class CNcdNodeDbManager;
       
    34 class CNcdNode;
       
    35 class CNcdNodeItem;
       
    36 class CNcdNodeFolder;
       
    37 class CNcdNodeSupplier;
       
    38 class CNcdNodeMetaData;
       
    39 class CNcdNodeItemMetaData;
       
    40 class CNcdNodeFolderMetaData;
       
    41 
       
    42 /**
       
    43  *  This class object should be used to create node and metadata
       
    44  *  objects instead of directly creating them in different places
       
    45  *  of code.
       
    46  *  Also, functions to check the object types are provided here.
       
    47  *
       
    48  *  @lib ?library
       
    49  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    50  */
       
    51 class CNcdNodeFactory : public CBase
       
    52     {
       
    53 
       
    54 public:
       
    55 
       
    56     /**
       
    57      * TNcdNodeType is used to inform the general type of the
       
    58      * node. Folder may contain other folders or items.
       
    59      */
       
    60     enum TNcdNodeType
       
    61         {
       
    62         /**
       
    63          * The node is some kind of item node.
       
    64          */ 
       
    65         ENcdNodeItem,
       
    66 
       
    67         /**
       
    68          * The node is some kind of folder node.
       
    69          */ 
       
    70         ENcdNodeFolder,
       
    71         
       
    72         /**
       
    73          * The node some kind of root
       
    74          */
       
    75         ENcdNodeRoot,
       
    76         
       
    77         /**
       
    78          * This node is not really a full node but a wrapper that will
       
    79          * contain an actual node when the type of the actual node is known
       
    80          * and the actual node can be created.
       
    81          */
       
    82         ENcdNodeSupplier,
       
    83         
       
    84         /**
       
    85          * The node is a search bundle folder (special type needed because
       
    86          * bundle searching needs special handling).
       
    87          */
       
    88         ENcdNodeSearchBundle
       
    89         };
       
    90 
       
    91 
       
    92     /**
       
    93      * Defines the purpose of the node. This enumeration can be used
       
    94      * to inform if node should be normal node or if it should have
       
    95      * some special meaning or functionality.
       
    96      */
       
    97     enum TNcdNodePurpose
       
    98         {
       
    99         /**
       
   100          * This means that normal nodes should be created.
       
   101          */
       
   102         ENcdNormalNode,
       
   103 
       
   104         /**
       
   105          * This means that the ref data is gotten as a result of the search.
       
   106          */
       
   107         ENcdSearchNode,
       
   108 
       
   109         /**
       
   110          * This means that the ref data was gotten from the configuration server
       
   111          * for the bundle node.
       
   112          */
       
   113         ENcdBundleNode,
       
   114 
       
   115         /**
       
   116          * This means that the configuration server has given data for the 
       
   117          * transparent node.
       
   118          */
       
   119         ENcdTransparentNode,
       
   120 
       
   121         /**
       
   122          * This means that the given data is for the child of the transparent parent
       
   123          * folder. This type should be used only for the nodes that are directly children
       
   124          * of the transparent folder. The grand children of the transparent folder should
       
   125          * use ENormalNode type.
       
   126          *
       
   127          * @note Because the parser gives the child data before the parent data, this type
       
   128          * can be used to check if the parent that will be created should be transparent folder
       
   129          * instead of for example normal 
       
   130          */
       
   131         ENcdChildOfTransparentNode
       
   132         
       
   133         };
       
   134 
       
   135 
       
   136     /**
       
   137      * NewL
       
   138      *
       
   139      * @param aNodeManager
       
   140      * @return CNcdNodeFactory* Pointer to the created object 
       
   141      * of this class.
       
   142      */
       
   143     static CNcdNodeFactory* NewL( CNcdNodeManager& aNodeManager );
       
   144 
       
   145     /**
       
   146      * NewLC
       
   147      *
       
   148      * @param aNodeManager
       
   149      * @return CNcdNodeFactory* Pointer to the created object 
       
   150      * of this class.
       
   151      */
       
   152     static CNcdNodeFactory* NewLC( CNcdNodeManager& aNodeManager );
       
   153 
       
   154 
       
   155     /**
       
   156      * Destructor
       
   157      *
       
   158      */
       
   159     virtual ~CNcdNodeFactory();
       
   160 
       
   161 
       
   162 public: // Functions to check the node types and node purposes
       
   163 
       
   164     /** 
       
   165      *
       
   166      */
       
   167     static TNcdNodeType NodeTypeL( const TDesC8& aNodeData );
       
   168 
       
   169     /**
       
   170      *
       
   171      */
       
   172     static TNcdNodeType NodeTypeL( const CNcdNode& aNode );
       
   173 
       
   174     /**
       
   175      *
       
   176      */
       
   177     static TNcdNodeType NodeTypeL( NcdNodeClassIds::TNcdNodeClassId aClassId );
       
   178 
       
   179 
       
   180     /**
       
   181      * @note Warning! Does not identify ENcdChildOfTransparentNode but returns
       
   182      * ENcdNormalNode instead.
       
   183      */
       
   184     static TNcdNodePurpose NodePurposeL( const CNcdNode& aNode );
       
   185 
       
   186     /**
       
   187      * @see CNcdNodeFactory::NodePurposeL
       
   188      */
       
   189     static TNcdNodePurpose NodePurposeL( NcdNodeClassIds::TNcdNodeClassId aClassId );    
       
   190     
       
   191 
       
   192 public: // Functions to find out the node class id
       
   193 
       
   194     /**
       
   195      * This function gives the class id of a node that has given properties.
       
   196      * The class id can be used to create the node of the right type by
       
   197      * using the creation function of this class.
       
   198      *
       
   199      * @param aNodeType
       
   200      * @param aNodePurpose
       
   201      * @return NcdNodeClassIds::TNcdNodeClassId Class of the node that has
       
   202      * the given properties.
       
   203      */
       
   204     static NcdNodeClassIds::TNcdNodeClassId NodeClassIdL( CNcdNodeFactory::TNcdNodeType aNodeType,
       
   205                                                          CNcdNodeFactory::TNcdNodePurpose aNodePurpose );
       
   206 
       
   207 
       
   208 public: // Functions to create node objects
       
   209 
       
   210     /**
       
   211      *
       
   212      */
       
   213     CNcdNodeItem* CreateNodeItemL( const CNcdNodeIdentifier& aParentIdentifier,
       
   214                                    const CNcdNodeIdentifier& aMetaDataIdentifier, 
       
   215                                    NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   216 
       
   217     /**
       
   218      * @see CNcdNodeFactory::CreateNodeItemL
       
   219      */
       
   220     CNcdNodeItem* CreateNodeItemLC( const CNcdNodeIdentifier& aParentIdentifier,
       
   221                                     const CNcdNodeIdentifier& aMetaDataIdentifier,
       
   222                                     NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   223 
       
   224     /**
       
   225      *
       
   226      */
       
   227     CNcdNodeItem* CreateNodeItemL( const CNcdNodeIdentifier& aNodeIdentifier, 
       
   228                                    NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   229 
       
   230     /**
       
   231      * @see CNcdNodeFactory::CreateNodeItemL
       
   232      */
       
   233     CNcdNodeItem* CreateNodeItemLC( const CNcdNodeIdentifier& aNodeIdentifier,
       
   234                                     NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   235                                     
       
   236 
       
   237     /**
       
   238      *
       
   239      */
       
   240     CNcdNodeFolder* CreateNodeFolderL( const CNcdNodeIdentifier& aParentIdentifier,
       
   241                                        const CNcdNodeIdentifier& aMetaDataIdentifier, 
       
   242                                        NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   243 
       
   244     /**
       
   245      * @see CNcdNodeFactory::CreateNodeFolderL
       
   246      */
       
   247     CNcdNodeFolder* CreateNodeFolderLC( const CNcdNodeIdentifier& aParentIdentifier,
       
   248                                         const CNcdNodeIdentifier& aMetaDataIdentifier,
       
   249                                         NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   250 
       
   251     /**
       
   252      *
       
   253      */
       
   254     CNcdNodeFolder* CreateNodeFolderL( const CNcdNodeIdentifier& aNodeIdentifier, 
       
   255                                        NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   256 
       
   257     /**
       
   258      * @see CNcdNodeFactory::CreateNodeFolderL
       
   259      */
       
   260     CNcdNodeFolder* CreateNodeFolderLC( const CNcdNodeIdentifier& aNodeIdentifier,
       
   261                                         NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   262 
       
   263     /**
       
   264      *
       
   265      */
       
   266     CNcdNodeSupplier* CreateNodeSupplierL( const CNcdNodeIdentifier& aNodeIdentifier, 
       
   267                                            NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   268 
       
   269     /**
       
   270      * @see CNcdNodeFactory::CreateNodeSupplierL
       
   271      */
       
   272     CNcdNodeSupplier* CreateNodeSupplierLC( const CNcdNodeIdentifier& aNodeIdentifier,
       
   273                                             NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   274 
       
   275 
       
   276     /**
       
   277      *
       
   278      */
       
   279     CNcdNode* CreateNodeL( const CNcdNodeIdentifier& aParentIdentifier,
       
   280                            const CNcdNodeIdentifier& aMetaDataIdentifier, 
       
   281                            NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   282 
       
   283     /**
       
   284      * @see CNcdNodeFactory::CreateNodeL
       
   285      */
       
   286     CNcdNode* CreateNodeLC( const CNcdNodeIdentifier& aParentIdentifier,
       
   287                             const CNcdNodeIdentifier& aMetaDataIdentifier,
       
   288                             NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   289 
       
   290     /**
       
   291      *
       
   292      */
       
   293     CNcdNode* CreateNodeL( const CNcdNodeIdentifier& aNodeIdentifier, 
       
   294                            NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   295 
       
   296     /**
       
   297      * @see CNcdNodeFactory::CreateNodeL
       
   298      */
       
   299     CNcdNode* CreateNodeLC( const CNcdNodeIdentifier& aNodeIdentifier,
       
   300                             NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   301 
       
   302 
       
   303     /**
       
   304      *
       
   305      */
       
   306     CNcdNode* CreateNodeL( const CNcdNodeIdentifier& aNodeIdentifier,
       
   307                            RReadStream& aStream ) const;
       
   308 
       
   309     /**
       
   310      * @see CNcdNodeFactory::CreateNodeL
       
   311      */
       
   312     CNcdNode* CreateNodeLC( const CNcdNodeIdentifier& aNodeIdentifier,
       
   313                             RReadStream& aStream ) const;    
       
   314 
       
   315 
       
   316     /**
       
   317      *
       
   318      */
       
   319     CNcdNode* CreateNodeL( const CNcdNodeIdentifier& aNodeIdentifier,
       
   320                            const TDesC8& aData ) const;
       
   321 
       
   322     /**
       
   323      * @see CNcdNodeFactory::CreateNodeL
       
   324      */
       
   325     CNcdNode* CreateNodeLC( const CNcdNodeIdentifier& aNodeIdentifier,
       
   326                             const TDesC8& aData ) const;    
       
   327 
       
   328     /** 
       
   329      * Internalizes the given node from the given data.
       
   330      *
       
   331      * @param aNode The node.
       
   332      * @param aData The data.
       
   333      */
       
   334     void InternalizeNodeL( CNcdNode& aNode, const TDesC8& aData );
       
   335 
       
   336 public: // Functions to get metadata type info
       
   337 
       
   338     /**
       
   339      *
       
   340      */
       
   341     static TNcdNodeType MetaDataTypeL( const CNcdNodeMetaData& aMetaData );
       
   342 
       
   343     /**
       
   344      *
       
   345      */
       
   346     static TNcdNodeType MetaDataTypeL( NcdNodeClassIds::TNcdNodeClassId aClassId );
       
   347 
       
   348 
       
   349 public: // Functions to find out the metadata class id
       
   350 
       
   351     /**
       
   352      * This function gives the class id of a metadata that has given properties.
       
   353      * The class id can be used to create the node of the right type by
       
   354      * using the creation function of this class.
       
   355      *
       
   356      * @param aMetaType
       
   357      * @return NcdNodeClassIds::TNcdNodeClassId Class of the node that has
       
   358      * the given properties.
       
   359      */
       
   360     static NcdNodeClassIds::TNcdNodeClassId MetaDataClassId( CNcdNodeFactory::TNcdNodeType aMetaType );
       
   361 
       
   362 
       
   363 public: // Functions to create metadata objects
       
   364 
       
   365     /**
       
   366      *
       
   367      */
       
   368      CNcdNodeMetaData* CreateMetaDataL( const CNcdNodeIdentifier& aIdentifier,
       
   369                                         TNcdNodeType aMetaType ) const;
       
   370 
       
   371     /**
       
   372      * @see CNcdNodeFactory::CreateMetaDataL
       
   373      */
       
   374     CNcdNodeMetaData* CreateMetaDataLC( const CNcdNodeIdentifier& aIdentifier,
       
   375                                         TNcdNodeType aMetaType ) const;
       
   376 
       
   377 
       
   378     /**
       
   379      *
       
   380      */
       
   381     CNcdNodeItemMetaData* CreateItemMetaDataL( const CNcdNodeIdentifier& aIdentifier, 
       
   382                                                NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   383 
       
   384     /**
       
   385      * @see CNcdNodeFactory::CreateItemMetaDataItemL
       
   386      */
       
   387     CNcdNodeItemMetaData* CreateItemMetaDataLC( const CNcdNodeIdentifier& aIdentifier,
       
   388                                                 NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   389                                     
       
   390 
       
   391     /**
       
   392      *
       
   393      */
       
   394     CNcdNodeFolderMetaData* CreateFolderMetaDataL( const CNcdNodeIdentifier& aIdentifier, 
       
   395                                                    NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   396 
       
   397     /**
       
   398      * @see CNcdNodeFactory::CreateNodeFolderL
       
   399      */
       
   400     CNcdNodeFolderMetaData* CreateFolderMetaDataLC( const CNcdNodeIdentifier& aIdentifier,
       
   401                                                     NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   402 
       
   403     /**
       
   404      *
       
   405      */
       
   406     CNcdNodeMetaData* CreateMetaDataL( const CNcdNodeIdentifier& aIdentifier, 
       
   407                                        NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   408 
       
   409     /**
       
   410      * @see CNcdNodeFactory::CreateMetaData
       
   411      */
       
   412     CNcdNodeMetaData* CreateMetaDataLC( const CNcdNodeIdentifier& aIdentifier,
       
   413                                         NcdNodeClassIds::TNcdNodeClassId aClassId ) const;
       
   414 
       
   415 
       
   416     /**
       
   417      *
       
   418      */
       
   419     CNcdNodeMetaData* CreateMetaDataL( const CNcdNodeIdentifier& aIdentifier,
       
   420                                        RReadStream& aStream ) const;
       
   421 
       
   422     /**
       
   423      * @see CNcdNodeFactory::CreateMetaDataL
       
   424      */
       
   425     CNcdNodeMetaData* CreateMetaDataLC( const CNcdNodeIdentifier& aIdentifier,
       
   426                                         RReadStream& aStream ) const;    
       
   427 
       
   428 
       
   429     /**
       
   430      *
       
   431      */
       
   432     CNcdNodeMetaData* CreateMetaDataL( const CNcdNodeIdentifier& aIdentifier,
       
   433                                        const TDesC8& aData ) const;
       
   434 
       
   435     /**
       
   436      * @see CNcdNodeFactory::CreateMetaDataL
       
   437      */
       
   438     CNcdNodeMetaData* CreateMetaDataLC( const CNcdNodeIdentifier& aIdentifier,
       
   439                                         const TDesC8& aData ) const;    
       
   440 
       
   441 
       
   442 protected:
       
   443 
       
   444     /**
       
   445      * Constructor
       
   446      *
       
   447      * @param aNodeManager     
       
   448      */
       
   449     CNcdNodeFactory( CNcdNodeManager& aNodeManager );
       
   450 
       
   451     /**
       
   452      * ConstructL
       
   453      */
       
   454     virtual void ConstructL();
       
   455 
       
   456 
       
   457     /**
       
   458      * @return CNcdNodeManager& Manager that owns this cleaner
       
   459      */
       
   460     CNcdNodeManager& NodeManager() const;
       
   461 
       
   462 
       
   463 private:
       
   464 
       
   465     // Prevent these two if they are not implemented
       
   466     CNcdNodeFactory( const CNcdNodeFactory& aObject );
       
   467     CNcdNodeFactory& operator =( const CNcdNodeFactory& aObject );
       
   468 
       
   469 
       
   470 private: // data
       
   471     
       
   472     // NodeManager that owns this factory
       
   473     CNcdNodeManager& iNodeManager;
       
   474     
       
   475     };
       
   476     
       
   477 #endif // NCD_NODE_FACTORY_H