os/persistentdata/persistentstorage/dbms/tdbms/t_dbfail.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef T_DBFAIL_H
    17 #define T_DBFAIL_H
    18 
    19 GLREF_D RTest test;
    20 GLREF_D RDbs TheDbs;
    21 GLREF_D RDbNamedDatabase TheDatabase;
    22 
    23 GLREF_C void Connect();
    24 GLREF_C void Disconnect();
    25 GLREF_C void PrepareDbFmtString();
    26 GLREF_C void TestOpen2();
    27 GLREF_C void Origins2();
    28 
    29 class THeapFail
    30 	{
    31 public:
    32 	virtual void Mark() const =0;
    33 	virtual void Fail(TInt aCount) const =0;
    34 	virtual void Reset() const =0;
    35 	virtual void Check() const =0;
    36 	};
    37 
    38 class TContext
    39 	{
    40 public:
    41 	virtual void OpenDbL() const =0;
    42 	};
    43 
    44 class TFail
    45 	{
    46 private:
    47 	void Test(const THeapFail& aHeap,const TContext* aContext);
    48 	virtual void RunL() 
    49 		{
    50 		}
    51 	virtual void End() 
    52 		{
    53 		}
    54 
    55 public:
    56 	inline void Test(const THeapFail& aHeap,const TContext& aContext)
    57 		{
    58 		Test(aHeap,&aContext);
    59 		}
    60 	inline void Test(const THeapFail& aHeap)
    61 		{
    62 		Test(aHeap,0);
    63 		}
    64 	};
    65 
    66 class TClientHeap : public THeapFail
    67 	{
    68 public:
    69 	TClientHeap() 
    70 		{
    71 		}
    72 		
    73 private:
    74 	void Mark() const
    75 		{
    76 		User::__DbgMarkStart(RHeap::EUser);
    77 		}
    78 	void Fail(TInt aCount) const
    79 		{
    80 		User::__DbgSetAllocFail(RHeap::EUser,RHeap::EFailNext,aCount);
    81 		}
    82 	void Reset() const
    83 		{
    84 		User::__DbgSetAllocFail(RHeap::EUser,RHeap::ENone,1);
    85 		}
    86 	void Check() const
    87 		{
    88 		User::__DbgMarkEnd(RHeap::EUser,0);
    89 		}
    90 		
    91 	};
    92 
    93 class TServerHeap : public THeapFail
    94 	{
    95 public:
    96 	TServerHeap() 
    97 		{
    98 		}
    99 		
   100 private:
   101 	void Mark() const
   102 		{
   103 		}
   104 	void Fail(TInt aCount) const
   105 		{
   106 		TheDbs.SetHeapFailure(RHeap::EFailNext,aCount);
   107 		}
   108 	void Reset() const
   109 		{
   110 		TheDbs.SetHeapFailure(RHeap::ENone,0);
   111 		}
   112 	void Check() const
   113 		{
   114 		}
   115 		
   116 	};
   117 
   118 GLREF_D TClientHeap KClientHeap;
   119 GLREF_D TServerHeap KServerHeap;
   120 
   121 #endif//T_DBFAIL_H