mpx/commonframework/common/src/mpxattribute.cpp
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     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:  mpx attribute class
       
    15 *
       
    16 */
       
    17 
       
    18 #include "mpxattribute.h"
       
    19 // ============================ MEMBER FUNCTIONS ==============================
       
    20 
       
    21 // ----------------------------------------------------------------------------
       
    22 // Overloadded operator
       
    23 // ----------------------------------------------------------------------------
       
    24 //
       
    25 EXPORT_C TBool TMPXAttributeData::operator& (
       
    26     const TMPXAttributeData& aData) const
       
    27     {
       
    28     ASSERT(iContentId == aData.iContentId);
       
    29     return iAttributeId & aData.iAttributeId;
       
    30     }
       
    31 
       
    32 // ----------------------------------------------------------------------------
       
    33 // Overloadded operator
       
    34 // ----------------------------------------------------------------------------
       
    35 //
       
    36 EXPORT_C TBool TMPXAttributeData::operator& (TUint& aData) const
       
    37     {
       
    38     return iAttributeId & aData;
       
    39     }
       
    40 // ----------------------------------------------------------------------------
       
    41 // Overloadded operator
       
    42 // ----------------------------------------------------------------------------
       
    43 //
       
    44 EXPORT_C TMPXAttributeData TMPXAttributeData::operator| (
       
    45     const TMPXAttributeData& aData) const
       
    46     {
       
    47     ASSERT(iContentId == aData.iContentId);
       
    48     TMPXAttributeData ret={iContentId, iAttributeId | aData.iAttributeId};
       
    49     return ret;
       
    50     }
       
    51 
       
    52 // ----------------------------------------------------------------------------
       
    53 // C++ default constructor
       
    54 // ----------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C TMPXAttribute::TMPXAttribute()
       
    57     {
       
    58     iData.iContentId=0;
       
    59     iData.iAttributeId=0;
       
    60     }
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // C++ constructor
       
    64 // ----------------------------------------------------------------------------
       
    65 //
       
    66 EXPORT_C TMPXAttribute::TMPXAttribute(TInt aContentId, TUint aAttributeId)
       
    67     {
       
    68     iData.iContentId=aContentId;
       
    69     iData.iAttributeId=aAttributeId;
       
    70     }
       
    71 
       
    72 // ----------------------------------------------------------------------------
       
    73 // Copy constructor
       
    74 // ----------------------------------------------------------------------------
       
    75 //
       
    76 EXPORT_C TMPXAttribute::TMPXAttribute(const TMPXAttribute& aId)
       
    77     {
       
    78     iData.iContentId=aId.ContentId();
       
    79     iData.iAttributeId=aId.AttributeId();
       
    80     }
       
    81 
       
    82 // ----------------------------------------------------------------------------
       
    83 // Copy constructor
       
    84 // ----------------------------------------------------------------------------
       
    85 //
       
    86 EXPORT_C TMPXAttribute::TMPXAttribute(const TMPXAttributeData& aData)
       
    87 :   iData(aData)
       
    88     {
       
    89     }
       
    90 
       
    91 // ----------------------------------------------------------------------------
       
    92 // Overloaded assignment operator
       
    93 // ----------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C TMPXAttribute& TMPXAttribute::operator=(const TMPXAttribute& aId)
       
    96     {
       
    97     if (this != &aId)
       
    98         {
       
    99         iData.iContentId = aId.ContentId();
       
   100         iData.iAttributeId = aId.AttributeId();
       
   101         }
       
   102     return *this;
       
   103     }
       
   104 
       
   105 // ----------------------------------------------------------------------------
       
   106 // Overloaded equal operator
       
   107 // ----------------------------------------------------------------------------
       
   108 //
       
   109 EXPORT_C TBool TMPXAttribute::operator==(const TMPXAttribute& aId) const
       
   110     {
       
   111     TBool ret = EFalse;
       
   112     if (iData.iAttributeId == aId.iData.iAttributeId && 
       
   113         iData.iContentId == aId.iData.iContentId)
       
   114         {
       
   115         ret = ETrue;
       
   116         }
       
   117     return ret;
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // Externalize
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 EXPORT_C void TMPXAttribute::ExternalizeL(RWriteStream& aStream) const
       
   125     {
       
   126     aStream.WriteInt32L(iData.iContentId);
       
   127     aStream.WriteUint32L(iData.iAttributeId);
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // Internalize
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 EXPORT_C void TMPXAttribute::InternalizeL(RReadStream& aStream)
       
   135     {
       
   136     iData.iContentId=aStream.ReadInt32L();
       
   137     iData.iAttributeId=aStream.ReadUint32L();
       
   138     }
       
   139 
       
   140 // ----------------------------------------------------------------------------
       
   141 // Return content id
       
   142 // ----------------------------------------------------------------------------
       
   143 //
       
   144 EXPORT_C TInt TMPXAttribute::ContentId() const
       
   145     {
       
   146     return iData.iContentId;
       
   147     }
       
   148 
       
   149 // ----------------------------------------------------------------------------
       
   150 // Return attribute id
       
   151 // ----------------------------------------------------------------------------
       
   152 //
       
   153 EXPORT_C TUint TMPXAttribute::AttributeId() const
       
   154     {
       
   155     return iData.iAttributeId;
       
   156     }
       
   157     
       
   158 // -----------------------------------------------------------------------------
       
   159 // Helper function to do match in the RArray of the objects of this class
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 EXPORT_C TBool TMPXAttribute::Match(
       
   163     const TMPXAttribute& aFirst, 
       
   164     const TMPXAttribute& aSecond)
       
   165     {
       
   166     return aFirst==aSecond;
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // Helper function to do match in the RArray of the objects of this class by
       
   171 // content id
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 EXPORT_C TBool TMPXAttribute::MatchContentId(
       
   175     const TMPXAttribute& aFirst, 
       
   176     const TMPXAttribute& aSecond)
       
   177     {
       
   178     return aFirst.ContentId()==aSecond.ContentId();
       
   179     }
       
   180 
       
   181 // End of File