metadataengine/client/src/mdepropertycondition.cpp
changeset 0 c53acadfccc6
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:  Represent property condition
       
    15 *
       
    16 */
       
    17 
       
    18 #include "mdepropertycondition.h"
       
    19 #include "mdcserializationbuffer.h"
       
    20 #include "mdepropertydef.h"
       
    21 #include "mdeobjectdef.h"
       
    22 #include "mdscommoninternal.h"
       
    23 #include "mdcquery.h"
       
    24 
       
    25 CMdEPropertyCondition* CMdEPropertyCondition::NewL( const CMdEPropertyDef& aPropertyDef )
       
    26     {
       
    27     CMdEPropertyCondition* self = CMdEPropertyCondition::NewLC( aPropertyDef );
       
    28     CleanupStack::Pop( self );
       
    29     return self;
       
    30     }
       
    31 
       
    32 CMdEPropertyCondition* CMdEPropertyCondition::NewLC( const CMdEPropertyDef& aPropertyDef )
       
    33     {
       
    34     CMdEPropertyCondition* self = new ( ELeave ) CMdEPropertyCondition( aPropertyDef );
       
    35     CleanupStack::PushL( self );
       
    36     self->ConstructL();
       
    37     return self;
       
    38     }
       
    39 
       
    40 CMdEPropertyCondition::CMdEPropertyCondition(const CMdEPropertyDef& aPropertyDef)
       
    41         : CMdECondition(EConditionTypeProperty), iPropertyDef(aPropertyDef)
       
    42     {
       
    43     }
       
    44 
       
    45 CMdEPropertyCondition::CMdEPropertyCondition(TConditionType aConditionType, 
       
    46                                              const CMdEPropertyDef& aPropertyDef)
       
    47         : CMdECondition(aConditionType), iPropertyDef(aPropertyDef)
       
    48     {
       
    49     }
       
    50 
       
    51 void CMdEPropertyCondition::ConstructL()
       
    52     {
       
    53     // Base class construction.
       
    54     ConditionConstruct();
       
    55     }
       
    56 
       
    57 CMdEPropertyCondition::~CMdEPropertyCondition()
       
    58 	{
       
    59 	}
       
    60 
       
    61 EXPORT_C const CMdEPropertyDef& CMdEPropertyCondition::PropertyDef() const
       
    62     {
       
    63     return iPropertyDef;
       
    64     }
       
    65 
       
    66 TUint32 CMdEPropertyCondition::InternalQueryOptimizationFlags(TUint32& aFlags)
       
    67 	{
       
    68 	aFlags |= EContainsObjectCondition;
       
    69 	return EContainsObjectCondition;
       
    70 	}
       
    71 
       
    72 TUint32 CMdEPropertyCondition::RequiredBufferSize() const
       
    73 	{
       
    74 	// Required size for property condition
       
    75 	return sizeof( TMdCPropertyCondition );
       
    76 	}
       
    77 
       
    78 void CMdEPropertyCondition::SerializeL(CMdCSerializationBuffer& aBuffer,
       
    79 		TMdCOffset& aFreespaceOffset) const
       
    80 	{
       
    81 	TMdCPropertyCondition condition;
       
    82 
       
    83 	condition.iConditionType = iType;
       
    84 	condition.iNegated = iNegated;
       
    85 	condition.iObjectDefId = iPropertyDef.ObjectDefId();
       
    86 	condition.iPropertyDefId = iPropertyDef.Id();
       
    87 	condition.iCondition = KNoOffset;
       
    88 
       
    89 	condition.SerializeL( aBuffer );
       
    90 
       
    91 	aFreespaceOffset = aBuffer.Position();
       
    92 	}