metadataengine/server/src/mdsobjectdef.cpp
changeset 0 c53acadfccc6
child 14 646a02f170b9
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 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:  Class to hold description about one object and it's properties
       
    15 *
       
    16 */
       
    17 
       
    18 #include "mdsobjectdef.h"
       
    19 
       
    20 #include "mdcdef.h"
       
    21 #include "mdspropertydef.h"
       
    22 #include "mdsdbconnectionpool.h"
       
    23 #include "mdcserializationbuffer.h"
       
    24 #include "mdsindexer.h"
       
    25 #include "mdeinternalerror.h"
       
    26 
       
    27 /**
       
    28  * NewLC
       
    29  */
       
    30 CMdsObjectDef* CMdsObjectDef::NewLC(const TDesC& aName, const CMdsObjectDef* aParent )
       
    31 	{
       
    32 	CMdsObjectDef* ret = new( ELeave ) CMdsObjectDef( aParent );
       
    33 	CleanupStack::PushL( ret );
       
    34 	ret->ConstructL( aName );
       
    35 	return ret;
       
    36 	}
       
    37 	
       
    38 /**
       
    39  * NewL
       
    40  */
       
    41 CMdsObjectDef* CMdsObjectDef::NewL( const TDesC& aName, const CMdsObjectDef* aParent )
       
    42 	{
       
    43 	CMdsObjectDef* ret = CMdsObjectDef::NewLC( aName, aParent );
       
    44 	CleanupStack::Pop( ret );
       
    45 	return ret;
       
    46 	}
       
    47 
       
    48 /**
       
    49  * default constructor
       
    50  */
       
    51 inline CMdsObjectDef::CMdsObjectDef( const CMdsObjectDef* aParent )
       
    52 	: iParent ( aParent ), iFlags( EObjectDefFlagsNone ), iMandatoryPropertyCount( 0 )
       
    53 	{}
       
    54 
       
    55 /**
       
    56  * ConstructL
       
    57  */
       
    58 void CMdsObjectDef::ConstructL( const TDesC& aName )
       
    59 	{
       
    60 	// check that only allowed characters (A-Z, a-z) are used
       
    61 	CheckAllowerCharatersL( aName, EFalse );
       
    62 
       
    63 	CMdsItemDef::ConstructL( aName );
       
    64 	}
       
    65 
       
    66 /**
       
    67  * Destructor
       
    68  */
       
    69 CMdsObjectDef::~CMdsObjectDef()
       
    70 	{
       
    71 	// deleting properties
       
    72 	iPropertyDefs.ResetAndDestroy();
       
    73 	iPropertyDefs.Close();
       
    74 
       
    75 	iCol2Prop.Close();
       
    76 	}
       
    77 
       
    78 void CMdsObjectDef::AddPropertyL( const TDesC& aName, TPropertyType aType,
       
    79 								  const TMdCValueUnion& aMinAdd, const TMdCValueUnion& aMaxAdd,
       
    80 								  TBool aReadOnly, TBool aMandatory, TBool aIndexed )
       
    81 	{
       
    82 	CMdsPropertyDef* newProp = CommonAddPropertyL( aName, aType, aReadOnly, aMandatory, aIndexed );
       
    83 	if (!newProp)
       
    84 		{
       
    85 		User::Leave( KErrMdEUnknownPropertyDef );
       
    86 		}
       
    87 	switch (aType)
       
    88 		{									
       
    89 		case EPropertyUint32:
       
    90 		case EPropertyText:
       
    91 		case EPropertyBool:		
       
    92 			{									
       
    93 			newProp->AddMinMaxValueL(aMinAdd.iUint32,aMaxAdd.iUint32);
       
    94 			break;
       
    95 			}
       
    96 		case EPropertyInt32:
       
    97 			{	
       
    98 			newProp->AddMinMaxValueL(aMinAdd.iInt32,aMaxAdd.iInt32);
       
    99 			break;
       
   100 			}
       
   101 		case EPropertyInt64:
       
   102 		case EPropertyTime:
       
   103 			{	
       
   104 			newProp->AddMinMaxValueL(aMinAdd.iInt64,aMaxAdd.iInt64);
       
   105 			break;
       
   106 			}
       
   107 		case EPropertyReal64:
       
   108 			{									
       
   109 			newProp->AddMinMaxValueL(aMinAdd.iReal,aMaxAdd.iReal);
       
   110 			break;
       
   111 			}
       
   112 
       
   113 	    default:
       
   114 	    	{
       
   115 #ifdef _DEBUG
       
   116             User::Panic( _L("MdSODAdd") , KErrMdEUnknownPropertyType );
       
   117 #endif		    	
       
   118 	    	User::Leave( KErrMdEUnknownPropertyType );
       
   119 	    	}
       
   120 		}
       
   121 	}
       
   122 	
       
   123 /**
       
   124  * AddPropertyL
       
   125  */
       
   126 void CMdsObjectDef::AddPropertyL( const TDesC& aName, TPropertyType aType,
       
   127 	                              TInt32 aMinAdd, TInt32 aMaxAdd,
       
   128 	                              TBool aReadOnly, TBool aMandatory, TBool aIndexed )
       
   129 	{
       
   130 	CMdsPropertyDef* newProp = CommonAddPropertyL( aName, aType, aReadOnly, aMandatory, aIndexed );
       
   131 	newProp->AddMinMaxValueL( aMinAdd, aMaxAdd );
       
   132 	}
       
   133 
       
   134 /**
       
   135  * AddPropertyL
       
   136  */
       
   137 void CMdsObjectDef::AddPropertyL( const TDesC& aName, TPropertyType aType,
       
   138 	                              TUint32 aMinAdd, TUint32 aMaxAdd,
       
   139 	                              TBool aReadOnly, TBool aMandatory, TBool aIndexed )
       
   140 	{
       
   141 	CMdsPropertyDef* newProp = CommonAddPropertyL( aName, aType, aReadOnly, aMandatory, aIndexed );
       
   142 	newProp->AddMinMaxValueL( aMinAdd, aMaxAdd );
       
   143 	}
       
   144 
       
   145 /**
       
   146  * AddPropertyL
       
   147  */
       
   148 void CMdsObjectDef::AddPropertyL( const TDesC& aName, TPropertyType aType,
       
   149 	                              const TInt64& aMinAdd, const TInt64& aMaxAdd,
       
   150 	                              TBool aReadOnly, TBool aMandatory, TBool aIndexed )
       
   151 	{
       
   152 	CMdsPropertyDef* newProp = CommonAddPropertyL( aName, aType, aReadOnly, aMandatory, aIndexed );
       
   153 	newProp->AddMinMaxValueL( aMinAdd, aMaxAdd );
       
   154 	}
       
   155 
       
   156 /**
       
   157  * AddPropertyL
       
   158  */
       
   159 void CMdsObjectDef::AddPropertyL( const TDesC& aName, TPropertyType aType,
       
   160 	                              const TReal& aMinAdd, const TReal& aMaxAdd,
       
   161 	                              TBool aReadOnly, TBool aMandatory, TBool aIndexed )
       
   162 	{
       
   163 	CMdsPropertyDef* newProp = CommonAddPropertyL( aName, aType, aReadOnly, aMandatory, aIndexed );
       
   164 	newProp->AddMinMaxValueL( aMinAdd, aMaxAdd );
       
   165 	}
       
   166 
       
   167 /**
       
   168  * CommonAddPropertyL
       
   169  */
       
   170 CMdsPropertyDef* CMdsObjectDef::CommonAddPropertyL( const TDesC& aName, TPropertyType aType,
       
   171 		TBool aReadOnly, TBool aMandatory, TBool aIndexed )
       
   172 	{
       
   173 	CMdsPropertyDef* propertyDef = CMdsPropertyDef::NewLC( aName, aType, aReadOnly, aMandatory,
       
   174 			aIndexed );
       
   175 	iPropertyDefs.AppendL( propertyDef );
       
   176 	CleanupStack::Pop( propertyDef );
       
   177 	return propertyDef;
       
   178 	}
       
   179 
       
   180 CMdsPropertyDef* CMdsObjectDef::CommonAddPropertyL( const TDesC& aName, TPropertyType aType,
       
   181 		TUint32 aFlags, TDefId aId )
       
   182 	{
       
   183 	CMdsPropertyDef* propertyDef = CMdsPropertyDef::NewLC( aName, aType, aFlags );
       
   184 	propertyDef->SetId(aId);
       
   185 	iPropertyDefs.AppendL( propertyDef );
       
   186 	CleanupStack::Pop( propertyDef );
       
   187 	return propertyDef;
       
   188 	}
       
   189 
       
   190 CMdsPropertyDef* CMdsObjectDef::GetProperty( TUint32 aIndex ) const
       
   191 	{
       
   192 	return iPropertyDefs[aIndex];
       
   193 	}
       
   194 
       
   195 CMdsPropertyDef* CMdsObjectDef::GetProperty( const TDesC& aName ) const
       
   196 	{
       
   197 	const TInt count = iPropertyDefs.Count();
       
   198 	
       
   199 	for ( TInt i = 0; i < count; ++i )
       
   200 		{
       
   201 		if( iPropertyDefs[i]->GetName().Compare( aName ) == 0 )
       
   202 			{
       
   203 			return iPropertyDefs[i];
       
   204 			}
       
   205 		}
       
   206 	if ( iParent )
       
   207 		{
       
   208 		return iParent->GetProperty( aName );
       
   209 		}
       
   210 	return NULL;
       
   211 	}
       
   212 
       
   213 
       
   214 const CMdsPropertyDef* CMdsObjectDef::GetPropertyByIdL( TDefId aId ) const
       
   215 	{
       
   216 	const TInt propertyDefCount = iPropertyDefs.Count();
       
   217 	for ( TInt i = 0; i < propertyDefCount; ++i )
       
   218 		{
       
   219 		const CMdsPropertyDef* propDef = iPropertyDefs[i];
       
   220 		if( propDef->GetId() == aId )
       
   221 			{
       
   222 			return propDef;
       
   223 			}
       
   224 		}
       
   225 	if ( iParent )
       
   226 		{
       
   227 		return iParent->GetPropertyByIdL( aId );
       
   228 		}
       
   229 	return NULL;
       
   230 	}
       
   231 
       
   232 
       
   233 void CMdsObjectDef::StoreToDBL( TDefId aNamespaceDefId )
       
   234 	{
       
   235 	_LIT( KMdsSqlClauseTriggerObjectDef, "CREATE TRIGGER Delete%S%u DELETE ON Object%u BEGIN DELETE FROM %S%u WHERE ObjectId=OLD.ObjectId; END;" );
       
   236 	_LIT( KMdsSqlClauseAddObjectDef, "INSERT INTO ObjectDef(NamespaceDefId, ParentDefId, Flags, Name) Values(?,?,?,?);" );
       
   237 
       
   238 	RRowData rowData;
       
   239     CleanupClosePushL( rowData );
       
   240 
       
   241 	if ( !GetStoredInDB() )
       
   242 		{
       
   243 		rowData.AppendL( TColumn( aNamespaceDefId ) );
       
   244 		rowData.AppendL( TColumn( iParent ? iParent->GetId() : KNoDefId ) );
       
   245 		rowData.AppendL( TColumn( (TInt32)iFlags ) );
       
   246 		rowData.AppendL( TColumn( GetName().AllocL() ) );
       
   247 
       
   248 		TDefId id = MMdSIndexer::ExecuteAndGetIndexL( KMdsSqlClauseAddObjectDef,rowData );
       
   249 
       
   250 	    SetId( id );
       
   251        	SetStoredInDB();
       
   252 
       
   253     	if ( GetId() != KBaseObjectDefId )
       
   254     		{
       
   255 	    	// Create trigger
       
   256 	        HBufC* sqlQueryCreateTrigger = HBufC::NewLC( KMdsSqlClauseTriggerObjectDef().Size() + ( KMaxUintValueLength * 3 )  + ( GetName().Length() * 2 ) );
       
   257             TPtr sqlPtr = sqlQueryCreateTrigger->Des();
       
   258             sqlPtr.Format( KMdsSqlClauseTriggerObjectDef, &GetName(), aNamespaceDefId, aNamespaceDefId, &GetName(), aNamespaceDefId );
       
   259             RRowData rowDataDummy;
       
   260 		    CleanupClosePushL( rowDataDummy );
       
   261 		    CMdSSqLiteConnection& connection = MMdSDbConnectionPool::GetDefaultDBL();
       
   262             connection.ExecuteL( *sqlQueryCreateTrigger, rowDataDummy );
       
   263             CleanupStack::PopAndDestroy( 2, sqlQueryCreateTrigger ); // rowDataDummy, sqlQueryCreateTrigger
       
   264     		}
       
   265 		}
       
   266 
       
   267 	// add propertyDef to DB
       
   268 	for( TInt counter = 0; counter < iPropertyDefs.Count(); ++counter )
       
   269 		{
       
   270 		iPropertyDefs[counter]->StoreToDBL( GetId() );
       
   271 		}
       
   272 	
       
   273 	CleanupStack::PopAndDestroy( &rowData );
       
   274 	}
       
   275 
       
   276 CMdsPropertyDef* CMdsObjectDef::FindProperty( const TDesC& aName ) const
       
   277 	{
       
   278 	const TInt count = iPropertyDefs.Count();
       
   279 	
       
   280 	for ( TInt i = 0; i < count; ++i )
       
   281 		{
       
   282 		if ( iPropertyDefs[i]->GetName().Compare( aName ) == 0 )
       
   283 			{
       
   284 			return iPropertyDefs[i];
       
   285 			}
       
   286 		}
       
   287 	return NULL;
       
   288 	}
       
   289 
       
   290 void CMdsObjectDef::MergeL( CMdsObjectDef* aObjectDef, const TBool& /*aDryRun*/ )
       
   291 	{
       
   292 	const TInt count = aObjectDef->iPropertyDefs.Count();
       
   293 	
       
   294 	for ( TInt i = 0; i < count; ++i )
       
   295 		{
       
   296 		CMdsPropertyDef* lPropertyDef = FindProperty( aObjectDef->iPropertyDefs[i]->GetName() );
       
   297 		if ( lPropertyDef )
       
   298 			{
       
   299 			if ( *lPropertyDef != *(aObjectDef->iPropertyDefs[i]) )
       
   300 				{
       
   301 				User::Leave( KErrAlreadyExists );
       
   302 				}
       
   303 			}
       
   304 		else
       
   305 			{
       
   306 			User::Leave( KErrAccessDenied );
       
   307 			}
       
   308 		}
       
   309 	}
       
   310 
       
   311 void CMdsObjectDef::AddPropertyL( const TDefId aId, TPropertyType aType, TUint32 aFlags,
       
   312 	                              const TDesC& aMinAdd, const TDesC& aMaxAdd, const TDesC& aName )
       
   313 	{
       
   314 	CMdsPropertyDef* prop = CommonAddPropertyL( aName, aType, aFlags, aId );
       
   315 	prop->SetStoredInDB();
       
   316 	switch( aType )
       
   317 		{
       
   318 		case EPropertyBool: case EPropertyInt8: case EPropertyUint8: case EPropertyInt16:
       
   319         case EPropertyUint16: case EPropertyInt32: case EPropertyText:
       
   320         	{
       
   321         	TInt32 minValue = 0;
       
   322             TInt32 maxValue = 0;
       
   323         	TLex lex( aMinAdd );
       
   324         	lex.Val( minValue );
       
   325         	lex.Assign( aMaxAdd );
       
   326         	lex.Val( maxValue );
       
   327         	prop->AddMinMaxValueL( minValue, maxValue );
       
   328         	break;
       
   329         	}
       
   330         case EPropertyUint32:
       
   331         	{
       
   332         	TUint32 minValue = 0;
       
   333         	TUint32 maxValue = 0;
       
   334         	TLex lex( aMinAdd );
       
   335         	lex.Val( (TInt64&)minValue );
       
   336         	lex.Assign( aMaxAdd );
       
   337         	lex.Val( (TInt64&)maxValue );
       
   338         	prop->AddMinMaxValueL( minValue, maxValue );
       
   339         	break;
       
   340         	}
       
   341         case EPropertyInt64:
       
   342         case EPropertyTime:
       
   343         	{
       
   344         	TInt64 minValue, maxValue;
       
   345         	TLex lex( aMinAdd );
       
   346         	lex.Val( minValue );
       
   347         	lex.Assign( aMaxAdd );
       
   348         	lex.Val( maxValue );
       
   349         	prop->AddMinMaxValueL( minValue, maxValue );
       
   350         	break;
       
   351         	}
       
   352         case EPropertyReal32:
       
   353         case EPropertyReal64:
       
   354         	{
       
   355         	TReal minValue, maxValue;
       
   356         	TLex lex( aMinAdd );
       
   357         	lex.Val( minValue );
       
   358         	lex.Assign( aMaxAdd );
       
   359         	lex.Val( maxValue );
       
   360         	prop->AddMinMaxValueL( minValue, maxValue );
       
   361         	break;
       
   362         	}
       
   363         default:
       
   364         	{
       
   365 #ifdef _DEBUG
       
   366             User::Panic( _L("MdSODAd2") , KErrMdEUnknownPropertyType );
       
   367 #endif		    	
       
   368         	
       
   369         	User::Leave( KErrMdEUnknownPropertyType );
       
   370         	}
       
   371 		}
       
   372 	}
       
   373 
       
   374 
       
   375 void CMdsObjectDef::ImportFromDBL()
       
   376 	{
       
   377 	_LIT( KMdsQueryGetPropertyDefs, "SELECT PropertyDefId,Flags,Type,MinValue,MaxValue,Name FROM PropertyDef WHERE ObjectDefId=?;" );
       
   378 	_LIT( KMdsQueryGetCol2Prop,     "SELECT PropertyDefId,ColumnId FROM Col2Prop WHERE ObjectDefId=?;" );
       
   379 
       
   380 	RMdsStatement query;
       
   381 	CleanupClosePushL( query );
       
   382 
       
   383 	// importing properties
       
   384 	RRowData objectNumber;
       
   385 	CleanupClosePushL( objectNumber );
       
   386 	objectNumber.AppendL( TColumn( GetId() ) );
       
   387 
       
   388 	CMdSSqLiteConnection& connection = MMdSDbConnectionPool::GetDefaultDBL();
       
   389 	TDefId propertyDefId = 0;
       
   390 	TPropertyType type;
       
   391 	TInt32 typeValue = 0;
       
   392 	TUint32 propertyFlags = 0;
       
   393 	TPtrC16 name;
       
   394     TPtrC16 minValue;
       
   395     TPtrC16 maxValue;
       
   396 	RRowData getData;
       
   397 	CleanupClosePushL( getData );
       
   398 	getData.AppendL( TColumn( propertyDefId ) );
       
   399 	getData.AppendL( TColumn( propertyFlags ) );
       
   400 	getData.AppendL( TColumn( typeValue ) );
       
   401 	getData.AppendL( TColumn( EColumnHBuf16 ) );
       
   402 	getData.AppendL( TColumn( EColumnHBuf16 ) );
       
   403 	getData.AppendL( TColumn( EColumnHBuf16 ) );
       
   404 	connection.ExecuteQueryL( KMdsQueryGetPropertyDefs, query, objectNumber );
       
   405 	while( connection.NextRowL( query, getData ) )
       
   406 		{
       
   407 		getData.Column( 0 ).Get( propertyDefId );
       
   408 		getData.Column( 1 ).Get( propertyFlags );
       
   409 		getData.Column( 2 ).Get( typeValue );
       
   410 		type = (TPropertyType)typeValue;
       
   411 		getData.Column( 3 ).Get( minValue );
       
   412 		getData.Column( 4 ).Get( maxValue );
       
   413 		getData.Column( 5 ).Get( name );
       
   414 		AddPropertyL( propertyDefId, type, propertyFlags, minValue, maxValue, name );
       
   415 		getData.Column( 5 ).Free( );
       
   416 		getData.Column( 4 ).Free( );
       
   417 		getData.Column( 3 ).Free( );
       
   418 		}
       
   419 
       
   420 	iCol2Prop.Reset();
       
   421 	RMdsStatement queryCol;
       
   422 	CleanupClosePushL( queryCol );
       
   423 	RRowData getColData;
       
   424 	CleanupClosePushL( getColData );
       
   425 	TUint32 columnId = 0;
       
   426 	getColData.AppendL( TColumn( propertyDefId ) );
       
   427 	getColData.AppendL( TColumn( columnId ) );
       
   428 	connection.ExecuteQueryL( KMdsQueryGetCol2Prop, queryCol, objectNumber );
       
   429 	while( connection.NextRowL( queryCol, getColData ) )
       
   430 		{
       
   431 		getColData.Column( 0 ).Get( propertyDefId );
       
   432 		getColData.Column( 1 ).Get( columnId );
       
   433 		const CMdsPropertyDef* propertyDef = GetPropertyByIdL( propertyDefId );
       
   434 		
       
   435 		if( !propertyDef )
       
   436 			{
       
   437 			User::Leave( KErrMdEUnknownPropertyDef );
       
   438 			}
       
   439 
       
   440 		CMdsObjectDef::TMdsColumnOrder col = { columnId, *propertyDef };
       
   441 		iCol2Prop.AppendL( col );
       
   442 		
       
   443 		if( propertyDef->GetMandatory() )
       
   444 			{
       
   445 			++iMandatoryPropertyCount;
       
   446 			}
       
   447 		}
       
   448 
       
   449 	// everything is ok, so set the flags
       
   450 	SetStoredInDB();
       
   451 	SetTableStoredInDB();
       
   452 	SetC2PStoredInDB();
       
   453 
       
   454 	CleanupStack::PopAndDestroy( 5, &query ); // getColData, queryCol, getData, objectNumber, query
       
   455 	}
       
   456 	
       
   457 TUint32 CMdsObjectDef::RequiredBufferSize()
       
   458 	{
       
   459 	TUint32 bufferSize = sizeof(TMdCObjectDef) + CMdsItemDef::RequiredBufferSize();
       
   460 
       
   461 	// propertydefs
       
   462 	const TInt propertyDefsCount = iPropertyDefs.Count();
       
   463 	bufferSize += propertyDefsCount * sizeof(TMdCPropertyDef);
       
   464 	for ( TInt i = 0; i < propertyDefsCount; ++i )
       
   465 		{
       
   466 		bufferSize += iPropertyDefs[i]->RequiredBufferSize();
       
   467 		}
       
   468 
       
   469 	return bufferSize;
       
   470 	}
       
   471 
       
   472 TMdCOffset CMdsObjectDef::SerializeL( CMdCSerializationBuffer& aBuffer, TMdCOffset aFreeSpace )
       
   473 	{
       
   474 	const TMdCOffset objectDefOffset = aBuffer.Position();
       
   475 	TMdCObjectDef objectDef;
       
   476 	// get const data and store Name
       
   477 	objectDef.iDefId = GetId();
       
   478 	objectDef.iParentId = iParent ? iParent->GetId() : KNoDefId;
       
   479 	objectDef.iName.iPtr.iCount = GetName().Length();
       
   480 	objectDef.iName.iPtr.iOffset = aFreeSpace;
       
   481 	aBuffer.PositionL( aFreeSpace );
       
   482 	aFreeSpace = CMdsItemDef::SerializeL( aBuffer );
       
   483 
       
   484 	// calculate necessary stuff for propertyDefs
       
   485 	const TInt propertyDefsCount = iPropertyDefs.Count();
       
   486 	objectDef.iPropertyDefs.iPtr.iCount = propertyDefsCount;
       
   487 	objectDef.iPropertyDefs.iPtr.iOffset = aFreeSpace;
       
   488 
       
   489 	// create space for propertyDefs
       
   490 	aFreeSpace += propertyDefsCount * sizeof(TMdCPropertyDef);
       
   491 
       
   492 	for ( TInt i = 0; i < propertyDefsCount; ++i )
       
   493 		{
       
   494 		aBuffer.PositionL( objectDef.iPropertyDefs.iPtr.iOffset + i * sizeof(TMdCPropertyDef) );
       
   495 		// write object
       
   496 		aFreeSpace = iPropertyDefs[i]->SerializeL( aBuffer, aFreeSpace );
       
   497 		}
       
   498 
       
   499 	// store objectDef itself
       
   500 	aBuffer.PositionL( objectDefOffset );
       
   501 	objectDef.SerializeL( aBuffer );
       
   502 
       
   503 	return aFreeSpace;
       
   504 	}
       
   505 
       
   506 TInt CMdsObjectDef::GetAllPropertiesCount() const
       
   507 	{
       
   508 #ifdef _DEBUG
       
   509 	_LIT( KCountPanicError, "CMdsObjectDef::GetAllPropertiesCount()" );
       
   510 	TInt temp = iPropertyDefs.Count() + ( iParent ? iParent->GetAllPropertiesCount() : 0 );
       
   511 	__ASSERT_DEBUG( temp == iCol2Prop.Count(), User::Panic( KCountPanicError, KErrCorrupt ) );
       
   512 #endif
       
   513 	return iCol2Prop.Count();
       
   514 	}
       
   515 
       
   516 TInt CMdsObjectDef::GetMandatoryPropertyCount() const
       
   517 	{
       
   518 	return iMandatoryPropertyCount;
       
   519 	}
       
   520 
       
   521 void CMdsObjectDef::SetStoredEveryInDB()
       
   522 	{
       
   523 	SetStoredInDB();
       
   524 	
       
   525 	const TInt count = iPropertyDefs.Count();
       
   526 	
       
   527 	for ( TInt i = 0; i < count; ++i )
       
   528 		{
       
   529 		iPropertyDefs[i]->SetStoredInDB();
       
   530 		}
       
   531 	}
       
   532 
       
   533 void CMdsObjectDef::SetNotStoredEveryInDB()
       
   534 	{
       
   535 	SetAllNotStoredInDB();
       
   536 	
       
   537 	const TInt count = iPropertyDefs.Count();
       
   538 	
       
   539 	for ( TInt i = 0; i < count; ++i )
       
   540 		{
       
   541 		iPropertyDefs[i]->SetAllNotStoredInDB();
       
   542 		}
       
   543 	}