epoc32/include/s32share.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     4
// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
#ifndef __S32SHARE_H__
williamr@2
    17
#define __S32SHARE_H__
williamr@2
    18
williamr@2
    19
#include <s32buf.h>
williamr@2
    20
#include <s32strm.h>
williamr@2
    21
williamr@2
    22
class TStreamExchange;
williamr@2
    23
/**
williamr@2
    24
 * @publishedAll 
williamr@2
    25
 * @released
williamr@2
    26
 * Manages the position of a read mark or a write mark within a shared stream.
williamr@2
    27
williamr@2
    28
A shared stream is one that shares its host with other streams. In practice, 
williamr@2
    29
the host is a stream buffer that is, itself, hosted by a file, an RFileBuf 
williamr@2
    30
object. 
williamr@2
    31
williamr@2
    32
TStreamMark objects are owned by RShareBuf, one for reading and one for writing. 
williamr@2
    33
They re-direct read/write operations through a TStreamExchange object to the 
williamr@2
    34
RFileBuf object, which handles the actual file read and write operations.
williamr@2
    35
williamr@2
    36
@see RFileBuf
williamr@2
    37
@see RShareBuf
williamr@2
    38
@see TStreamExchange  
williamr@2
    39
*/
williamr@2
    40
class TStreamMark
williamr@2
    41
	{
williamr@2
    42
public:
williamr@2
    43
	inline TStreamMark();
williamr@2
    44
	inline TStreamMark(TStreamPos aPos);
williamr@2
    45
	inline TStreamMark& operator=(TStreamPos aPos);
williamr@2
    46
	inline operator TStreamMark*();
williamr@2
    47
	inline operator const TStreamMark*() const;
williamr@2
    48
//
williamr@2
    49
	inline TBool operator==(const TStreamMark& aMark) const;
williamr@2
    50
	inline TBool operator==(const TStreamMark* aPtr) const;
williamr@2
    51
	inline TBool operator!=(const TStreamMark& aMark) const;
williamr@2
    52
	inline TBool operator!=(const TStreamMark* aPtr) const;
williamr@2
    53
//
williamr@2
    54
	inline TBool IsEmpty() const;
williamr@2
    55
	inline void Clear();
williamr@2
    56
	inline TStreamPos Position() const;
williamr@2
    57
//
williamr@2
    58
	inline TBool IsWith(TStreamExchange& aHost) const;
williamr@2
    59
	inline TBool RelatesTo(TStreamExchange& aHost) const;
williamr@2
    60
	inline void Withdraw(TStreamExchange& aHost);
williamr@2
    61
	inline void ExtractL(TStreamExchange& aHost);
williamr@2
    62
//
williamr@2
    63
	inline TInt ReadL(TStreamExchange& aHost,TAny* aPtr,TInt aMaxLength);
williamr@2
    64
	IMPORT_C TInt ReadL(TStreamExchange& aHost,TDes8& aDes,TRequestStatus& aStatus);
williamr@2
    65
	inline TInt ReadL(TStreamExchange& aHost,TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
williamr@2
    66
	inline TStreamTransfer ReadL(TStreamExchange& aHost,MStreamInput& anInput,TStreamTransfer aTransfer);
williamr@2
    67
	inline TInt ReadL(TStreamExchange& aHost,MStreamInput& anInput,TInt aMaxLength);
williamr@2
    68
	inline void ReadL(TStreamExchange& aHost,MStreamInput& anInput);
williamr@2
    69
//
williamr@2
    70
	inline void WriteL(TStreamExchange& aHost,const TAny* aPtr,TInt aLength);
williamr@2
    71
	IMPORT_C TInt WriteL(TStreamExchange& aHost,const TDesC8& aDes,TRequestStatus& aStatus);
williamr@2
    72
	inline TInt WriteL(TStreamExchange& aHost,const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
williamr@2
    73
	inline TStreamTransfer WriteL(TStreamExchange& aHost,MStreamOutput& anOutput,TStreamTransfer aTransfer);
williamr@2
    74
	inline TInt WriteL(TStreamExchange& aHost,MStreamOutput& anOutput,TInt aMaxLength);
williamr@2
    75
	inline void WriteL(TStreamExchange& aHost,MStreamOutput& anOutput);
williamr@2
    76
//
williamr@2
    77
	inline void SeekL(TStreamExchange& aHost,TStreamPos aPos);
williamr@2
    78
	inline TStreamPos SeekL(TStreamExchange& aHost,TStreamLocation aLocation,TInt anOffset=0);
williamr@2
    79
	inline TStreamPos SeekL(TStreamExchange& aHost,TInt anOffset);
williamr@2
    80
//
williamr@2
    81
	inline TStreamPos TellL(TStreamExchange& aHost) const;
williamr@2
    82
private:
williamr@2
    83
	/** Constructs a default shared stream mark object.
williamr@2
    84
	
williamr@2
    85
	The position for the mark is uninitialised.
williamr@2
    86
	
williamr@2
    87
	An uninitialised mark means that a call to IsEmpty() returns true.
williamr@2
    88
	
williamr@2
    89
	@see IsEmpty() */
williamr@2
    90
	TStreamMark(const TStreamMark&);
williamr@2
    91
	TStreamMark& operator=(const TStreamMark&);
williamr@2
    92
private:
williamr@2
    93
	TStreamPos iPos;
williamr@2
    94
private:
williamr@2
    95
	inline TBool IsTracking(TStreamMark*const& aRef) const;
williamr@2
    96
	inline void Track(TStreamMark*const& aRef);
williamr@2
    97
private:
williamr@2
    98
	friend class TStreamExchange;
williamr@2
    99
private:
williamr@2
   100
	IMPORT_C static void __DbgChkPos(TStreamPos aPos);
williamr@2
   101
	};
williamr@2
   102
williamr@2
   103
/**
williamr@2
   104
 * @publishedAll 
williamr@2
   105
 * @released
williamr@2
   106
 * Manages access to a shared host buffer for shared stream buffers.
williamr@2
   107
williamr@2
   108
The class maintains independent markers for the shared stream buffer that 
williamr@2
   109
has most recently read or written to the shared host buffer.
williamr@2
   110
williamr@2
   111
This is the way in which multiple requests from the same shared stream buffer 
williamr@2
   112
are handled without the need for repeated seeking. The shared host buffer 
williamr@2
   113
only needs to seek when a new shared buffer needs to use it
williamr@2
   114
williamr@2
   115
@see RShareBuf  
williamr@2
   116
*/
williamr@2
   117
class TStreamExchange
williamr@2
   118
	{
williamr@2
   119
public:
williamr@2
   120
	inline TStreamExchange();
williamr@2
   121
	inline TStreamExchange(MStreamBuf* aHost);
williamr@2
   122
	inline void Share(MStreamBuf* aHost);
williamr@2
   123
	inline TBool IsActive() const;
williamr@2
   124
	IMPORT_C MStreamBuf* Host();
williamr@2
   125
	IMPORT_C MStreamBuf* HostL();
williamr@2
   126
	IMPORT_C void Release();
williamr@2
   127
//
williamr@2
   128
	IMPORT_C TInt SizeL() const;
williamr@2
   129
private:
williamr@2
   130
/** Used to identify the type of mark in a stream.
williamr@2
   131
williamr@2
   132
The type is used by functions of this class and derived classes that perform 
williamr@2
   133
seek operations to marks within a stream.
williamr@2
   134
williamr@2
   135
The type uses the ERead and EWrite enumeration values, as bit flags, to identify 
williamr@2
   136
the read and write marks respectively.
williamr@2
   137
williamr@2
   138
ERead is an MStreamBuf::TRead enumerator. EWrite is an MStreamBuf::EWrite 
williamr@2
   139
enumerator.
williamr@2
   140
williamr@2
   141
@see MStreamBuf::TRead
williamr@2
   142
@see MStreamBuf::TWrite */
williamr@2
   143
	typedef MStreamBuf::TMark TMark;
williamr@2
   144
private:
williamr@2
   145
	/** Constructs an empty object.
williamr@2
   146
	
williamr@2
   147
	Call Share() to prepare for access to a shared stream buffer. */
williamr@2
   148
	TStreamExchange(const TStreamExchange&);
williamr@2
   149
	TStreamExchange& operator=(const TStreamExchange&);
williamr@2
   150
//
williamr@2
   151
	IMPORT_C TBool RefersTo(const TStreamMark& aMark);
williamr@2
   152
	IMPORT_C void Drop(const TStreamMark& aMark);
williamr@2
   153
	IMPORT_C void GetL(TStreamMark& aMark);
williamr@2
   154
	IMPORT_C TInt DoReadL(TAny* aPtr,TInt aMaxLength,TStreamMark& aMark);
williamr@2
   155
	IMPORT_C TInt DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus,TStreamMark& aMark);
williamr@2
   156
	IMPORT_C TStreamTransfer DoReadL(MStreamInput& anInput,TStreamTransfer aTransfer,TStreamMark& aMark);
williamr@2
   157
	IMPORT_C void DoWriteL(const TAny* aPtr,TInt aLength,TStreamMark& aMark);
williamr@2
   158
	IMPORT_C TInt DoWriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus,TStreamMark& aMark);
williamr@2
   159
	IMPORT_C TStreamTransfer DoWriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer,TStreamMark& aMark);
