landmarks/locationlandmarks/server/src/EPos_CPosLmSubsessionRegistry.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 27 Apr 2010 17:05:00 +0300
branchRCL_3
changeset 10 d6e4203b7ebe
parent 0 667063e416a2
permissions -rw-r--r--
Revision: 201015 Kit: 201017

/*
* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: Class to handle registration and unregistration of subsessions.
*
*
*/


#include "EPos_CPosLmSubsessionRegistry.h"
#include "EPos_CPosLmSubsessionBase.h"

// -----------------------------------------------------------------------------
// CPosLmSubsessionRegistry::CPosLmSubsessionRegistry
// C++ default constructor can NOT contain any code, that
// might leave.
// -----------------------------------------------------------------------------
//
CPosLmSubsessionRegistry::CPosLmSubsessionRegistry()
    {
    }

// -----------------------------------------------------------------------------
// CPosLmSubsessionRegistry::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CPosLmSubsessionRegistry::ConstructL()
    {
    iRegistryIndex = CObjectIx::NewL();
    iRegistryContainerIndex = CObjectConIx::NewL();
    iRegistryContainer = iRegistryContainerIndex->CreateL();
    }

// -----------------------------------------------------------------------------
// CPosLmSubsessionRegistry::NewL
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CPosLmSubsessionRegistry* CPosLmSubsessionRegistry::NewL()
    {
    CPosLmSubsessionRegistry* self = new (ELeave) CPosLmSubsessionRegistry;
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }

// Destructor
CPosLmSubsessionRegistry::~CPosLmSubsessionRegistry()
    {
    delete iRegistryIndex;
    delete iRegistryContainerIndex;
    iRegistryContainer = NULL; // deleted by index
    }

// -----------------------------------------------------------------------------
// CPosLmSubsessionRegistry::SubsessionFromHandleL
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
CPosLmSubsessionBase* CPosLmSubsessionRegistry::SubsessionFromHandleL(
    TUint aHandle)
    {
    return static_cast<CPosLmSubsessionBase*>(iRegistryIndex->At(aHandle));
    }

// -----------------------------------------------------------------------------
// CPosLmSubsessionRegistry::SubsessionFromIndex
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
CPosLmSubsessionBase* CPosLmSubsessionRegistry::SubsessionFromIndex(
    TInt aIndex)
    {
    return static_cast<CPosLmSubsessionBase*>((*iRegistryIndex)[aIndex]);
    }

// -----------------------------------------------------------------------------
// CPosLmSubsessionRegistry::Count
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt CPosLmSubsessionRegistry::Count()
    {
    return iRegistryContainer->Count();
    }

// -----------------------------------------------------------------------------
// CPosLmSubsessionRegistry::CloseSubsession
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt CPosLmSubsessionRegistry::CloseSubsession(
    TUint aHandle)
    {
    if (iRegistryIndex->At(aHandle))
        {
        // Remove on a CObjectIx does close on the CObject
        iRegistryIndex->Remove(aHandle);
        return KErrNone;
        }
    return KErrNotFound;
    }

// -----------------------------------------------------------------------------
// CPosLmSubsessionRegistry::AddInstanceL
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt CPosLmSubsessionRegistry::AddInstanceL(
    CPosLmSubsessionBase* aSubsession)
    {
    iRegistryContainer->AddL(aSubsession);
    return iRegistryIndex->AddL(aSubsession);
    }

//  End of File