commsfwtools/preparedefaultcommsdatabase/src/MetaDatabaseVisitor.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 /**
       
     2 * Copyright (c) 2004-2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file MetaDatabaseVisitor.h
       
    22  @internalComponent
       
    23 */
       
    24  
       
    25 #if (!defined METADATABASEVISITOR_H)
       
    26 #define       METADATABASEVISITOR_H
       
    27 
       
    28 
       
    29 namespace CommsDat
       
    30 /*
       
    31 Namespace encapsulates all types that are able to perform MMetaDatabase actions on specific record data types
       
    32 */
       
    33     {
       
    34 
       
    35 using namespace CommsDatInternal;
       
    36 using namespace Meta;
       
    37 
       
    38 
       
    39 
       
    40 NONSHARABLE_CLASS(TMDBVisitorBase) : public Meta::MMetaType
       
    41 /**
       
    42 A general database visitor 
       
    43 @internalComponent
       
    44 */
       
    45     {  
       
    46 public:
       
    47 
       
    48     virtual ~TMDBVisitorBase();
       
    49 
       
    50     ////////// From Meta::MMetaType /////////////////////////////////////////
       
    51        TInt Load(TPtrC8& aBuffer){ aBuffer == aBuffer; return 0; }
       
    52        TInt Store(TDes8& aBuffer) const{aBuffer == aBuffer; return 0; }
       
    53        void Copy(const TAny* aData)  {aData = aData;}
       
    54        TInt Length() const {return 0;}
       
    55    	///////////////////////////////////////////////////////////////////
       
    56     
       
    57     // GET
       
    58     virtual TInt LoadL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags) = 0; 
       
    59     virtual TInt LoadL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags, RArray<TUint32>& aIds) = 0;
       
    60     virtual TInt FindL(CMDBSessionImpl* aSession, RArray<TUint32>& aIds) = 0;
       
    61     virtual TInt RefreshL(CMDBSessionImpl* aSession) = 0;
       
    62 	virtual TInt GetL(CMDBSessionImpl* aSession);
       
    63    
       
    64     // SET
       
    65     virtual TInt StoreL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags) = 0;
       
    66     virtual TInt ModifyL(CMDBSessionImpl* aSession, TMDBAttributeFlags aAttributeFlags) = 0;
       
    67  
       
    68     virtual void SetOwner(CMDBElement* aOwner);
       
    69     virtual TInt Changed() const = 0;  
       
    70     virtual void Sync();
       
    71     virtual void ClearValue(){}
       
    72 
       
    73 public:
       
    74     
       
    75     // These do not need to be specialised in inheriting templates
       
    76     void Change();
       
    77     void FieldLoaded();
       
    78     TBool IsFieldLoaded();
       
    79     void SetFieldNull();
       
    80     
       
    81 	TUint32 TypeId();
       
    82     TUint32 ElementId();
       
    83     void SetElementId(TMDBElementId* aId);
       
    84     void SetElementId(TMDBElementId aId);
       
    85        
       
    86     void SetMaxLength(TInt aLength);
       
    87 
       
    88     /* Removes all of the flags from the elementId of the DBVisitor - use only if the given record
       
    89      * which needs to be loaded is NOT a template record!! Doesn't have to be virtual.
       
    90      */
       
    91     void ResetElementId(TInt aRecId);
       
    92     
       
    93 protected:
       
    94 
       
    95     TMDBVisitorBase(TMDBElementId *aElementId);
       
    96     TMDBVisitorBase();
       
    97     
       
    98     void FindRecordsUsingTemplateL(CMDBSessionImpl* aSession, RArray<TUint32>& aRecordIds, RArray<TUint32>& aCandidateIds);
       
    99 
       
   100     TInt            iMaxLength;  
       
   101     CMDBElement*    iOwner; 
       
   102     
       
   103     TMDBElementId*  iElementId;
       
   104     };
       
   105 
       
   106 
       
   107 
       
   108 
       
   109 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
   110 // TMDBVisitor
       
   111 // 
       
   112 /**
       
   113 Generic visitor for any simple MetaDatabase element.
       
   114 Class is specialised to act on fields of type TMDBMetaField<T>
       
   115 where T is 
       
   116     TInt    - (for any number - reals not used in comms database)
       
   117     HBufC   - for any string
       
   118     HBufC8  - for binary data
       
   119 */
       
   120 
       
   121 
       
   122 /*Simple encapsulation of a metadatabase element for use by visitors
       
   123 @internalComponent
       
   124 */
       
   125 template<class TYPE> 
       
   126 struct SMDBMetaElement 
       
   127     {
       
   128     TMDBElementId   iElementId;
       
   129     TYPE            iValue;
       
   130     };
       
   131 
       
   132 /*
       
   133 Implementation of MMetaDBVisitor for a general type 
       
   134 @internalComponent
       
   135 */
       
   136 
       
   137 
       
   138 template <class TYPE> 
       
   139 class TMDBVisitor : public TMDBVisitorBase
       
   140 /**
       
   141 Implementation of MMetaDBVisitor for a general element type 
       
   142 @internalComponent
       
   143 */
       
   144     {    
       
   145 public:
       
   146 
       
   147     inline static TMDBVisitor<TYPE>* NewL(const TAny* aMem, const TAny* aData);
       
   148     inline static TMDBVisitor<TYPE>* CreateL(const TAny* aMem, const TAny* aData);
       
   149 
       
   150     // GET
       
   151     TInt LoadL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags); 
       
   152     TInt LoadL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags, RArray<TUint32>& aIds);
       
   153     TInt FindL(CMDBSessionImpl* aSession, RArray<TUint32>& aIds);
       
   154     TInt RefreshL(CMDBSessionImpl* aSession);
       
   155 	TInt GetL(CMDBSessionImpl* aSession);
       
   156    
       
   157     // SET
       
   158     TInt StoreL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags);
       
   159     TInt ModifyL(CMDBSessionImpl* aSession, TMDBAttributeFlags aAttributeFlags);  
       
   160     
       
   161 	TInt Changed() const;
       
   162     //void SetOwner(CMDBElement* aOwner);
       
   163     void ClearValue();
       
   164 
       
   165 public:
       
   166     
       
   167     SMDBMetaElement<TYPE>* iTarget;
       
   168     
       
   169 protected:
       
   170 
       
   171     TMDBVisitor(SMDBMetaElement<TYPE>* aData);
       
   172     };
       
   173 
       
   174 
       
   175 
       
   176 template <class TYPE> 
       
   177 inline TMDBVisitor<TYPE>::TMDBVisitor(SMDBMetaElement<TYPE>* aData)
       
   178 : TMDBVisitorBase(&(aData->iElementId)), iTarget(aData)
       
   179 /**
       
   180  * Constructor
       
   181  */
       
   182     {
       
   183     }
       
   184 
       
   185 
       
   186 
       
   187 template<class TYPE> 
       
   188 inline TMDBVisitor<TYPE>* TMDBVisitor<TYPE>::NewL(const TAny* aMem, const TAny* aData)
       
   189 /**
       
   190  * Instantiates a Visitor of a particular type.
       
   191  * Used for attribute registration (in the data v-table).
       
   192  */
       
   193     {
       
   194     return static_cast<TMDBVisitor<TYPE>*>( ::new ((TUint8*)aMem) TMDBVisitor( (SMDBMetaElement<TYPE>*)(aData) ) );
       
   195     }
       
   196 
       
   197 template<class TYPE> 
       
   198 inline TMDBVisitor<TYPE>* TMDBVisitor<TYPE>::CreateL(const TAny* aMem, const TAny* aData)
       
   199 /**
       
   200  * Instantiates a Visitor of a particular type.
       
   201  * Used for attribute registration (in the data v-table).
       
   202  */
       
   203     {
       
   204     return static_cast<TMDBVisitor<TYPE>*>( ::new ((TUint8*)aMem) TMDBVisitor( (SMDBMetaElement<TYPE>*)(((CMDBElement*)aData)->Data()) ) );
       
   205     }
       
   206 
       
   207 
       
   208 template <class TYPE> 
       
   209 inline TInt TMDBVisitor<TYPE>::Changed() const
       
   210 /*
       
   211 Has the value been changed by the caller?
       
   212 
       
   213 @internalComponent
       
   214 */  { 
       
   215     if (iElementId)
       
   216         {
       
   217         return ( *iElementId & KCDChangedFlag );
       
   218     	}
       
   219     return 0;
       
   220     } 
       
   221 
       
   222 
       
   223 template<class TYPE>
       
   224 inline void TMDBVisitor<TYPE>::ClearValue() 
       
   225     {
       
   226     if (iTarget)
       
   227         {
       
   228         iTarget->iValue = 0;
       
   229         SetFieldNull();
       
   230         }
       
   231     }
       
   232 
       
   233 
       
   234 template<>
       
   235 inline void TMDBVisitor<HBufC16*>::ClearValue() 
       
   236     {
       
   237     if (iTarget)
       
   238         {
       
   239         delete iTarget->iValue;
       
   240         iTarget->iValue = 0;
       
   241         SetFieldNull();
       
   242         }
       
   243     }
       
   244 
       
   245 
       
   246 template<>
       
   247 inline void TMDBVisitor<HBufC8*>::ClearValue() 
       
   248     {
       
   249     if (iTarget)
       
   250         { 
       
   251         delete iTarget->iValue;
       
   252         iTarget->iValue = 0;
       
   253         SetFieldNull();
       
   254         }
       
   255     }
       
   256 
       
   257 
       
   258 template<class TYPE> 
       
   259 inline TInt TMDBVisitor<TYPE>::RefreshL(CMDBSessionImpl* aSession) 
       
   260 	{
       
   261 	return LoadL(aSession,*iElementId,*iElementId);
       
   262 	}
       
   263 
       
   264 
       
   265 template<class TYPE> 
       
   266 inline TInt TMDBVisitor<TYPE>::GetL(CMDBSessionImpl* aSession) 
       
   267 /*
       
   268 Assumes fully resolved element Id but still needs mask for reserved bits
       
   269 
       
   270 @internalComponent
       
   271 */
       
   272     {
       
   273     if (! iTarget )
       
   274         {
       
   275         User::Leave(KErrNotReady);
       
   276         }
       
   277 
       
   278     TUint32 id = ElementId() & ~KCDMaskShowRes;
       
   279 
       
   280     TInt err = aSession->StorageL()->Get(id, iTarget->iValue);
       
   281      
       
   282     if(err == KErrNone)
       
   283 		{
       
   284 		FieldLoaded(); // value has been retrieved
       
   285 		}
       
   286     else 
       
   287         {
       
   288         Sync(); // indicates the field is still null.  
       
   289         
       
   290         if (err != KErrNotFound && err != KErrPermissionDenied)
       
   291             {
       
   292             __FLOG_STATIC2(KLogComponent, KCDErrLog, _L("TMDBVisitor<TYPE> GetL() storage server Get returned err = %d for id %08x"), err, id);
       
   293             User::Leave(err);
       
   294             }
       
   295         }
       
   296 	return err;
       
   297     }
       
   298 
       
   299 
       
   300 
       
   301 template<> 
       
   302 inline TInt TMDBVisitor<HBufC16*>::GetL(CMDBSessionImpl* aSession) 
       
   303 /*
       
   304 Specialisation for HBufC16 
       
   305 Assumes fully resolved element Id but still needs mask for reserved bits
       
   306 
       
   307 @internalComponent
       
   308 */
       
   309 	{
       
   310 	if (! iTarget )
       
   311         {
       
   312         User::Leave(KErrNotReady);
       
   313         }
       
   314 
       
   315     if( ! iTarget->iValue  || 
       
   316 		iTarget->iValue->Length() < iMaxLength)
       
   317 		{
       
   318 		delete iTarget->iValue;
       
   319         iTarget->iValue = NULL;
       
   320 		iTarget->iValue = HBufC16::NewMaxL(iMaxLength);
       
   321 		}
       
   322 
       
   323 	TPtr16 ptr = iTarget->iValue->Des();
       
   324 	TUint32 id = ElementId() & KCDMaskHideRes;
       
   325 
       
   326     TInt err = aSession->StorageL()->Get(id, ptr);   
       
   327     
       
   328     if(err == KErrNone)
       
   329 		{
       
   330 		FieldLoaded(); // value has been loaded
       
   331 
       
   332 		HBufC16* temp = iTarget->iValue;
       
   333 		iTarget->iValue = HBufC16::NewMaxL(ptr.Length());
       
   334 		TPtr16 ptrNew = iTarget->iValue->Des();;
       
   335 		ptrNew = ptr;
       
   336 		delete temp;
       
   337 		}
       
   338     else 
       
   339         {
       
   340         delete iTarget->iValue;
       
   341         iTarget->iValue = NULL;
       
   342         
       
   343         Sync(); // indicates the field is null.  
       
   344 
       
   345         if (err != KErrNotFound  &&  err != KErrPermissionDenied)
       
   346             {
       
   347             __FLOG_STATIC2(KLogComponent, KCDErrLog, _L("TMDBVisitor<HBufC16*> GetL() storage server Get returned err = %d for id %08x"), err, id);
       
   348             User::Leave(err);
       
   349             }
       
   350         }
       
   351 		
       
   352     return err;
       
   353 	}
       
   354 
       
   355 
       
   356 
       
   357 template<> 
       
   358 inline TInt TMDBVisitor<HBufC8*>::GetL(CMDBSessionImpl* aSession) 
       
   359 /*
       
   360 Specialisation for HBufC8*
       
   361 Assumes fully resolved element Id but still needs mask for reserved bits
       
   362 
       
   363 @internalTechnology
       
   364 */
       
   365     {
       
   366     if (! iTarget )
       
   367         {
       
   368         User::Leave(KErrNotReady);
       
   369         }
       
   370 
       
   371     if (! iTarget->iValue || 
       
   372 		iTarget->iValue->Length() < iMaxLength)
       
   373 		{
       
   374 		delete iTarget->iValue;
       
   375 		iTarget->iValue = NULL;
       
   376 		iTarget->iValue = HBufC8::NewMaxL(iMaxLength);
       
   377 		}
       
   378 	
       
   379 	TPtr8 ptr = iTarget->iValue->Des();
       
   380     TUint32 id = ElementId() & KCDMaskHideRes;
       
   381 
       
   382 	TInt err = aSession->StorageL()->Get(id, ptr);    
       
   383      
       
   384     if(err == KErrNone)
       
   385 		{
       
   386 		FieldLoaded();// Value was retrieved
       
   387 
       
   388         /*
       
   389 		HBufC8* temp = iTarget->iValue;
       
   390 		iTarget->iValue = HBufC8::NewMaxL(ptr.Length());
       
   391 		TPtr8 ptrNew = iTarget->iValue->Des();;
       
   392 		ptrNew = ptr;
       
   393 		delete temp;
       
   394         */
       
   395 		}
       
   396     else 
       
   397         {
       
   398         delete iTarget->iValue;
       
   399         iTarget->iValue = NULL;
       
   400         
       
   401         Sync(); // indicates the field is null.  
       
   402 
       
   403         if (err != KErrNotFound && err != KErrPermissionDenied)
       
   404             {
       
   405             __FLOG_STATIC2(KLogComponent, KCDErrLog, _L("TMDBVisitor<HBufC8*> GetL() storage server Get returned err = %d for id %08x"), err, id);
       
   406             User::Leave(err);
       
   407             }
       
   408         }
       
   409 		
       
   410 	return err;
       
   411     }
       
   412 
       
   413 
       
   414 
       
   415 template<class TYPE> 
       
   416 inline TInt TMDBVisitor<TYPE>::LoadL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags /*aAttributeFlags*/) 
       
   417 /*
       
   418 Assumes type and record id set by caller
       
   419 
       
   420 @internalComponent
       
   421 */
       
   422     {
       
   423     if (! iTarget)
       
   424         {
       
   425         User::Leave(KErrNotReady);
       
   426         }
       
   427 
       
   428     // set the element id to the full id set by the caller
       
   429     iTarget->iElementId = (iTarget->iElementId & (KCDMaskShowType | KCDMaskShowRes)) | (aRecordId & KCDMaskShowRecordId);  
       
   430 
       
   431     RArray<TUint32> ids;
       
   432 	CleanupClosePushL(ids);
       
   433 
       
   434 	TUint32 mask = KCDMaskShowType | KCDMaskShowRecordId | aSession->GetReadAttributeMask();
       
   435 
       
   436 	TUint32 id = ElementId() & KCDMaskHideAttrAndRes;
       
   437 
       
   438     TInt err = (aSession->StorageL())->FindL(id, mask, ids);  
       
   439      
       
   440     if ( err != KErrNone  &&  err != KErrNotFound )
       
   441         {
       
   442         __FLOG_STATIC3(KLogComponent, KCDErrLog, _L("TMDBVisitor<TYPE> LoadL() storage server FindL returned err = %d when looking for %08x, masked with %08x"), err, id, mask);
       
   443         }
       
   444 #ifdef __DEBUG    
       
   445     else if ( ids.Count() > 1 )
       
   446         {
       
   447         __FLOG_STATIC2(KLogComponent, KCDErrLog, _L("TMDBVisitor<TYPE> LoadL() storage server FindL/FindEqL %d fields found for %08x.  Should be 1 or 0."), aIds.Count(), id & mask);
       
   448         }
       
   449 #endif
       
   450   
       
   451     // Load the field data
       
   452     if (err == KErrNone)
       
   453         {
       
   454 	    // Set the full id 
       
   455 		iTarget->iElementId = ids[0];
       
   456 		err = GetL(aSession); 		
       
   457         }
       
   458 
       
   459 	CleanupStack::PopAndDestroy(&ids);
       
   460     if ( err == KErrNotFound )
       
   461         {
       
   462         // it's ok not to find a field.  
       
   463         // Don't report that error back.
       
   464        // VCT - experimenting without this err = KErrNone;
       
   465         }
       
   466 
       
   467 	return err;
       
   468     }
       
   469 
       
   470 
       
   471 
       
   472 template<class TYPE> 
       
   473 inline TInt TMDBVisitor<TYPE>::LoadL(CMDBSessionImpl* aSession, TMDBElementId /*aRecordId*/, TMDBAttributeFlags /*aAttributeFlags*/,RArray<TUint32>& aIds ) 
       
   474 /*
       
   475 Assumes type and record id set by caller
       
   476 
       
   477 @internalComponent
       
   478 */
       
   479     {
       
   480     if (aIds.Count() == 0)
       
   481         {
       
   482         User::Leave(KErrNotFound);
       
   483         }
       
   484 
       
   485     return LoadL(aSession, aIds[0] & KCDMaskShowRecordId, aIds[0] & KCDMaskShowAttributes);
       
   486     }
       
   487 
       
   488 
       
   489 
       
   490 template <class TYPE> 
       
   491 inline TInt TMDBVisitor<TYPE>::FindL(CMDBSessionImpl* aSession, RArray<TUint32>& aIds) 
       
   492 /*
       
   493 Only find dont actually load
       
   494 Assumes fully resolved element Id but still needs mask for reserved bits
       
   495 
       
   496 @internalComponent
       
   497 */
       
   498     {
       
   499     if (! iTarget )
       
   500         {
       
   501         User::Leave(KErrNotReady);
       
   502         }
       
   503 
       
   504     TInt err(KErrNotFound);
       
   505 
       
   506     // want to find this field in any record of this type that has appropriate attributes
       
   507     // so mask out recordid, reserved bits and any attributes that need not be observed.
       
   508     // TUint32 mask = KCDMaskShowType | (~aAttributeFlags & KCDMaskShowAttributes);
       
   509     TUint32 mask = KCDMaskShowType | aSession->GetReadAttributeMask();
       
   510     
       
   511     if (Changed())
       
   512         {
       
   513         err = aSession->StorageL()->FindEqL(ElementId() & ~aSession->GetReadAttributeMask(), mask, iTarget->iValue, aIds);
       
   514     
       
   515         RArray<TUint32> ids;
       
   516         CleanupClosePushL(ids);
       
   517         
       
   518         mask = (mask & ~ECDHidden) | KCDMaskShowRecordId;
       
   519 
       
   520         // Now look in template record to find other records
       
   521         err = aSession->StorageL()->FindEqL(ElementId() & ~KCDMaskShowRecordId, mask, iTarget->iValue, ids);
       
   522                 
       
   523         if ( err == KErrNone )
       
   524             {
       
   525             FindRecordsUsingTemplateL(aSession, ids, aIds);
       
   526             }
       
   527 
       
   528         if ( aIds.Count() )
       
   529             {
       
   530             err = KErrNone;
       
   531             }
       
   532     
       
   533         CleanupStack::PopAndDestroy(&ids);
       
   534     }
       
   535     else
       
   536         {  
       
   537         err = aSession->StorageL()->FindL(ElementId() & ~aSession->GetReadAttributeMask(), mask, aIds);  
       
   538         }
       
   539 
       
   540     if ( aIds.Count() == 0)
       
   541         {
       
   542         __FLOG_STATIC3(KLogComponent, KCDErrLog, _L("TMDBVisitor<TYPE> FindL() storage server FindL returned err = %d when looking for %08x, masked with %08x"), err, ElementId(), mask);
       
   543         if (err == KErrNone || err == KErrNotFound)
       
   544             {
       
   545             __FLOG_STATIC2(KLogComponent, KCDInfoLog, _L("TMDBVisitor<TYPE> FindL() storage server FindL() did not find <%08x> masked with <%08x>"), ElementId(), mask);
       
   546             err = KErrNotFound;
       
   547             }
       
   548         else
       
   549             {
       
   550             __FLOG_STATIC3(KLogComponent, KCDErrLog, _L("TMDBVisitor<TYPE> FindL() storage server FindL returned err = %d when looking for <%08x>, masked with <%08x>"), err, ElementId(), mask);
       
   551             }
       
   552         }
       
   553 #ifdef __DEBUG
       
   554     else if ( aIds->Count() > 1)
       
   555         {
       
   556         __FLOG_STATIC2(KLogComponent, KCDErrLog, _L("TMDBVisitor<TYPE> FindL() storage server FindL/FindEqL %d fields found for id %08x.  Should be 1 or 0."), aIds.Count(), id & mask);
       
   557         }
       
   558 #endif
       
   559 
       
   560     return err;
       
   561     }
       
   562 
       
   563 
       
   564 
       
   565 template <> 
       
   566 inline TInt TMDBVisitor<HBufC16*>::FindL(CMDBSessionImpl* aSession, RArray<TUint32>& aIds) 
       
   567 /*
       
   568 Only find dont actually load
       
   569 Assumes fully resolved element Id but still needs mask for reserved bits
       
   570 
       
   571 @internalComponent
       
   572 */
       
   573     {
       
   574     if (! iTarget || ! iTarget->iValue )
       
   575         {
       
   576         User::Leave(KErrNotReady);
       
   577         }
       
   578     
       
   579     // want to find this field in any record of this type that has appropriate attributes
       
   580     // so mask out recordid, reserved bits and any attributes that need not be observed.
       
   581     // TUint32 mask = KCDMaskShowType | (~aAttributeFlags & KCDMaskShowAttributes);
       
   582     TUint32 mask = KCDMaskShowType | aSession->GetReadAttributeMask();
       
   583     
       
   584     TInt err(KErrNotFound);
       
   585 
       
   586     if (Changed())
       
   587         {
       
   588         const TDesC16& val = *iTarget->iValue;
       
   589         // An absent text field is treated as being synonymous with one that is present but blank, ie
       
   590         // searching for an empty descriptor matches both actual blanks and fields that aren't found. Because
       
   591         // CenRep doesn't support such a thing we're forced to get handle this case by brute force: get the set
       
   592         // of all record ids, fetch the desired field for each, and remove those records where the field is present
       
   593         // and non blank.
       
   594        	if(val.Length() == 0)
       
   595        		{
       
   596        		// Get the set of all recordIds
       
   597 			TUint32 maskId = KCDMaskHideAttrAndRes & ~KCDColumnTypeInfo;
       
   598 
       
   599 			TUint32 tableId = ElementId() | KCDMaskShowColumnTypeAndRecordId;
       
   600 
       
   601 			err = (aSession->StorageL())->FindL(tableId, maskId, aIds);  
       
   602 			 
       
   603 			// remove node (side effect from query)
       
   604 			for (TInt idx = aIds.Count() - 1; idx >= 0; -- idx)
       
   605 				{
       
   606 				if( (aIds[idx] & ~KCDMaskShowAttrAndRes) == (tableId & ~KCDMaskShowAttrAndRes) )
       
   607 					{
       
   608 					aIds.Remove(idx);
       
   609 					}
       
   610 				}
       
   611 
       
   612 			if ( err != KErrNone  &&  err != KErrNotFound )
       
   613 				{
       
   614 				__FLOG_STATIC3(KLogComponent, KCDErrLog, _L("TMDBVisitor<HBufC16*> FindL() storage server FindL returned err = %d when looking for <%08x>, masked with <%08x>"), err, tableId, mask);
       
   615 				}
       
   616 			else
       
   617 				{
       
   618 				// Fetch the desired field for each record
       
   619 				RArray<TUint32> fieldIds;
       
   620 				CleanupClosePushL(fieldIds);
       
   621 
       
   622 				TUint32 fieldId = (ElementId() & ~KCDMaskShowRecordId);
       
   623 				maskId = KCDMaskShowType | aSession->GetReadAttributeMask();
       
   624 				
       
   625 				TInt errFieldSearch = aSession->StorageL()->FindL(fieldId, maskId, fieldIds);
       
   626 				if(errFieldSearch == KErrNone)
       
   627 					{
       
   628 					for(TInt fieldIdx = fieldIds.Count() - 1; fieldIdx >= 0; --fieldIdx)
       
   629 						{
       
   630 						for (TInt idx = aIds.Count() - 1; idx >= 0; -- idx)
       
   631 							{
       
   632 							// Remove those records where the field is present and non blank
       
   633 							if( (fieldIds[fieldIdx] & KCDMaskShowRecordId) == (aIds[idx] & KCDMaskShowRecordId ))
       
   634 								{
       
   635 								aIds.Remove(idx);
       
   636 								}
       
   637 							}
       
   638 						}
       
   639 					}
       
   640 
       
   641 				CleanupStack::PopAndDestroy(&fieldIds);
       
   642 				}
       
   643        		}
       
   644        	else
       
   645        		{
       
   646        		if((ElementId() & KCDMaskHideRes) == KCDMaskGenericTableName)
       
   647        			{
       
   648        			mask = KCDMaskGenericTableName;	
       
   649        			}
       
   650        	
       
   651 	        err = aSession->StorageL()->FindEqL(ElementId() & ~aSession->GetReadAttributeMask(), mask, val, aIds);
       
   652 
       
   653             RArray<TUint32> ids;
       
   654             CleanupClosePushL(ids);
       
   655         
       
   656             mask = (mask & ~ECDHidden) | KCDMaskShowRecordId;
       
   657 
       
   658             // Now look in template record
       
   659             err = aSession->StorageL()->FindEqL(ElementId() & ~KCDMaskShowRecordId, mask, val, ids);
       
   660         
       
   661             if ( err == KErrNone )
       
   662                 {
       
   663                 FindRecordsUsingTemplateL(aSession, ids, aIds);
       
   664                 }
       
   665 
       
   666             if ( aIds.Count() )
       
   667                 {
       
   668                 err = KErrNone;
       
   669                 }
       
   670 
       
   671             CleanupStack::PopAndDestroy(&ids);     
       
   672             }
       
   673         }
       
   674     else
       
   675         {  
       
   676         err = aSession->StorageL()->FindL(ElementId() & ~aSession->GetReadAttributeMask(), mask, aIds);  
       
   677         }
       
   678     
       
   679     if ( aIds.Count() == 0)
       
   680         {
       
   681         __FLOG_STATIC3(KLogComponent, KCDErrLog, _L("TMDBVisitor<HBufC16*> FindL() storage server FindL returned err = %d when looking for %08x, masked with %08x"), err, ElementId(), mask);
       
   682         if (err == KErrNone || err == KErrNotFound)
       
   683             {
       
   684             __FLOG_STATIC2(KLogComponent, KCDInfoLog, _L("TMDBVisitor<HBufC16*> FindL() storage server FindL() did not find <%08x> masked with %08x"), ElementId(), mask);
       
   685             err = KErrNotFound;
       
   686             }
       
   687         else
       
   688             {
       
   689             __FLOG_STATIC3(KLogComponent, KCDErrLog, _L("TMDBVisitor<HBufC16*> FindL() storage server FindL() returned err = %d when looking for <%08x>, masked with <%08x>"), err, ElementId(), mask);
       
   690             }
       
   691         }       
       
   692 #ifdef __DEBUG
       
   693     else if ( aIds->Count() > 1)
       
   694         {
       
   695         __FLOG_STATIC2(KLogComponent, KCDErrLog, _L("TMDBVisitor<HBufC16*> FindL() storage server FindL/FindEqL %d fields found for id.  Should be 1 or 0."), aIds.Count(), ElementId() & mask);
       
   696         }
       
   697 #endif
       
   698  
       
   699     return err;
       
   700     }
       
   701 
       
   702 
       
   703 
       
   704 template <> 
       
   705 inline TInt TMDBVisitor<HBufC8*>::FindL(CMDBSessionImpl* aSession, RArray<TUint32>& aIds) 
       
   706 /*
       
   707 Only find dont actually load
       
   708 Assumes fully resolved element Id but still needs mask for reserved bits
       
   709 
       
   710 @internalComponent
       
   711 */
       
   712     {
       
   713     if (! iTarget || ! iTarget->iValue )
       
   714         {
       
   715         User::Leave(KErrNotReady);
       
   716         }
       
   717 
       
   718     // want to find this field in any record of this type that has appropriate attributes
       
   719     // so mask out recordid, reserved bits and any attributes that need not be observed.
       
   720     // TUint32 mask = KCDMaskShowType | (~aAttributeFlags & KCDMaskShowAttributes);
       
   721     TUint32 mask = KCDMaskShowType | aSession->GetReadAttributeMask();
       
   722     
       
   723     TInt err(KErrNotFound);
       
   724    
       
   725     if (Changed())
       
   726         {
       
   727         const TDesC8& val = *iTarget->iValue;
       
   728         // An absent text field is treated as being synonymous with one that is present but blank, ie
       
   729         // searching for an empty descriptor matches both actual blanks and fields that aren't found. Because
       
   730         // CenRep doesn't support such a thing we're forced to get handle this case by brute force: get the set
       
   731         // of all record ids, fetch the desired field for each, and remove those records where the field is present
       
   732         // and non blank.
       
   733        	// @TODO - find a cleaner way to achieve this
       
   734        	if(val.Length() == 0)
       
   735        		{
       
   736         	TUint32 recId = (ElementId() & ~KCDMaskShowFieldType) | KCDInitialColumnId;
       
   737         	err = aSession->StorageL()->FindL(recId & ~aSession->GetReadAttributeMask(), mask, aIds);
       
   738         	if(err == KErrNone)
       
   739         		{
       
   740         		TBuf8<1> dummyVal;	// doesn't matter if it overflows; mere presence of non-blank is all we seek
       
   741         		for(TInt idx = aIds.Count() - 1; idx >= 0; --idx)
       
   742         			{
       
   743         			TUint32 fldId = (aIds[idx] & ~KCDMaskShowFieldType) | (ElementId() & KCDMaskShowFieldType);
       
   744         			TInt lookupErr = aSession->StorageL()->Get(fldId, dummyVal);
       
   745         			if(lookupErr == KErrOverflow || (lookupErr == KErrNone && dummyVal.Length() != 0))
       
   746         				{
       
   747         				// comparison field does exist in this specific record but didn't match "" - remove
       
   748         				aIds.Remove(idx);
       
   749         				}
       
   750         			}
       
   751         		}
       
   752        		}
       
   753        	else
       
   754        		{
       
   755 	        err = aSession->StorageL()->FindEqL(ElementId() & ~aSession->GetReadAttributeMask(), mask, val, aIds);
       
   756        	
       
   757             RArray<TUint32> ids;
       
   758             CleanupClosePushL(ids);
       
   759         
       
   760             mask = (mask & ~ECDHidden) | KCDMaskShowRecordId;
       
   761 
       
   762             // Now look in template record
       
   763             err = aSession->StorageL()->FindEqL(ElementId() & ~KCDMaskShowRecordId, mask, val, ids);
       
   764                 
       
   765             if ( err == KErrNone )
       
   766                 {
       
   767                 FindRecordsUsingTemplateL(aSession, ids, aIds);
       
   768                 }
       
   769        	    
       
   770             if ( aIds.Count() )
       
   771                 {
       
   772                 err = KErrNone;
       
   773                 }
       
   774 
       
   775             CleanupStack::PopAndDestroy(&ids);
       
   776             }
       
   777         }
       
   778     else
       
   779         {  
       
   780         err = aSession->StorageL()->FindL(ElementId() & ~aSession->GetReadAttributeMask(), mask, aIds);  
       
   781         }
       
   782     
       
   783     if ( aIds.Count() == 0)
       
   784         {
       
   785         __FLOG_STATIC3(KLogComponent, KCDErrLog, _L("TMDBVisitor<HBufC8*> FindL() storage server FindL returned err = %d when looking for %08x, masked with %08x"), err, ElementId(), mask);
       
   786         if (err == KErrNone || err == KErrNotFound)
       
   787             {
       
   788             __FLOG_STATIC2(KLogComponent, KCDInfoLog, _L("TMDBVisitor<HBufC8*> FindL() storage server FindL did not find <%08x> masked with <%08x>"), ElementId(), mask);
       
   789             err = KErrNotFound;
       
   790             }
       
   791         else
       
   792             {
       
   793             __FLOG_STATIC3(KLogComponent, KCDErrLog, _L("TMDBVisitor<HBufC8*> FindL() storage server FindL returned err = %d when looking for <%08x>, masked with <%08x>"), err, ElementId(), mask);
       
   794             }
       
   795         }   
       
   796 #ifdef __DEBUG
       
   797     else if ( aIds->Count() > 1)
       
   798         {
       
   799         __FLOG_STATIC2(KLogComponent, KCDErrLog, _L("TMDBVisitor<HBufC8*> FindL() storage server FindL/FindEqL %d fields found when looking for <%08x>.  Should be 1 or 0."), aIds.Count(), ElementId() & mask);
       
   800         }
       
   801 #endif
       
   802  
       
   803     return err;
       
   804     }
       
   805 
       
   806 
       
   807 
       
   808 template<class TYPE> 
       
   809 inline TInt TMDBVisitor<TYPE>::StoreL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags)
       
   810 /*
       
   811  Store the field in the repository
       
   812  
       
   813  @internalComponent
       
   814 */
       
   815     {
       
   816     if (! iTarget || ! iElementId )
       
   817         {
       
   818         User::Leave(KErrNotReady);
       
   819         }
       
   820 
       
   821     *iElementId = (*iElementId & ~KCDMaskShowRecordId) | (aRecordId & KCDMaskShowRecordId) | aAttributeFlags;            
       
   822     return aSession->StorageL()->Create( ElementId() & KCDMaskHideRes, iTarget->iValue);
       
   823     }
       
   824 
       
   825 
       
   826 
       
   827 template<> 
       
   828 inline TInt TMDBVisitor<HBufC16*>::StoreL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags)
       
   829 /*
       
   830  Store the field in the repository
       
   831  
       
   832  @internalComponent
       
   833 */
       
   834     {
       
   835     if (! iTarget || ! iElementId )
       
   836         {
       
   837         User::Leave(KErrNotReady);
       
   838         }
       
   839     
       
   840     *iElementId = (*iElementId & ~KCDMaskShowRecordId) | (aRecordId & KCDMaskShowRecordId) | aAttributeFlags;
       
   841     return aSession->StorageL()->Create( ElementId() & KCDMaskHideRes, *(iTarget->iValue));
       
   842     }
       
   843 
       
   844 
       
   845 
       
   846 template<> 
       
   847 inline TInt TMDBVisitor<HBufC8*>::StoreL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags)
       
   848 /*
       
   849  Store the field in the repository
       
   850  
       
   851  @internalComponent
       
   852 */
       
   853     {
       
   854     if (! iTarget || ! iTarget->iValue )
       
   855         {
       
   856         User::Leave(KErrNotReady);
       
   857         }
       
   858     
       
   859     *iElementId = (*iElementId & ~KCDMaskShowRecordId) | (aRecordId & KCDMaskShowRecordId) | aAttributeFlags;
       
   860    	return aSession->StorageL()->Create( ElementId() & KCDMaskHideRes, *(iTarget->iValue));
       
   861     }
       
   862 
       
   863 
       
   864 
       
   865 template<class TYPE> 
       
   866 inline TInt TMDBVisitor<TYPE>::ModifyL(CMDBSessionImpl* aSession, TMDBAttributeFlags aAttributeFlags)
       
   867 /*
       
   868 Modify the value of a field if the field exists
       
   869 Never need to modify attributes as this is always done via the node.
       
   870 
       
   871 @internalComponent
       
   872 */
       
   873     { 
       
   874     TInt err(KErrNotFound);
       
   875     
       
   876     if (! iTarget || !iElementId )
       
   877         {
       
   878         User::Leave(KErrNotReady);
       
   879         }
       
   880         
       
   881     *iElementId |= aAttributeFlags;
       
   882 
       
   883     TUint32 mask = (KCDMaskShowType | KCDMaskShowRecordId);
       
   884 
       
   885     RArray<TUint32> ids;
       
   886     CleanupClosePushL(ids);
       
   887 
       
   888     err = aSession->StorageL()->FindL(ElementId(), mask, ids);  
       
   889    
       
   890     if (ids.Count() > 0)
       
   891         {
       
   892 
       
   893 #ifdef __DEBUG
       
   894         if (ids.Count() > 1)
       
   895             {
       
   896             __FLOG_STATIC2(KLogComponent, KCDErrLog, _L("TMDBVisitor<TYPE> ModifyL() storage server FindL/FindEqL %d fields found when looking for id %08x.  Should be 1 or 0."), aIds.Count(), ElementId() & mask);
       
   897             }
       
   898 #endif
       
   899 
       
   900     	err = aSession->StorageL()->Set(ElementId() & KCDMaskHideRes, iTarget->iValue);
       
   901         }
       
   902     else
       
   903         {
       
   904         err = aSession->StorageL()->Create(ElementId() & KCDMaskHideRes, iTarget->iValue);  
       
   905         }
       
   906     
       
   907     CleanupStack::PopAndDestroy(&ids);
       
   908     return err;
       
   909     }
       
   910 
       
   911 
       
   912 
       
   913 
       
   914 template<> 
       
   915 inline TInt TMDBVisitor<HBufC16*>::ModifyL(CMDBSessionImpl* aSession, TMDBAttributeFlags aAttributeFlags)
       
   916 /*
       
   917 ElementId must be fully resolved before this call
       
   918 
       
   919 @internalComponent
       
   920 */
       
   921     {
       
   922     if (! iTarget || !iElementId )
       
   923         {
       
   924         User::Leave(KErrNotReady);
       
   925         }
       
   926   
       
   927     *iElementId |= aAttributeFlags;
       
   928     TUint32 mask = KCDMaskShowType | KCDMaskShowRecordId;
       
   929 
       
   930     RArray<TUint32> ids;
       
   931     CleanupClosePushL(ids);
       
   932 
       
   933     TInt err = aSession->StorageL()->FindL(ElementId(), mask, ids);  
       
   934    
       
   935     if (ids.Count() > 0)
       
   936         {
       
   937 #ifdef DEBUG
       
   938         if (ids.Count() > 1)
       
   939             {
       
   940             __FLOG_STATIC2(KLogComponent, KCDErrLog, _L("TMDBVisitor<TYPE> ModifyL() storage server FindL/FindEqL %d fields found when looking for id %08x.  Should be 1 or 0."), aIds.Count(), ElementId() & mask);
       
   941             }
       
   942 #endif
       
   943 
       
   944         if(! iTarget->iValue)
       
   945         	{
       
   946     	    return KErrNone;
       
   947     	    }
       
   948 
       
   949 		err = aSession->StorageL()->Set(ElementId() & KCDMaskHideRes, *(iTarget->iValue));
       
   950         }
       
   951     else
       
   952     	{
       
   953         if(! iTarget->iValue)
       
   954     	    {
       
   955     	    return KErrNone;
       
   956     	    }
       
   957     	err = aSession->StorageL()->Create(ElementId() & KCDMaskHideRes, *(iTarget->iValue));
       
   958     	}
       
   959     	
       
   960     CleanupStack::PopAndDestroy(&ids);
       
   961     return err;
       
   962     }
       
   963 
       
   964 
       
   965 
       
   966 template<> 
       
   967 inline TInt TMDBVisitor<HBufC8*>::ModifyL(CMDBSessionImpl* aSession, TMDBAttributeFlags aAttributeFlags)
       
   968 /*
       
   969 ElementId must be fully resolved before this call
       
   970 
       
   971 @internalComponent
       
   972 */
       
   973     { 
       
   974     if (! iTarget || !iElementId )
       
   975         {
       
   976         User::Leave(KErrNotReady);
       
   977         }       
       
   978  
       
   979     *iElementId |= aAttributeFlags;
       
   980     TUint32 mask = KCDMaskShowType | KCDMaskShowRecordId;
       
   981 
       
   982     RArray<TUint32> ids;
       
   983     CleanupClosePushL(ids);
       
   984 
       
   985     TInt err = aSession->StorageL()->FindL(ElementId(), mask, ids);  
       
   986    
       
   987     if (ids.Count() > 0)
       
   988         {
       
   989 #ifdef __DEBUG
       
   990         if (ids.Count() > 1)
       
   991             {
       
   992             __FLOG_STATIC2(KLogComponent, KCDErrLog, _L("TMDBVisitor<HBufC8*> ModifyL() storage server FindL/FindEqL %d fields found when looking for %08x.  Should be 1 or 0."), ids.Count(), ElementId() & mask);
       
   993             }
       
   994 #endif
       
   995 
       
   996         if(! iTarget->iValue)
       
   997        	    {
       
   998     	    return KErrNone;
       
   999     	    }
       
  1000 
       
  1001 		err = aSession->StorageL()->Set(ElementId() & KCDMaskHideRes, *(iTarget->iValue));
       
  1002         }
       
  1003     else
       
  1004     	{
       
  1005         if(! iTarget->iValue)
       
  1006            	{
       
  1007     	    return KErrNone;
       
  1008     	    }
       
  1009  
       
  1010     	err = aSession->StorageL()->Create(ElementId() & KCDMaskHideRes, *(iTarget->iValue));
       
  1011     	}
       
  1012 
       
  1013     CleanupStack::PopAndDestroy(&ids);
       
  1014     return err;
       
  1015     }
       
  1016 
       
  1017 
       
  1018 
       
  1019 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
       
  1020 // Record Set Visitor
       
  1021 //
       
  1022 
       
  1023 NONSHARABLE_CLASS(TMDBRecordSetVisitor) : public TMDBVisitorBase
       
  1024 /*
       
  1025 A visitor for CMDBRecordSet.data
       
  1026 
       
  1027 @internalComponent
       
  1028 */
       
  1029     {
       
  1030 public:
       
  1031 
       
  1032     static TMDBRecordSetVisitor* NewL(const TAny* aMem, const TAny* aData);
       
  1033 
       
  1034     // GET
       
  1035     TInt LoadL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags);
       
  1036     TInt LoadL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags, RArray<TUint32>& aIds);
       
  1037     TInt FindL(CMDBSessionImpl* aSession, RArray<TUint32>& aIds);
       
  1038     TInt RefreshL(CMDBSessionImpl* aSession);
       
  1039    
       
  1040     // SET
       
  1041     TInt StoreL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags);
       
  1042     TInt ModifyL(CMDBSessionImpl* aSession, TMDBAttributeFlags aAttributeFlags);
       
  1043  
       
  1044     TInt Changed() const;
       
  1045     void Sync(){} // do nothing - leave changed flag set
       
  1046 
       
  1047     //void SetOwner(CMDBElement* aOwner);
       
  1048       
       
  1049 public:
       
  1050    
       
  1051     RPointerArray<CMDBRecordBase>*   iTarget; 
       
  1052          
       
  1053 protected:
       
  1054 
       
  1055     TMDBRecordSetVisitor(RPointerArray<CMDBRecordBase>* aData); 
       
  1056 
       
  1057 private:
       
  1058     
       
  1059     void DoFindL(CMDBSessionImpl& aSession, CMDBElement& aElement, TInt& aErr, RArray<TUint32>& aCandidates, RArray<TUint32>& aMatches);
       
  1060     };  
       
  1061 
       
  1062 
       
  1063 
       
  1064 
       
  1065 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
  1066 //  Record Link Visitor
       
  1067 //
       
  1068 
       
  1069 
       
  1070 NONSHARABLE_CLASS(TMDBRecordLinkVisitor) : public TMDBVisitor<TInt>
       
  1071 /*
       
  1072 A visitor for linked record data
       
  1073 
       
  1074 @internalComponent
       
  1075 */
       
  1076     {
       
  1077 public:
       
  1078     static TMDBRecordLinkVisitor* NewL(const TAny* aMem, const TAny* aData);
       
  1079 
       
  1080     // GET
       
  1081     TInt LoadL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags);
       
  1082     TInt LoadL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags, RArray<TUint32>& aIds);
       
  1083     TInt FindL(CMDBSessionImpl* aSession, RArray<TUint32>& aIds);
       
  1084     TInt RefreshL(CMDBSessionImpl* aSession);
       
  1085     TInt GetL(CMDBSessionImpl* aSession);
       
  1086    
       
  1087     // SET
       
  1088     TInt StoreL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags);
       
  1089     TInt ModifyL(CMDBSessionImpl* aSession, TMDBAttributeFlags aAttributeFlags);
       
  1090 
       
  1091 	TInt Changed() const;
       
  1092     void SetOwner(CMDBElement* aOwner);
       
  1093 
       
  1094 private:
       
  1095     void SetLinkValueL(CMDBSession& aSession);
       
  1096 
       
  1097     void CheckLinkedRecordL(TMDBElementId aLinkedElementId);
       
  1098 
       
  1099     void CreateLinkedRecordL(CMDBSession& aSession, TMDBElementId aLinkedElementId);
       
  1100 
       
  1101     void CheckLinkValueL(TMDBElementId aLinkedElementId);
       
  1102 
       
  1103     void MaintainBCForLegacyLinks();
       
  1104 public:
       
  1105     
       
  1106     CMDBElement** iLinkedRecord; 
       
  1107     
       
  1108 protected:
       
  1109 
       
  1110     TMDBRecordLinkVisitor(CMDBElement** aData);
       
  1111     };  
       
  1112 
       
  1113 
       
  1114 
       
  1115 
       
  1116 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
  1117 //  User defined Record Visitor
       
  1118 //
       
  1119 
       
  1120 
       
  1121 NONSHARABLE_CLASS(TMDBGenericRecordVisitor) : public TMDBVisitorBase
       
  1122 /*
       
  1123 A visitor for data inside a user-defined record
       
  1124 
       
  1125 @internalComponent
       
  1126 */
       
  1127     {
       
  1128 public:
       
  1129  
       
  1130     static TMDBGenericRecordVisitor* NewL(const TAny* aMem, const TAny* aData);
       
  1131 
       
  1132     // GET
       
  1133     void LoadTableInfoL(CMDBSessionImpl& aSession, TMDBAttributeFlags aAttributeFlags, CMDBGenericRecord& aRealOwner);
       
  1134     TInt LoadL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags);
       
  1135     TInt LoadL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags, RArray<TUint32>& aIds);
       
  1136     void FindTableL(CMDBSessionImpl& aSession, CMDBGenericRecord& aRealOwner, RArray<TUint32>& aMatchingIds);
       
  1137     TInt FindL(CMDBSessionImpl* aSession, RArray<TUint32>& aIds);
       
  1138     TInt RefreshL(CMDBSessionImpl* aSession);
       
  1139    
       
  1140     // SET
       
  1141     void StoreTableInfoL(CMDBSessionImpl& aSession, CMDBGenericRecord& aRealOwner);
       
  1142     TInt StoreL(CMDBSessionImpl* aSession, TMDBElementId aRecordId, TMDBAttributeFlags aAttributeFlags);
       
  1143     TInt ModifyL(CMDBSessionImpl* aSession, TMDBAttributeFlags aAttributeFlags);
       
  1144 
       
  1145 	TInt Changed() const;
       
  1146     void Sync(){} // do nothing - leave changed flag set
       
  1147     //void SetOwner(CMDBElement* aOwner);
       
  1148      
       
  1149 public:
       
  1150 
       
  1151     RPointerArray<CMDBElement>* iTarget;    
       
  1152     
       
  1153 protected:
       
  1154 
       
  1155     TMDBGenericRecordVisitor(RPointerArray<CMDBElement>* aData);
       
  1156 
       
  1157     TMDBVisitorBase* CreateVisitorL(TAny* mem, CMDBElement* element, SGenericRecordTypeInfo* aRecordInfo);
       
  1158 
       
  1159 private:
       
  1160 
       
  1161     CMDBGenericRecord* SetReadyL();
       
  1162     };  
       
  1163 
       
  1164 
       
  1165 
       
  1166     } // End namespace CommsDat
       
  1167 
       
  1168 
       
  1169 
       
  1170 #endif //METADATABASEVISITOR_H