epoc32/include/pcstore/directfilestore.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/pcstore/directfilestore.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,91 @@
     1.4 +// Copyright (c) 2006-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 +#if !defined(__DIRECTFILESTORE_H__)
    1.20 +#define __DIRECTFILESTORE_H__
    1.21 +
    1.22 +#include <pcstore/pcstoredef.h>
    1.23 +#include <pcstore/streamid.h>
    1.24 +#include <pcstore/uid.h>
    1.25 +
    1.26 +namespace PCStore
    1.27 +{
    1.28 +class TUidType;
    1.29 +class CStoreWriteStream;
    1.30 +class CStoreReadStream;
    1.31 +class CFileStreamBuf;
    1.32 +
    1.33 +const TInt KDirectFileStoreLayoutUidValue=0x10000037; //268435511;
    1.34 +const TUid KDirectFileStoreLayoutUid={KDirectFileStoreLayoutUidValue};
    1.35 +
    1.36 +/**
    1.37 +@internalAll
    1.38 +
    1.39 +Direct file store.
    1.40 +
    1.41 +A direct file store implements a set of the operations to open store, create streams(CStoreWriteStream 
    1.42 +and CStoreReadStream), set root stream id to the store.
    1.43 +
    1.44 +Objects can be externalized to streams represented by class CStoreWriteStream. Once the streams 
    1.45 +have been closed, they cannot subsequently be changed, i.e. streams cannot be replaced, deleted, 
    1.46 +extended or changed in any way. 
    1.47 +
    1.48 +Existing direct file stores can be opened with this class. Objects can be restored with class 
    1.49 +CStoreReadStream.
    1.50 +
    1.51 +Before closing a new store, the root stream id must be set. After opening an existing store, the 
    1.52 +first thing done is to look up the root stream id. The root stream can then be opened and data 
    1.53 +read from the store.
    1.54 +
    1.55 +@see CStoreWriteStream
    1.56 +@see CStoreReadStream
    1.57 +*/
    1.58 +class CDirectFileStore
    1.59 +	{
    1.60 +public:
    1.61 +	//Enumerations for the store open mode
    1.62 +	enum TStoreMode 
    1.63 +	{
    1.64 +	EReadStore=0,
    1.65 +	EWriteStore=1
    1.66 +	};
    1.67 +
    1.68 +public:
    1.69 +	~CDirectFileStore();
    1.70 +
    1.71 +	void SetRoot(TStreamId aId);
    1.72 +	TStreamId Root() const;
    1.73 +	static CDirectFileStore* Open(const char* aFileName);
    1.74 +	static CDirectFileStore* Replace(const char* aFileName);
    1.75 +	static CDirectFileStore* Replace(const char* aFileName, const TUidType& aType);
    1.76 +	CStoreWriteStream* CreateWriteStream(TStreamId& aId);
    1.77 +	CStoreReadStream* CreateReadStream(TStreamId aId);
    1.78 +
    1.79 +private:
    1.80 +	CDirectFileStore(const char* aFileName, TStoreMode aMode);
    1.81 +	CStoreWriteStream* CreateIdWriteStream(TStreamId aId);
    1.82 +
    1.83 +	void SetType(const TUidType& aType);
    1.84 +	void CheckType();
    1.85 +	void Externalize(CStoreWriteStream& aWs) const;
    1.86 +	void Internalize(CStoreReadStream& aRs);
    1.87 +
    1.88 +private:
    1.89 +	TStoreMode iMode;
    1.90 +	TStreamId iRoot;
    1.91 +	CFileStreamBuf* iFileStreamBuf;
    1.92 +	};
    1.93 +}
    1.94 +#endif // !defined(__DIRECTFILESTORE_H__)