locationrequestmgmt/locationserver/src/EPos_CPosSubsessionRegistry.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2005-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 
       
    18 // INCLUDE FILES
       
    19 #include <e32base.h>
       
    20 #include "EPos_CPosSubsessionRegistry.h"
       
    21 #include "EPos_CPosSubSession.h"
       
    22 
       
    23 // ================= MEMBER FUNCTIONS =======================
       
    24 
       
    25 /**
       
    26 * C++ default constructor.
       
    27 */
       
    28 CPosSubsessionRegistry::CPosSubsessionRegistry()
       
    29     {
       
    30     }
       
    31 
       
    32 /**
       
    33  * Symbian constructor
       
    34  */
       
    35 void CPosSubsessionRegistry::ConstructL()
       
    36     {
       
    37     iRegistryIndex = CObjectIx::NewL();
       
    38     iRegistryContainerIndex = CObjectConIx::NewL();
       
    39     iRegistryContainer = iRegistryContainerIndex->CreateL();
       
    40     }
       
    41 
       
    42 /**
       
    43  * Two-phased constructor
       
    44  *
       
    45  * @return a new instance of this class
       
    46  */
       
    47 CPosSubsessionRegistry* CPosSubsessionRegistry::NewL()
       
    48     {
       
    49     CPosSubsessionRegistry* self = new (ELeave) CPosSubsessionRegistry;
       
    50     CleanupStack::PushL(self);
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop(self);
       
    53     return self;
       
    54     }
       
    55 
       
    56 /**
       
    57  * C++ destructor
       
    58  */
       
    59 CPosSubsessionRegistry::~CPosSubsessionRegistry()
       
    60     {
       
    61     delete iRegistryIndex;
       
    62     delete iRegistryContainerIndex;
       
    63     iRegistryContainer = NULL; // deleted by index
       
    64     }
       
    65 
       
    66 /**
       
    67  * Retreives the appropriate subsession.
       
    68  *
       
    69  * @param aHandle the subsession handle
       
    70  * @return a subsession
       
    71  */
       
    72 CPosSubSession* CPosSubsessionRegistry::SubSessionFromHandleL(TUint aHandle)
       
    73     {
       
    74     return static_cast<CPosSubSession*> (iRegistryIndex->At(aHandle));
       
    75     }
       
    76 
       
    77 /**
       
    78  * Retreives the appropriate subsession.
       
    79  *
       
    80  * @param aIndex the index in the list
       
    81  * @return a subsession, NULL if no session at specified index.
       
    82  */
       
    83 CPosSubSession* CPosSubsessionRegistry::SubSessionFromIndex(TInt aIndex)
       
    84     {
       
    85     return static_cast<CPosSubSession*> ((*iRegistryIndex)[aIndex]);
       
    86     }
       
    87 
       
    88 /**
       
    89  * Returns the maximum number of reference counting 
       
    90 	* objects that the object index can hold before 
       
    91 	* internal buffers need to be expanded.
       
    92  * @return the maximum number of reference counting objects.
       
    93  */
       
    94 TInt CPosSubsessionRegistry::Count()
       
    95     {
       
    96     return iRegistryIndex->Count();
       
    97     }
       
    98 
       
    99 /**
       
   100  * Closes a subsession.
       
   101  *
       
   102  * @param aHandle a handle to the subsession
       
   103  */
       
   104 void CPosSubsessionRegistry::CloseSubSession(TUint aHandle)
       
   105     {
       
   106     if (iRegistryIndex->At(aHandle))
       
   107         {
       
   108         // Remove on a CObjectIx does close on the CObject
       
   109         iRegistryIndex->Remove(aHandle);
       
   110         }
       
   111     }
       
   112 
       
   113 /**
       
   114  * Adds an object instance to the registry and
       
   115  * transfers object ownership to the registry.
       
   116  *
       
   117  * @param aSubSession an object instance
       
   118  * @return a registry handle to the object instance.
       
   119  */
       
   120 TInt CPosSubsessionRegistry::AddInstanceL(CPosSubSession* aSubSession)
       
   121     {
       
   122     iRegistryContainer->AddL(aSubSession);
       
   123     return iRegistryIndex->AddL(aSubSession);
       
   124     }
       
   125 
       
   126 // End of File