williamr@2
   160
	IMPORT_C TStreamPos DoSeekL(TStreamMark& aMark,TStreamLocation aLocation,TInt anOffset);
williamr@2
   161
//
williamr@2
   162
	void PrepareForReadingL(TStreamMark& aMark);
williamr@2
   163
	void PrepareForWritingL(TStreamMark& aMark);
williamr@2
   164
//
williamr@2
   165
	TInt PrepareAndReadL(TAny* aPtr,TInt aMaxLength,TStreamMark& aMark);
williamr@2
   166
	TInt PrepareAndReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus,TStreamMark& aMark);
williamr@2
   167
	TStreamTransfer PrepareAndReadL(MStreamInput& anInput,TStreamTransfer aTransfer,TStreamMark& aMark);
williamr@2
   168
	void PrepareAndWriteL(const TAny* aPtr,TInt aLength,TStreamMark& aMark);
williamr@2
   169
	TInt PrepareAndWriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus,TStreamMark& aMark);
williamr@2
   170
	TStreamTransfer PrepareAndWriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer,TStreamMark& aMark);
williamr@2
   171
	TStreamPos MarkSeekL(TStreamMark& aMark,TStreamLocation aLocation,TInt anOffset);
williamr@2
   172
//
williamr@2
   173
	inline MStreamBuf& BufL() const;
