memspy/Driver/Kernel/Source/MemSpyDriverObjectIx.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:37:10 +0100
branchRCL_3
changeset 21 52e343bb8f80
parent 20 ca8a1b6995f6
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include "MemSpyDriverObjectIx.h"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
// System includes
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <kern_priv.h>
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
//#include <dobject.h>
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
//const TInt KObjectIxGranularity=8;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
const TInt KObjectIndexMask=0x7fff;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
//const TInt KObjectMaxIndex=0x7fff;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
const TInt KObjectInstanceShift=16;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
const TInt KObjectInstanceMask=0x3fff;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
//const TInt KObjectIxMaxHandles=0x8000;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
inline TInt index(TInt aHandle)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
	{return(aHandle&KObjectIndexMask);}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
inline TInt instance(TInt aHandle)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
	{return((aHandle>>KObjectInstanceShift)&KObjectInstanceMask);}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
inline TInt instanceLimit(TInt& aCount)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
	{return ((aCount&KObjectInstanceMask)==0) ? ((++aCount)&KObjectInstanceMask) : aCount&KObjectInstanceMask;}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
inline TInt makeHandle(TInt aIndex, TInt aInstance)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
	{return((TInt)((aInstance<<KObjectInstanceShift)|aIndex));}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
enum TDObjectPanic
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
	{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
	EObjObjectStillReferenced,
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
	EObjNegativeAccessCount,
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
	EObjRemoveObjectNotFound,
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
	EObjRemoveContainerNotFound,
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
	EObjRemoveBadHandle,
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
	EObjFindBadHandle,
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
	EObjFindIndexOutOfRange,
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
	EDObjectConDestroyed,
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
	EArrayIndexOutOfRange,
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
	EObjInconsistent,
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
	};
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
inline void Panic(TDObjectPanic aPanic)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
	{ Kern::Fault("DOBJECT",aPanic); }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
	
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
#if MCL_ROBJECTIX_DUPLICATION
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
#define asserta(x)	do { if (!(x)) { __crash(); } } while(0)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
RMemSpyObjectIx::RMemSpyObjectIx()
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
  : iRWL(TSpinLock::EOrderGenericIrqLow3)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
    {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
    }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
void RMemSpyObjectIx::Wait()
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
	{
21
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
    70
//	Kern::MutexWait(*HandleMutex);
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
	} // RObjectIx::Wait
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
void RMemSpyObjectIx::Signal()
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
	{
21
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
    76
//	Kern::MutexSignal(*HandleMutex);
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
	} // RObjectIx::Signal
21
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
    78
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
DObject* RMemSpyObjectIx::operator[](TInt aIndex)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
	{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
	DObject* obj = 0;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
	AcquireReadLock();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
	asserta(TUint(aIndex)<TUint(iCount));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
	SSlot* slot = iSlots + aIndex;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
	obj = Occupant(slot);
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
	ReleaseReadLock();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
	return obj;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
	} // RObjectIx::operator[]
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
21
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
    92
TInt RMemSpyObjectIx::At(DObject* aObj)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
    93
	{
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
    94
	//Check preconditions(debug build only)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
    95
	__ASSERT_CRITICAL;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
    96
	__ASSERT_NO_FAST_MUTEX;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
    97
	//__ASSERT_MUTEX(HandleMutex);
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
    98
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
    99
	if (iState==ETerminated)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   100
		{
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   101
		return KErrNotFound;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   102
		}
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   103
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   104
	TInt h = KErrNotFound;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   105
	AcquireWriteLock();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   106
	iState = (TUint8)ESearching;		// enable monitoring of new handles
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   107
	iModList.iMonitor.iObj = aObj;		// object to check for
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   108
	iModList.iMonitor.iBoundary = 0;	// will change if aObj is added to a slot before this point
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   109
	TInt pos = 0;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   110
	while (pos<iCount && iActiveCount)	// stop if index empty
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   111
		{
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   112
		TInt limit = pos + EMaxLockedIter;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   113
		if (limit>iCount)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   114
			{
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   115
			limit = iCount;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   116
			}
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   117
		while (pos<limit)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   118
			{
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   119
			SSlot* slot = iSlots + pos;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   120
			if (Occupant(slot) == aObj)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   121
				{
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   122
				// found it, finish
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   123
				h = MakeHandle(pos, slot->iUsed.iAttr);
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   124
				break;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   125
				}
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   126
			pos++;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   127
			}
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   128
		if (h>0)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   129
			{
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   130
			break;	// found it, finish
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   131
			}
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   132
		iModList.iMonitor.iBoundary = pos;	// will change if aObj is added to a slot already checked
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   133
		ReleaseWriteLock();	// let other threads in
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   134
		AcquireWriteLock();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   135
		pos = iModList.iMonitor.iBoundary;	// next position to check
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   136
		}
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   137
	iState = (TUint8)ENormal;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   138
	ReleaseWriteLock();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   139
	return h;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   140
	} // RObjectIx::At
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   141
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   142
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   143
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   144
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   145
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   146
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
#elif MCL_DOBJECTIX_DUPLICATION
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
21
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   149
void DMemSpyObjectIx::Wait( DMemSpyObjectIx* /*aObjectIndex*/ )
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
	{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
//	Kern::MutexWait(*aObjectIndex->HandleMutex);
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
	}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
