diff -r 000000000000 -r 08ec8eefde2f loggingservices/eventlogger/LogCli/src/LogChangeDefinition.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loggingservices/eventlogger/LogCli/src/LogChangeDefinition.cpp Fri Jan 22 11:06:30 2010 +0200 @@ -0,0 +1,241 @@ +// Copyright (c) 2002-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 "LogChangeDefinition.h" + +// User includes +#include "logclipanic.h" + + +///////////////////////////////////////////////////////////////////////////////////////// +// -----> CLogChangeDefinition (source) +///////////////////////////////////////////////////////////////////////////////////////// + +CLogChangeDefinition::CLogChangeDefinition(TInt aGranularity) +: iChanges(aGranularity) + { + } + +EXPORT_C CLogChangeDefinition::~CLogChangeDefinition() + { + iChanges.Close(); + } + +void CLogChangeDefinition::ConstructL(const CLogChangeDefinition& aCopy) + { + const TInt count = aCopy.Count(); + for(TInt i=0; iConstructL(aCopy); + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CLogChangeDefinition* CLogChangeDefinition::NewL(RReadStream& aStream) + { + CLogChangeDefinition* self = new(ELeave) CLogChangeDefinition(KLogChangeDefinitionDefaultGranularity); + CleanupStack::PushL(self); + aStream >> *self; + CleanupStack::Pop(self); + return self; + } + +///////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////// + +EXPORT_C TInt CLogChangeDefinition::Count() const + { + return iChanges.Count(); + } + +EXPORT_C TLogDatabaseChangeType CLogChangeDefinition::At(TInt aIndex) const + { + const TLogShdChangeDetails& entry = iChanges[aIndex]; + return entry.iType; + } + +EXPORT_C TLogDatabaseChangeType CLogChangeDefinition::At(TInt aIndex, TLogId& aId) const + { + const TLogShdChangeDetails& entry = iChanges[aIndex]; + aId = entry.iId; + return entry.iType; + } + +EXPORT_C TLogDatabaseChangeType CLogChangeDefinition::At(TInt aIndex, TLogId& aId, TInt& aViewIndex) const + { + const TLogShdChangeDetails& entry = iChanges[aIndex]; + aId = entry.iId; + aViewIndex = entry.iViewIndex; + return entry.iType; + } + +EXPORT_C TInt CLogChangeDefinition::Find(TLogId aId) const + { + // Linear search + const TLogShdChangeDetails entryToFind(aId); + TIdentityRelation relation(CompareEntryIds); + const TInt position = iChanges.Find(entryToFind, relation); + return position; + } + +EXPORT_C TInt CLogChangeDefinition::Find(TLogId aId, TLogDatabaseChangeType aType) const + { + // First try and find any log id regardless of change type + TInt position = Find(aId); + if (position >= 0) + { + const TInt count = iChanges.Count(); + + // Keep iterating through the changes until we + // + // a) Reach the end of the changes OR + // b) Reach a change corresponding to a different log id OR + // c) Find the change we're interested in + TInt i = position; + position = KErrNotFound; + // + for(; i relation(CompareViewIndicies); + const TInt position = iChanges.Find(entryToFind, relation); + return position; + } + +EXPORT_C void CLogChangeDefinition::AddL(TLogId aId, TLogDatabaseChangeType aType, TInt aViewIndex) + { + switch(aType) + { + case ELogChangeTypeEventChanged: + case ELogChangeTypeEventChangedHidden: + case ELogChangeTypeEventAdded: + case ELogChangeTypeEventDeleted: + case ELogChangeTypeLogCleared: + AddToContainerL(aId, aType, aViewIndex); + break; + // + default: + case ELogChangeTypeUndefined: + __ASSERT_ALWAYS(0, Panic(ELogUndefinedChangeType)); + break; + } + } + +EXPORT_C void CLogChangeDefinition::Reset() + { + iChanges.Reset(); + iChanges.GranularCompress(); + } + +///////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////// + +EXPORT_C void CLogChangeDefinition::InternalizeL(RReadStream& aStream) + { + TLogShdChangeDetails entry; + // + TCardinality count; + aStream >> count; + // + for(TInt i=0; i(aStream.ReadInt32L()); + entry.iType = static_cast(aStream.ReadUint8L()); + entry.iViewIndex = static_cast(aStream.ReadInt32L()); + // + User::LeaveIfError(iChanges.Append(entry)); + } + } + +EXPORT_C void CLogChangeDefinition::ExternalizeL(RWriteStream& aStream) const + { + TCardinality count = Count(); + aStream << count; + // + for(TInt i=0; i