ncdengine/provider/server/inc/ncdnodeidentifiereditor.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     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 NcdNodeIdentifierEditor namespace
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NCD_NODE_IDENTIFIER_EDITOR_H
       
    20 #define NCD_NODE_IDENTIFIER_EDITOR_H
       
    21 
       
    22 
       
    23 #include <e32std.h>
       
    24 
       
    25 class CNcdNodeIdentifier;
       
    26 
       
    27 
       
    28 /**
       
    29  *  This class object should be used to create node and metadata
       
    30  *  identifiers instead of directly creating them in different places
       
    31  *  of code.
       
    32  */
       
    33 namespace NcdNodeIdentifierEditor
       
    34     {
       
    35     
       
    36     // Functions to create correct node identifiers
       
    37 
       
    38     /**
       
    39      * @param aParentIdentifier
       
    40      * @param aMetaDataIdentifier
       
    41      * @return CNcdNodeIdentifier* The identifier that has been created by using the
       
    42      * parent id and the metadata id. Ownership is transferred.
       
    43      */
       
    44     CNcdNodeIdentifier* CreateNodeIdentifierLC( const CNcdNodeIdentifier& aParentIdentifier,
       
    45                                                 const CNcdNodeIdentifier& aMetaDataIdentifier );
       
    46 
       
    47     void MarkMetaDataPartL( TLex& aMetaId );
       
    48     
       
    49     /**
       
    50      * Gets parent id and namespace from child's id.
       
    51      * If there is no parent the values will be set to KNullDesC.
       
    52      *
       
    53      * @param aChildId Child's id.
       
    54      * @param aParentId Will contain parent's id upon return.
       
    55      * @param aParentId Will contain parent's namespace upon return.
       
    56      */
       
    57     void GetParentIdAndNsL( const TDesC& aChildId, TPtrC& aParentId, TPtrC& aParentNs );
       
    58     
       
    59     /**
       
    60      * @see CNcdNodeIdentifierEditor::CreateMetaIdentifierLC
       
    61      */
       
    62     CNcdNodeIdentifier* CreateMetaDataIdentifierL( const CNcdNodeIdentifier& aNodeIdentifier );
       
    63 
       
    64     /**
       
    65      * @param aNodeIdentifier The identifier that identifies the node. (Contains parent info in id).
       
    66      * @return CNcdNodeIdentifier* Identifier of the metadata of the given node.
       
    67      */
       
    68     CNcdNodeIdentifier* CreateMetaDataIdentifierLC( const CNcdNodeIdentifier& aNodeIdentifier );
       
    69     
       
    70     /**
       
    71      * 
       
    72      */
       
    73     TBool DoesMetaDataIdentifierMatchL( const CNcdNodeIdentifier& aNodeIdentifier,
       
    74         const TDesC& aMetaId, const TDesC& aMetaNameSpace, const TUid& aMetaUid );
       
    75 
       
    76     TBool DoesMetaDataIdentifierMatchL( const CNcdNodeIdentifier& aMetaDataIdentifier,
       
    77         const CNcdNodeIdentifier& aNodeIdentifier );
       
    78 
       
    79     /**
       
    80      * All the root identifiers have the same namespace but the client id
       
    81      * is used also as the id.
       
    82      *
       
    83      * @param aUid Uid of the client whose root identifier is asked.
       
    84      * @return CNcdNodeIdentifier* Identifier of the root node of a given client.
       
    85      */
       
    86     CNcdNodeIdentifier* CreateRootIdentifierForClientLC( const TUid& aUid );
       
    87 
       
    88     /**
       
    89      * All the search root identifiers have the same namespace but the client id
       
    90      * is used also as the id.
       
    91      *
       
    92      * @param aUid Uid of the client whose search root identifier is asked.
       
    93      * @return CNcdNodeIdentifier* Identifier of the search root node of a given client.
       
    94      */
       
    95     CNcdNodeIdentifier* CreateSearchRootIdentifierForClientLC( const TUid& aUid );
       
    96 
       
    97     /**
       
    98      * This function creates the identifier for the temporary node. Temporary nodes are not child
       
    99      * of any other node. So, they will be left hanging themselves.
       
   100      *
       
   101      * @param aMetaDataIdentifier Identifies the metadata that this temporary node will contain.
       
   102      * @return CNcdNodeIdentifier* Identifies the temporary node.
       
   103      */ 
       
   104     CNcdNodeIdentifier* CreateTemporaryNodeIdentifierLC( const CNcdNodeIdentifier& aMetaDataIdentifier );    
       
   105 
       
   106 
       
   107     // Functions that can provide information that is included to the identifiers
       
   108 
       
   109     /**
       
   110      * This function returns the depth of the node in the node hierarchy.
       
   111      * 
       
   112      * @note Namespaces are omitted in the node id. So, only the metadata id parts are
       
   113      * counted for the depth. Depth is zero if only one metadata id is included to the node id.
       
   114      *
       
   115      * @param aNodeIdentifier Identifier of the node. The node id contains also
       
   116      * parent names. So, the depth can be calculated from id descriptor.
       
   117      * @return TInt The depth of the node. The root level is zero.
       
   118      */
       
   119     TInt NodeDepthL( const CNcdNodeIdentifier& aNodeIdentifier );
       
   120 
       
   121     /**
       
   122      * This function checks if the given identifier identifies
       
   123      * some root. The namespace information of the identifier
       
   124      * is used to check this. So, this function can be used
       
   125      * for both metadata and nodes. There may be multiple 
       
   126      * namespaces that identify different roots. For example, 
       
   127      * normal node root or search root etc.
       
   128      * 
       
   129      * @param aIdentifier Identifier that is used to check
       
   130      * if it identifies root some root. 
       
   131      * @return TBool ETrue if identifier identifies root. Else
       
   132      * EFalse.
       
   133      */
       
   134     TBool IdentifiesSomeRoot( const CNcdNodeIdentifier& aIdentifier );
       
   135 
       
   136     /**
       
   137      * This function check if the given identifier identifies
       
   138      * some temporary node, which does not belong under some root
       
   139      * node. In other words, the node just hangs by itself.
       
   140      *
       
   141      * @param aIdentifier The identifier of the node that is checked.
       
   142      * @return TBool ETrue if the node is temporary node. Else EFalse.
       
   143      */
       
   144     TBool IdentifiesTemporaryNodeL( const CNcdNodeIdentifier& aIdentifier );
       
   145 
       
   146     /**
       
   147      * @param aParentNodeIdentifier A supposed parent
       
   148      * @param aChildNodeIdentifier A supposed child or grand child etc. of parent
       
   149      * @return TBool ETrue if the child is the child or grand child etc. of the 
       
   150      * given parent. Else EFalse.
       
   151      */
       
   152     TBool ParentOf( const CNcdNodeIdentifier& aParentNodeIdentifier,
       
   153                     const CNcdNodeIdentifier& aChildNodeIdentifier );    
       
   154 
       
   155 
       
   156     /**
       
   157      * This function parses the child identifier and creates the parent information
       
   158      * from the child identifier.
       
   159      * @param aChildNodeIdentifier A supposed child or grand child etc. of parent
       
   160      * @return CNodeIdentifier* The identifier of the parent of the node that is identified
       
   161      * by the aChildNodeIdentifier.
       
   162      * @exception Leaves with KErrArgument if aChildNodeIdentifier contains empty fields
       
   163      * or if no parent can be deducted from the id (e.g. root node's identifier).
       
   164      */    
       
   165     CNcdNodeIdentifier* ParentOfLC( const CNcdNodeIdentifier& aChildNodeIdentifier );    
       
   166 
       
   167     /**
       
   168      * This function checks if the given identifier identifies
       
   169      * some search node.
       
   170      *
       
   171      * @param aIdentifier The identifier of the node that is checked.
       
   172      * @return TBool ETrue if the node is a search node. Else EFalse.
       
   173      */
       
   174     TBool IdentifiesSearchNodeL( const CNcdNodeIdentifier& aIdentifier );
       
   175 
       
   176     }
       
   177 
       
   178 #endif // NCD_NODE_IDENTIFIER_EDITOR_H