os/persistentdata/persistentstorage/dbms/pcdbms/utable/UT_REC.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/dbms/pcdbms/utable/UT_REC.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,187 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "UT_STD.H"
    1.20 +
    1.21 +// Class CDbRecordBase
    1.22 +
    1.23 +EXPORT_C TBool CDbRecordBase::DoRestoreL()
    1.24 +//
    1.25 +// If we haven't been opened, then try to restore the state
    1.26 +//
    1.27 +	{
    1.28 +	TBool broken=RestoreL();
    1.29 +	iFlags|=broken ? EBroken : EOpen;
    1.30 +	return broken;
    1.31 +	}
    1.32 +
    1.33 +EXPORT_C void CDbRecordBase::TouchL()
    1.34 +//
    1.35 +// if we are not modified then mark
    1.36 +// Can touch a broken object, will not invoke AboutToModifyL()
    1.37 +//
    1.38 +	{
    1.39 +	__ASSERT(iFlags&(EOpen|EBroken));
    1.40 +	if (!(iFlags&EModified))
    1.41 +		{
    1.42 +		if (!(iFlags&EBroken))
    1.43 +			AboutToModifyL();
    1.44 +		iFlags|=EModified;
    1.45 +		}
    1.46 +	}
    1.47 +
    1.48 +EXPORT_C void CDbRecordBase::FlushL()
    1.49 +//
    1.50 +// If we are open, modified and not broken then flush
    1.51 +// Must allow un-opened Flush during framework cleanup on failed open
    1.52 +//
    1.53 +	{
    1.54 +	if (iFlags==(EOpen|EModified))
    1.55 +		{
    1.56 +		SynchL();
    1.57 +		iFlags&=~EModified;
    1.58 +		}
    1.59 +	}
    1.60 +
    1.61 +void CDbRecordBase::DoAbandon(CDbRecordBase* aRec)
    1.62 +	{
    1.63 +	aRec->Abandon();
    1.64 +	}
    1.65 +
    1.66 +void CDbRecordBase::DoFlushL(CDbRecordBase* aRec)
    1.67 +	{
    1.68 +	aRec->FlushL();
    1.69 +	}
    1.70 +
    1.71 +void CDbRecordBase::DoDelete(CDbRecordBase* aRec)
    1.72 +	{
    1.73 +	delete aRec;
    1.74 +	}
    1.75 +
    1.76 +EXPORT_C TBool CDbRecordBase::RestoreL()
    1.77 +//
    1.78 +// default to do nothing
    1.79 +//
    1.80 +	{
    1.81 +	return EFalse;
    1.82 +	}
    1.83 +
    1.84 +EXPORT_C void CDbRecordBase::AboutToModifyL()
    1.85 +//
    1.86 +// default to do nothing
    1.87 +//
    1.88 +	{}
    1.89 +
    1.90 +EXPORT_C void CDbRecordBase::SynchL()
    1.91 +//
    1.92 +// default to do nothing
    1.93 +//
    1.94 +	{}
    1.95 +
    1.96 +
    1.97 +// Class CDbRecordIter
    1.98 +
    1.99 +EXPORT_C CDbRecordIter::CDbRecordIter(CDbRecordBase& aHost)
   1.100 +	:iHost(aHost)
   1.101 +	{}
   1.102 +
   1.103 +EXPORT_C CDbRecordIter::~CDbRecordIter()
   1.104 +	{}
   1.105 +
   1.106 +
   1.107 +// Class CDbRecordSpace
   1.108 +
   1.109 +TUint8* CDbRecordSpace::ReplaceL(TDbRecordId aRecordId,TInt aRecordSize)
   1.110 +	{
   1.111 +	__ASSERT(!IsBroken());
   1.112 +	TouchL();
   1.113 +	return DoReplaceL(aRecordId,aRecordSize);
   1.114 +	}
   1.115 +
   1.116 +TUint8* CDbRecordSpace::NewL(TInt aRecordSize)
   1.117 +	{
   1.118 +	__ASSERT(!IsBroken());
   1.119 +	TouchL();
   1.120 +	return DoNewL(aRecordSize);
   1.121 +	}
   1.122 +
   1.123 +void CDbRecordSpace::EraseL(TDbRecordId aRecordId)
   1.124 +	{
   1.125 +	__ASSERT(!IsBroken());
   1.126 +	TouchL();
   1.127 +	DoEraseL(aRecordId);
   1.128 +	}
   1.129 +
   1.130 +// Class CDbBlobSpace
   1.131 +
   1.132 +EXPORT_C MStreamBuf* CDbBlobSpace::ReadLC(TDbBlobId aBlobId,TDbColType aType) const
   1.133 +	{
   1.134 +	MStreamBuf* buf=ReadL(aBlobId,aType);
   1.135 +	buf->PushL();
   1.136 +	return buf;
   1.137 +	}
   1.138 +
   1.139 +EXPORT_C MStreamBuf* CDbBlobSpace::CreateL(TDbBlobId &aBlobId,TDbColType aType)
   1.140 +	{
   1.141 +	__ASSERT(!IsBroken());
   1.142 +	TouchL();
   1.143 +	return DoCreateL(aBlobId,aType);
   1.144 +	}
   1.145 +
   1.146 +EXPORT_C TDbBlobId CDbBlobSpace::CreateL(TDbColType aType,const TAny* aData,TInt aLength)
   1.147 +//
   1.148 +// Create a blob containing the data buffer
   1.149 +//
   1.150 +	{
   1.151 +	TDbBlobId id;
   1.152 +	MStreamBuf* buf=CreateL(id,aType);
   1.153 +	buf->PushL();
   1.154 +	buf->WriteL(aData,aLength);
   1.155 +	buf->SynchL();
   1.156 +	CleanupStack::PopAndDestroy();
   1.157 +	return id;
   1.158 +	}
   1.159 +
   1.160 +EXPORT_C void CDbBlobSpace::DeleteL(TDbBlobId aBlobId)
   1.161 +	{
   1.162 +	if (aBlobId!=KDbNullBlobId)
   1.163 +		{
   1.164 +		__ASSERT(!IsBroken());
   1.165 +		TouchL();
   1.166 +		DoDeleteL(aBlobId);
   1.167 +		}
   1.168 +	}
   1.169 +
   1.170 +EXPORT_C TInt CDbBlobSpace::Delete(TDbBlobId aBlobId)
   1.171 +	{
   1.172 +	TRAPD(r,DeleteL(aBlobId));
   1.173 +	return r;
   1.174 +	}
   1.175 +
   1.176 +// Class CDbRecordIndex
   1.177 +
   1.178 +TBool CDbRecordIndex::InsertL(TDbRecordId aRecordId,const RDbTableRow& aRow)
   1.179 +	{
   1.180 +	__ASSERT(!IsBroken());
   1.181 +	TouchL();
   1.182 +	return DoInsertL(aRecordId,aRow);
   1.183 +	}
   1.184 +
   1.185 +void CDbRecordIndex::DeleteL(TDbRecordId aRecordId,const RDbTableRow& aRow)
   1.186 +	{
   1.187 +	__ASSERT(!IsBroken());
   1.188 +	TouchL();
   1.189 +	DoDeleteL(aRecordId,aRow);
   1.190 +	}