traceservices/tracefw/ulogger/src/pluginframework/outputframework.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 16:57:14 +0300
branchRCL_3
changeset 23 26645d81f48d
parent 0 08ec8eefde2f
permissions -rw-r--r--
Revision: 201035 Kit: 201035

// Copyright (c) 2007-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 "outputframework.h"
#include "uloggeroutputplugin.h" // MOutputPlugin, ...


namespace Ulogger
{
/** Static Factory Construction 
@param aOutputPlugin the output plugin reference. This plugin will be used to send data.
@return a pointer to the created object
@leave KErrNoMemory if not enough memory available
*/
EXPORT_C COutputFramework* COutputFramework::NewL(MOutputPlugin& aOutputPlugin, const RPointerArray<TPluginConfiguration>& aOutputSettings)
	{
	COutputFramework* me = new (ELeave) COutputFramework(aOutputPlugin);
	CleanupStack::PushL(me);
	me->ConstructL(aOutputSettings);
	CleanupStack::Pop();
	return me;
	}

/**
Public Destructor 
*/
EXPORT_C COutputFramework::~COutputFramework()
	{
	iOutputPlugin.CloseOutputPlugin();
	iOutputSettings.ResetAndDestroy();
	iOutputSettings.Close();
	}

/*!This function send data trough active output channel.
@param aData reference to data
@return KErrNone if successfull otherwise Symbian OS error code
*/
EXPORT_C TInt COutputFramework::SendData(const TDesC8& aData)
	{
	return iOutputPlugin.Write(aData);
	}

//Default constructor
COutputFramework::COutputFramework(MOutputPlugin& aOutputPlugin) 
: iOutputPlugin(aOutputPlugin)
	{
	}
	
//Second stage constructL function
//This will create a local mutex and initialize all the channels
void COutputFramework::ConstructL(const RPointerArray<TPluginConfiguration>& aOutputSettings)
	{	
	//copy settings
	for(TInt i=0; i<aOutputSettings.Count(); ++i)
		{
		TPluginConfiguration* pluginConfig = new TPluginConfiguration();
		pluginConfig->SetKey(aOutputSettings[i]->Key());
		pluginConfig->SetValue(aOutputSettings[i]->Value());
		iOutputSettings.AppendL(pluginConfig);
		}
	
	User::LeaveIfError(iOutputPlugin.ConfigureOutputPlugin(iOutputSettings));
	}

/**Unconfigure active output channel and release all locked resources.
*/
EXPORT_C void COutputFramework::ReleaseOutputResources()
	{
	iOutputPlugin.CloseOutputPlugin();
	}

} // namespace