os/persistentdata/persistentstorage/sql/SRC/Server/SqlSrvObjContainer.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef __SQLSRVOBJCONTAINER_H__
sl@0
    17
#define __SQLSRVOBJCONTAINER_H__
sl@0
    18
sl@0
    19
#include <e32std.h>
sl@0
    20
#include "SqlAssert.h"
sl@0
    21
sl@0
    22
/**
sl@0
    23
Indexed storage for server sdide objects.
sl@0
    24
sl@0
    25
RDbObjContainer container is used for storing IPC stream handles (HIpcStream) and 
sl@0
    26
statement handles (CSqlSrvStatement).
sl@0
    27
sl@0
    28
Behaviour when the container is destroyed:
sl@0
    29
 - all objects inside the container are destroyed too;
sl@0
    30
 
sl@0
    31
Behaviour when the an object is removed from the container:
sl@0
    32
 - the container will destroy the object;
sl@0
    33
sl@0
    34
Behaviour when the an object is added to the container:
sl@0
    35
 - the container stores the object <by_ref>, not <by_val>;
sl@0
    36
sl@0
    37
Behaviour when a look up is performed in the container for an object:
sl@0
    38
 - a pointer to the object is returned or NULL if there is no object;
sl@0
    39
sl@0
    40
@see CSqlSrvStatement
sl@0
    41
@see HIpcStream
sl@0
    42
@see RDbObjContainer::Close()
sl@0
    43
@see RDbObjContainer::AllocL()
sl@0
    44
@see RDbObjContainer::Add()
sl@0
    45
@see RDbObjContainer::Remove()
sl@0
    46
@see RDbObjContainer::Find()
sl@0
    47
@see RDbObjContainer::Count()
sl@0
    48
sl@0
    49
@internalComponent
sl@0
    50
*/
sl@0
    51
template <class T> class RDbObjContainer
sl@0
    52
	{
sl@0
    53
public:
sl@0
    54
	RDbObjContainer();
sl@0
    55
	void Close();
sl@0
    56
	void AllocL();
sl@0
    57
	TInt Add(T* aObj);
sl@0
    58
	void Remove(TInt aHandle);
sl@0
    59
	T* Find(TInt aHandle) const;
sl@0
    60
	TInt Count() const;
sl@0
    61
sl@0
    62
private:	
sl@0
    63
	TInt MakeHandle(TInt aIndex) const;
sl@0
    64
	TInt MakeIndex(TInt aHandle) const;
sl@0
    65
	
sl@0
    66
private:	
sl@0
    67
	struct TEntry
sl@0
    68
		{
sl@0
    69
		T*		iObj;
sl@0
    70
		TInt	iNext;
sl@0
    71
		};
sl@0
    72
	enum {KGranularity = 16};
sl@0
    73
	//KMaxSize value depends on how many bits are used for handles - see
sl@0
    74
	//KStmtHandleMask and KStreamHandleMask in SqlUtil.h file.
sl@0
    75
	enum {KMaxSize = 0x7FF};
sl@0
    76
	TEntry*	iEntries;
sl@0
    77
	TInt	iSize;
sl@0
    78
	TInt 	iFree;
sl@0
    79
	};
sl@0
    80
sl@0
    81
#include "SqlSrvObjContainer.inl"
sl@0
    82
sl@0
    83
#endif//__SQLSRVOBJCONTAINER_H__