21
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   154
void DMemSpyObjectIx::Signal( DMemSpyObjectIx* /*aObjectIndex*/ )
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
	{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
//	Kern::MutexSignal(*aObjectIndex->HandleMutex);
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
	}
21
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   158
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
/** Counts the number of times an object appears in this index.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
	@param	aObject	Object whose occurrences are to be counted.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
	@return	Number of times aObject appears in the index.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
    @pre    Calling thread must be in a critical section.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    @pre    No fast mutex can be held.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
	@pre	Call in a thread context.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
	@pre	DObject::HandleMutex held
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
 */
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
TInt DMemSpyObjectIx::Count(DObject* aObject)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
	{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
	//Check preconditions(debug build only)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
	__ASSERT_CRITICAL;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
	__ASSERT_NO_FAST_MUTEX;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
	TInt c=0;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
	if (iCount)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
		{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
		SDObjectIxRec* pS=iObjects;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
		SDObjectIxRec* pE=pS+iCount;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
		do
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
			{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
			if (pS->obj==aObject)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
				c++;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
			} while (++pS<pE);
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
		}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
	return c;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
	}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
/**	Looks up an object in the index by handle.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
	
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
	The object must be of a specified type (specified by container ID)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
	@param	aHandle		Handle to look up.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
	@param	aUniqueID	Unique ID (container ID) that object should have.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
	
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
	@return	Pointer to object or NULL if handle invalid.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
	@pre	Call in a thread context.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
	@pre    System lock must be held.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
 */
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
DObject* DMemSpyObjectIx::At(TInt aHandle, TInt aUniqueID)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
	{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
	__ASSERT_SYSTEM_LOCK; //Check preconditions (debug build only)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
	TInt i=index(aHandle);
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
	if (i>=iCount)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
		return(NULL);
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
	SDObjectIxRec *pS=iObjects+i;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
	if (pS->str.instance!=instance(aHandle) || pS->str.uniqueID!=aUniqueID)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
		return(NULL);
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
	return(pS->obj);
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
	}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
/**	Looks up an object in the index by handle.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
	The object may be of any type.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
	@param	aHandle		Handle to look up.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
	
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
	@return	Pointer to object or NULL if handle invalid.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
	@pre	Call in a thread context.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
	@pre    System lock must be held.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
 */
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
DObject* DMemSpyObjectIx::At(TInt aHandle)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
	{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
	__ASSERT_SYSTEM_LOCK; //Check preconditions (debug build only)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
	TInt i=index(aHandle);
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
	if (i>=iCount)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
		return NULL;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
	SDObjectIxRec *pS=iObjects+i;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
	if (pS->str.instance!=instance(aHandle))
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
		return NULL;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
	return pS->obj;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
	}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
21
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   240
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   241
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   242
/**	Looks up an object in the index by object pointer.
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   243
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   244
	Returns a handle to the object.
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   245
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   246
	@param	aObj	Pointer to the object to look up.
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   247
	
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   248
	@return	Handle to object (always >0);
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   249
	        KErrNotFound, if object not present in index.
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   250
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   251
    @pre    Calling thread must be in a critical section.
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   252
    @pre    No fast mutex can be held.
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   253
	@pre	Call in a thread context.
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   254
	@pre	DObject::HandleMutex held.
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   255
 */
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   256
TInt DMemSpyObjectIx::At(DObject* aObj)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   257
	{
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   258
	//Check preconditions(debug build only)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   259
	__ASSERT_CRITICAL;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   260
	__ASSERT_NO_FAST_MUTEX;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   261
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   262
	if (iCount)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   263
		{
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   264
		SDObjectIxRec* pS=iObjects;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   265
		SDObjectIxRec* pE=pS+iCount;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   266
		TInt i=0;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   267
		while(pS<pE && pS->obj!=aObj)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   268
			pS++, i++;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   269
		if (pS<pE)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   270
			return(makeHandle(i,pS->str.instance));
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   271
		}
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   272
	return KErrNotFound;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   273
	}
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   274
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 20
diff changeset
   275
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
/** Finds the object at a specific position in the index array.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
	@param	aIndex	Index into array.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
	
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
	@return	Pointer to the object at that position (could be NULL).
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
	@pre	Call in a thread context. 
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
    @pre    System lock must be held.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
 */
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
DObject* DMemSpyObjectIx::operator[](TInt aIndex)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
	{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
	__ASSERT_SYSTEM_LOCK; //Check preconditions (debug build only)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
	__ASSERT_ALWAYS(aIndex>=0 && aIndex<iCount,Panic(EArrayIndexOutOfRange));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
	return iObjects[aIndex].obj;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
	}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
#endif
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293