taskswitcher/server/src/tsservicesprovider.cpp
changeset 117 c63ee96dbe5f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsservicesprovider.cpp	Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+
+#include "tsservicesprovider.h"
+#include "tsservice.h"
+// -----------------------------------------------------------------------------
+CTsServiceProvider* CTsServiceProvider::NewL(const CTsServiceProviderConfig& config)
+{
+    CTsServiceProvider* self = new (ELeave)CTsServiceProvider();
+    self->Construct(config);
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+CTsServiceProvider::CTsServiceProvider()
+{
+    //No implementation required
+}
+
+// -----------------------------------------------------------------------------
+void CTsServiceProvider::Construct(const CTsServiceProviderConfig& config)
+{
+    CTsService* srvPtr(0);
+    for (TInt iter(0); iter < config.count(); ++iter) {
+        TRAP_IGNORE(
+        srvPtr = CTsService::NewLC(config.loadL(iter));
+        mServices.AppendL(srvPtr);
+        CleanupStack::Pop(srvPtr);
+        );
+    }
+}
+
+// -----------------------------------------------------------------------------
+CTsServiceProvider::~CTsServiceProvider()
+{
+    mServices.ResetAndDestroy();
+}
+
+// -----------------------------------------------------------------------------
+MTsModel& CTsServiceProvider::operator[](TInt offset) const
+{
+    return *(mServices[offset]);
+}
+
+// -----------------------------------------------------------------------------
+TInt CTsServiceProvider::count() const
+{
+    return mServices.Count();
+}