williamr@2
   174
	inline MStreamBuf& Buf() const;
williamr@2
   175
private:
williamr@2
   176
	MStreamBuf* iHost;
williamr@2
   177
	TStreamMark* iRMrk;
williamr@2
   178
	TStreamMark* iWMrk;
williamr@2
   179
private:
williamr@2
   180
	friend class TStreamMark;
williamr@2
   181
	};
williamr@2
   182
williamr@2
   183
/**
williamr@2
   184
 * @publishedAll 
williamr@2
   185
 * @released
williamr@2
   186
 * A shared stream buffer.
williamr@2
   187
williamr@2
   188
This class is part of the framework used by CFileStore that allows multiple 
williamr@2
   189
stream buffers to concurrently access the single hosting file buffer, an RFileBuf 
williamr@2
   190
object.
williamr@2
   191
williamr@2
   192
Each shared stream buffer maintains its own read and write positions.
williamr@2
   193
williamr@2
   194
Read and write operations to RShareBuf are directed through separate TStreamMark 
williamr@2
   195
objects, one for read and one for write. The TStreamMark objects re-direct 
williamr@2
   196
read/write operations through a TStreamExchange object to the RFileBuf object, 
williamr@2
   197
which handles the actual file read and write operations. 
williamr@2
   198
williamr@2
   199
This stream buffer can also be accessed through RShareReadStream and RShareWriteStream 
williamr@2
   200
objects.
williamr@2
   201
williamr@2
   202
@see TStreamMark
williamr@2
   203
@see TStreamExchange
williamr@2
   204
@see RFileBuf
williamr@2
   205
@see RShareReadStream
williamr@2
   206
@see RShareWriteStream  
williamr@2
   207
*/
williamr@2
   208
