diff -r 8ee96d21d9bf -r 7e0eff37aedb controlpanel/src/logger/src/logoutputfactory.cpp --- a/controlpanel/src/logger/src/logoutputfactory.cpp Tue Aug 31 15:29:50 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* -* 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: Factory class to create LogOutput. -* -*/ -#include -#include -#include -#include -#include "logoutput.h" -#include "loglogger.h" - -typedef QHash CreateEntryContainer; - -Q_GLOBAL_STATIC(CreateEntryContainer, theCreateEntryList) - -static QString formalizeName(const QString &name) -{ - QString formalName = name; - formalName.toLower(); - formalName = formalName.trimmed(); - return formalName; -} - -LogOutput *LogOutputFactory::createLogOutput(const QString &name) -{ - return createLogOutput(name,QHash()); -} - -LogOutput *LogOutputFactory::createLogOutput(const QString &name, - const QHash &properties /*= QHash()*/) -{ - LogOutputFactory::CREATE_ENTRY entry = theCreateEntryList()->value(formalizeName(name)); - - LogOutput *output = entry ? (*entry)() : 0; - - if (output && !properties.isEmpty()) { - const QMetaObject *metaObj = output->metaObject(); - int count = metaObj->propertyCount(); - for (int i = 0; i < count; i++) { - QMetaProperty metaProperty = metaObj->property(i); - if (metaProperty.isValid() && metaProperty.isWritable()) { - QVariant var = properties.value(metaProperty.name()); - if (var.isValid()) { - metaProperty.write(output,var); - } - } - } - } - - return output; -} - -void LogOutputFactory::addCreateLogOutputEntry(const QString &name,CREATE_ENTRY entry) -{ - if (!entry) { - return; - } - - QString formalName = formalizeName(name); - - if (theCreateEntryList()->value(formalName)) { - LOGGER_LOG(QString("LogOutputFactory::addCreateLogOutputEntry << ") - + QString("create entry with the name:") + formalName + QString("already exists.")); - return; - } - - theCreateEntryList()->insert(formalName,entry); -}