usbmgmt/usbmgr/device/classcontroller/SRC/CUsbClassControllerBase.cpp
changeset 0 c9bc50fca66e
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 /*
       
     2 * Copyright (c) 1997-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 * Implements part of UsbMan USB Class Controller Framework.
       
    16 * All USB classes to be managed by UsbMan must derive
       
    17 * from this class.
       
    18 *
       
    19 */
       
    20 
       
    21 /**
       
    22  @file
       
    23 */
       
    24 
       
    25 #include <cusbclasscontrollerbase.h>
       
    26 #include <musbclasscontrollernotify.h>
       
    27 
       
    28 
       
    29 /**
       
    30  * Constructor.
       
    31  *
       
    32  * @param aOwner Owner and manager of this object
       
    33  * @param aStartupPriority The priority of the Class Controller (the 
       
    34  * priorities of all present Class Controllers determines the order in which 
       
    35  * they are started).
       
    36  */
       
    37 EXPORT_C CUsbClassControllerBase::CUsbClassControllerBase(
       
    38 	MUsbClassControllerNotify& aOwner, TInt aStartupPriority)
       
    39 	: CActive(EPriorityStandard), iStartupPriority(aStartupPriority),
       
    40 	  iState(EUsbServiceIdle), iOwner(aOwner)
       
    41 	{
       
    42 	CActiveScheduler::Add(this);
       
    43 	}
       
    44 
       
    45 /**
       
    46  * Destructor.
       
    47  */
       
    48 EXPORT_C CUsbClassControllerBase::~CUsbClassControllerBase()
       
    49 	{
       
    50 	}
       
    51 
       
    52 /**
       
    53  * Fetch the owner of the USB class controller.
       
    54  *
       
    55  * @return	The owner of the USB class controller
       
    56  */
       
    57 EXPORT_C MUsbClassControllerNotify& CUsbClassControllerBase::Owner() const
       
    58 	{
       
    59 	return iOwner;
       
    60 	}
       
    61 
       
    62 /**
       
    63  * Get the state of this USB class controller.
       
    64  *
       
    65  * @return	The state of this USB class controller
       
    66  */
       
    67 EXPORT_C TUsbServiceState CUsbClassControllerBase::State() const
       
    68 	{
       
    69 	return iState;
       
    70 	}
       
    71 
       
    72 /**
       
    73  * Get the startup priority of this USB class controller.
       
    74  *
       
    75  * @return	The startup priority of this USB class controller
       
    76  */
       
    77 EXPORT_C TInt CUsbClassControllerBase::StartupPriority() const
       
    78 	{
       
    79 	return iStartupPriority;
       
    80 	}
       
    81 
       
    82 EXPORT_C TInt CUsbClassControllerBase::Compare(const CUsbClassControllerBase& aFirst,
       
    83 	const CUsbClassControllerBase& aSecond)
       
    84 	{
       
    85 	if (aFirst.StartupPriority() < aSecond.StartupPriority()) {
       
    86 		return -1;
       
    87 	}
       
    88 	else if (aFirst.StartupPriority() > aSecond.StartupPriority()) {
       
    89 		return 1;
       
    90 	}
       
    91 	return 0;
       
    92 	}
       
    93