class RShareBuf : public MStreamBuf
williamr@2
   209
	{
williamr@2
   210
public:
williamr@2
   211
	IMPORT_C RShareBuf();
williamr@2
   212
	IMPORT_C void Open(TStreamExchange& aHost,TStreamPos aPos,TInt aMode=ERead|EWrite);
williamr@2
   213
	inline void Open(TStreamExchange& aHost,TInt aMode=ERead|EWrite);
williamr@2
   214
protected:
williamr@2
   215
	IMPORT_C void DoRelease();
williamr@2
   216
	IMPORT_C TInt DoReadL(TAny* aPtr,TInt aMaxLength);
williamr@2
   217
	IMPORT_C TInt DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
williamr@2
   218
	IMPORT_C TStreamTransfer DoReadL(MStreamInput& anInput,TStreamTransfer aTransfer);
williamr@2
   219
	IMPORT_C void DoWriteL(const TAny* aPtr,TInt aLength);
williamr@2
   220
	IMPORT_C TInt DoWriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
williamr@2
   221
	IMPORT_C TStreamTransfer DoWriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer);
williamr@2
   222
	IMPORT_C TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
williamr@2
   223
private:
williamr@2
   224
	inline TStreamExchange& Host() const;
williamr@2
   225
private:
williamr@2
   226
	TStreamExchange* iHost;
williamr@2
   227
	TStreamMark iRMark;
williamr@2
   228
	TStreamMark iWMark;
williamr@2
   229
	};
williamr@2
   230
williamr@2
   231
/**
williamr@2
   232
 * @publishedAll 
williamr@2
   233
 * @released
williamr@2
   234
 * Supports the opening, for reading, of a stream which shares its host with other 
williamr@2
   235
streams.
williamr@2
   236
williamr@2
   237
This is also called a shared read stream.
williamr@2
   238
williamr@2
   239
The class uses a RShareBuf stream buffer.
williamr@2
   240
williamr@2
   241
@see RShareBuf
williamr@2
   242
@see RFileBuf  
williamr@2
   243
*/
williamr@2
   244
class RShareReadStream : public RReadStream
williamr@2
   245
	{
williamr@2
   246
public:
williamr@2
   247
	/** Constructs an empty shared read stream object.
williamr@2
   248
	
williamr@2
   249
	Call Open() to prepare the shared stream for reading.
williamr@2
   250
	
williamr@2
   251
	@see RShareReadStream::Open() */
williamr@2
   252
	RShareReadStream() {}
williamr@2
   253
	IMPORT_C RShareReadStream(TStreamExchange& aHost,TStreamPos aPos=KStreamBeginning);
williamr@2
   254
	IMPORT_C void Open(TStreamExchange& aHost,TStreamPos aPos=KStreamBeginning);
williamr@2
   255
private:
williamr@2
   256
	RShareBuf iSource;
williamr@2
   257
	};
williamr@2
   258
williamr@2
   259
/**
williamr@2
   260
 * @publishedAll 
williamr@2
   261
 * @released
williamr@2
   262
 * Supports the opening, for writing, of a stream which shares its host with other 
williamr@2
   263
streams.
williamr@2
   264
williamr@2
   265
This is also called a shared write stream.
williamr@2
   266
williamr@2
   267
The class uses a RShareBuf stream buffer.
williamr@2
   268
williamr@2
   269
@see RShareBuf
williamr@2
   270
@see RFileBuf  
williamr@2
   271
*/
williamr@2
   272
class RShareWriteStream : public RWriteStream
williamr@2
   273
	{
williamr@2
   274
public:
williamr@2
   275
	/** Constructs an empty shared write stream object.
williamr@2
   276
	
williamr@2
   277
	Call Open() to prepare the shared stream for writing.
williamr@2
   278
	
williamr@2
   279
	@see RShareWriteStream::Open() */
williamr@2
   280
	RShareWriteStream() {}
williamr@2
   281
	inline RShareWriteStream(const MExternalizer<TStreamRef>& anExter);
williamr@2
   282
	IMPORT_C RShareWriteStream(TStreamExchange& aHost,TStreamPos aPos=KStreamBeginning);
williamr@2
   283
	IMPORT_C void Open(TStreamExchange& aHost,TStreamPos aPos=KStreamBeginning);
williamr@2
   284
private:
williamr@2
   285
	RShareBuf iSink;
williamr@2
   286
	};
williamr@2
   287
williamr@2
   288
#include <s32share.inl>
williamr@2
   289
#endif