os/persistentdata/traceservices/tracefw/ulogger/src/pluginframework/outputframework.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "outputframework.h"
    17 #include "uloggeroutputplugin.h" // MOutputPlugin, ...
    18 
    19 
    20 namespace Ulogger
    21 {
    22 /** Static Factory Construction 
    23 @param aOutputPlugin the output plugin reference. This plugin will be used to send data.
    24 @return a pointer to the created object
    25 @leave KErrNoMemory if not enough memory available
    26 */
    27 EXPORT_C COutputFramework* COutputFramework::NewL(MOutputPlugin& aOutputPlugin, const RPointerArray<TPluginConfiguration>& aOutputSettings)
    28 	{
    29 	COutputFramework* me = new (ELeave) COutputFramework(aOutputPlugin);
    30 	CleanupStack::PushL(me);
    31 	me->ConstructL(aOutputSettings);
    32 	CleanupStack::Pop();
    33 	return me;
    34 	}
    35 
    36 /**
    37 Public Destructor 
    38 */
    39 EXPORT_C COutputFramework::~COutputFramework()
    40 	{
    41 	iOutputPlugin.CloseOutputPlugin();
    42 	iOutputSettings.ResetAndDestroy();
    43 	iOutputSettings.Close();
    44 	}
    45 
    46 /*!This function send data trough active output channel.
    47 @param aData reference to data
    48 @return KErrNone if successfull otherwise Symbian OS error code
    49 */
    50 EXPORT_C TInt COutputFramework::SendData(const TDesC8& aData)
    51 	{
    52 	return iOutputPlugin.Write(aData);
    53 	}
    54 
    55 //Default constructor
    56 COutputFramework::COutputFramework(MOutputPlugin& aOutputPlugin) 
    57 : iOutputPlugin(aOutputPlugin)
    58 	{
    59 	}
    60 	
    61 //Second stage constructL function
    62 //This will create a local mutex and initialize all the channels
    63 void COutputFramework::ConstructL(const RPointerArray<TPluginConfiguration>& aOutputSettings)
    64 	{	
    65 	//copy settings
    66 	for(TInt i=0; i<aOutputSettings.Count(); ++i)
    67 		{
    68 		TPluginConfiguration* pluginConfig = new TPluginConfiguration();
    69 		pluginConfig->SetKey(aOutputSettings[i]->Key());
    70 		pluginConfig->SetValue(aOutputSettings[i]->Value());
    71 		iOutputSettings.AppendL(pluginConfig);
    72 		}
    73 	
    74 	User::LeaveIfError(iOutputPlugin.ConfigureOutputPlugin(iOutputSettings));
    75 	}
    76 
    77 /**Unconfigure active output channel and release all locked resources.
    78 */
    79 EXPORT_C void COutputFramework::ReleaseOutputResources()
    80 	{
    81 	iOutputPlugin.CloseOutputPlugin();
    82 	}
    83 
    84 } // namespace