mtpfws/mtpfw/src/tmtptypeobjecthandle.cpp
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 #include "tmtptypeobjecthandle.h"
       
    18 #include <mtp/tmtptypeuint32.h>
       
    19 
       
    20 /**
       
    21 Constructor.
       
    22 @param aId The data provider unique object identifier.
       
    23 @param aDp The ID of the data provider responsible for the object.
       
    24 */
       
    25 TMTPTypeObjectHandle::TMTPTypeObjectHandle(TUint32 aId, TUint8 aDp) : 
       
    26     TMTPTypeUint32(aId)
       
    27     {
       
    28     __ASSERT_DEBUG((aId <= KObjectIdMax), User::Invariant());
       
    29     SetDPHandle(aDp);
       
    30     }
       
    31     
       
    32 /**
       
    33 Destructor.
       
    34 */
       
    35 TMTPTypeObjectHandle::~TMTPTypeObjectHandle()
       
    36     {
       
    37     }
       
    38 
       
    39 /**
       
    40 Constructor.
       
    41 @param aId The data provider unique object identifier.
       
    42 @param aDp The ID of the data provider responsible for the object.
       
    43 */
       
    44 TMTPTypeObjectHandle::TMTPTypeObjectHandle(TMTPTypeUint32 aId, TUint8 aDp) : TMTPTypeUint32(aId)
       
    45     {
       
    46     __ASSERT_DEBUG((aId.Value() <= KObjectIdMax), User::Invariant());
       
    47     SetDPHandle(aDp);
       
    48     }
       
    49 
       
    50 /**
       
    51 Constructor.
       
    52 @param aHandle A valid encoded 32-bit MTP object handle.
       
    53 */
       
    54 TMTPTypeObjectHandle::TMTPTypeObjectHandle(TMTPTypeUint32 aHandle) : 
       
    55     TMTPTypeUint32(aHandle)
       
    56     {   
       
    57     }
       
    58     
       
    59 /**
       
    60 Provides the ID of the data provider responsible for the object.
       
    61 @return The ID of the data provider responsible for the object.
       
    62 */
       
    63 TUint8 TMTPTypeObjectHandle::DpId() const
       
    64     {
       
    65     return (Value() & KDpMask) >> KObjectIdWidth;
       
    66     }
       
    67 
       
    68 /**
       
    69 Provides the DP's unique object ID for the object.
       
    70 @return The object's unique DP ID.
       
    71 */
       
    72 TUint32 TMTPTypeObjectHandle::DPObjectId() const
       
    73     {
       
    74     return Value() & ~KDpMask;
       
    75     }
       
    76 
       
    77 /**
       
    78 Encodes the given data provider ID into the top eight bits of this data type
       
    79 
       
    80 @param aDp The ID of the data provider responsible for the object.
       
    81 */
       
    82 void TMTPTypeObjectHandle::SetDPHandle(TUint8 aDp)
       
    83     {
       
    84     Set(Value() | (aDp << KObjectIdWidth));
       
    85     }