os/persistentdata/traceservices/tracefw/ulogger/src/pluginframework/pluginallocator.cpp
Update contrib.
1 // Copyright (c) 2007-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include "pluginallocator.h"
18 #include "uloggeroutputplugin.h"
20 #include <ecom/ecom.h>
25 /*!Default constructor.
27 CPluginAllocator::CPluginAllocator()
29 iOutputPluginBase = NULL;
30 iInputPluginBase = NULL;
36 EXPORT_C CPluginAllocator::~CPluginAllocator()
40 delete iOutputPluginBase;
41 iOutputPluginBase = NULL;
45 if((iOutputLibName.Compare(iInputLibName)!=0) && iInputPluginBase)
47 delete iInputPluginBase;
48 iInputPluginBase = NULL;
52 REComSession::FinalClose();
56 /*!Standard Symbian OS construction method which leaves object on CleanupStack.
58 EXPORT_C CPluginAllocator* CPluginAllocator::NewLC(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName)
60 CPluginAllocator* obj = new (ELeave) CPluginAllocator();
61 CleanupStack::PushL(obj);
62 obj->ConstructL(aOutputPluginName, aInputPluginName);
67 /*!Standard Symbian OS construction method which does not leaves object on CleanupStack.
69 EXPORT_C CPluginAllocator* CPluginAllocator::NewL(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName)
71 CPluginAllocator* obj = CPluginAllocator::NewLC(aOutputPluginName, aInputPluginName);
72 CleanupStack::Pop(); //obj
77 /*!Standard Symbian OS construction method.
79 EXPORT_C void CPluginAllocator::ConstructL(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName)
81 //create output and control channels
82 User::LeaveIfError(this->CreateChannelsL(aOutputPluginName, aInputPluginName));
85 /*!This function create Output channel according to aOutputSettings.
87 TInt CPluginAllocator::CreateChannelsL(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName)
89 TInt retVal = KErrNone;
91 iOutputLibName.Copy(aOutputPluginName);
92 iInputLibName.Copy(aInputPluginName);
94 //create output plugin
95 iOutputPluginBase = (CPlugin*)(CPlugin::NewL(aOutputPluginName));
97 //create control plugin
98 if(iOutputLibName.Compare(iInputLibName) == 0)
100 //share implementation
101 if(aInputPluginName.Length()>0)
102 iInputPluginBase = iOutputPluginBase;
106 //create new instance of control plugin
107 //ulogger can work without control plugin as this is optional functionality
108 if(aInputPluginName.Length()>0)
109 iInputPluginBase = (CPlugin*)(CPlugin::NewL(aInputPluginName));
116 EXPORT_C MOutputPlugin* CPluginAllocator::GetOutputPlugin()
118 if(iOutputPluginBase)
119 return (MOutputPlugin*)iOutputPluginBase->GetInterfaceL(MOutputPlugin::iInterfaceId);
124 EXPORT_C MInputPlugin* CPluginAllocator::GetInputPlugin()
127 return (MInputPlugin*)iInputPluginBase->GetInterfaceL(MInputPlugin::iInterfaceId);
132 EXPORT_C void CPluginAllocator::ListAllImplementationsL(RImplInfoPtrArray& aImplInfoArray)
134 REComSession::ListImplementationsL(KCPluginUid, aImplInfoArray);
137 } //</namespace Ulogger>