epoc32/include/pcstore/directfilestore.h
branchSymbian3
changeset 4 837f303aceeb
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
       
     1 // Copyright (c) 2006-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 #if !defined(__DIRECTFILESTORE_H__)
       
    17 #define __DIRECTFILESTORE_H__
       
    18 
       
    19 #include <pcstore/pcstoredef.h>
       
    20 #include <pcstore/streamid.h>
       
    21 #include <pcstore/uid.h>
       
    22 
       
    23 namespace PCStore
       
    24 {
       
    25 class TUidType;
       
    26 class CStoreWriteStream;
       
    27 class CStoreReadStream;
       
    28 class CFileStreamBuf;
       
    29 
       
    30 const TInt KDirectFileStoreLayoutUidValue=0x10000037; //268435511;
       
    31 const TUid KDirectFileStoreLayoutUid={KDirectFileStoreLayoutUidValue};
       
    32 
       
    33 /**
       
    34 @internalAll
       
    35 
       
    36 Direct file store.
       
    37 
       
    38 A direct file store implements a set of the operations to open store, create streams(CStoreWriteStream 
       
    39 and CStoreReadStream), set root stream id to the store.
       
    40 
       
    41 Objects can be externalized to streams represented by class CStoreWriteStream. Once the streams 
       
    42 have been closed, they cannot subsequently be changed, i.e. streams cannot be replaced, deleted, 
       
    43 extended or changed in any way. 
       
    44 
       
    45 Existing direct file stores can be opened with this class. Objects can be restored with class 
       
    46 CStoreReadStream.
       
    47 
       
    48 Before closing a new store, the root stream id must be set. After opening an existing store, the 
       
    49 first thing done is to look up the root stream id. The root stream can then be opened and data 
       
    50 read from the store.
       
    51 
       
    52 @see CStoreWriteStream
       
    53 @see CStoreReadStream
       
    54 */
       
    55 class CDirectFileStore
       
    56 	{
       
    57 public:
       
    58 	//Enumerations for the store open mode
       
    59 	enum TStoreMode 
       
    60 	{
       
    61 	EReadStore=0,
       
    62 	EWriteStore=1
       
    63 	};
       
    64 
       
    65 public:
       
    66 	~CDirectFileStore();
       
    67 
       
    68 	void SetRoot(TStreamId aId);
       
    69 	TStreamId Root() const;
       
    70 	static CDirectFileStore* Open(const char* aFileName);
       
    71 	static CDirectFileStore* Replace(const char* aFileName);
       
    72 	static CDirectFileStore* Replace(const char* aFileName, const TUidType& aType);
       
    73 	CStoreWriteStream* CreateWriteStream(TStreamId& aId);
       
    74 	CStoreReadStream* CreateReadStream(TStreamId aId);
       
    75 
       
    76 private:
       
    77 	CDirectFileStore(const char* aFileName, TStoreMode aMode);
       
    78 	CStoreWriteStream* CreateIdWriteStream(TStreamId aId);
       
    79 
       
    80 	void SetType(const TUidType& aType);
       
    81 	void CheckType();
       
    82 	void Externalize(CStoreWriteStream& aWs) const;
       
    83 	void Internalize(CStoreReadStream& aRs);
       
    84 
       
    85 private:
       
    86 	TStoreMode iMode;
       
    87 	TStreamId iRoot;
       
    88 	CFileStreamBuf* iFileStreamBuf;
       
    89 	};
       
    90 }
       
    91 #endif // !defined(__DIRECTFILESTORE_H__)