mtpfws/mtpfw/datatypes/interface/cmtptypelist.h
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     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 /**
       
    17 @file
       
    18 @publishedPartner
       
    19 @released
       
    20 */
       
    21 
       
    22 #ifndef CMTPTYPELIST_H_
       
    23 #define CMTPTYPELIST_H_
       
    24 
       
    25 
       
    26 #include <e32std.h>
       
    27 #include <mtp/rmtptype.h>
       
    28 #include <mtp/cmtptypecompoundbase.h>
       
    29 #include <mtp/mtpdatatypeconstants.h>
       
    30 
       
    31 
       
    32 class CMTPTypeList : public CMTPTypeCompoundBase
       
    33     {
       
    34 public:
       
    35     IMPORT_C static CMTPTypeList* NewL(TMTPTypeIds aListType, TMTPTypeIds aElementType);
       
    36     IMPORT_C static CMTPTypeList* NewLC(TMTPTypeIds aListType, TMTPTypeIds aElementType);
       
    37     IMPORT_C virtual ~CMTPTypeList();
       
    38     IMPORT_C virtual void AppendL(const MMTPType* aElement);
       
    39     IMPORT_C virtual void Remove(const TInt aIndex);
       
    40     IMPORT_C virtual TInt ElementType() const;
       
    41     IMPORT_C virtual TUint32 NumberOfElements() const;
       
    42     IMPORT_C MMTPType& ElementL(const TInt aIndex) const;
       
    43     IMPORT_C void ResetAndDestroy();
       
    44     
       
    45 public: // From CMTPTypeCompoundBase
       
    46 
       
    47     IMPORT_C virtual TInt FirstWriteChunk(TPtr8& aChunk);
       
    48     IMPORT_C virtual TInt NextWriteChunk(TPtr8& aChunk);
       
    49     IMPORT_C virtual TUint Type() const;
       
    50     IMPORT_C virtual TBool CommitRequired() const;
       
    51     IMPORT_C virtual MMTPType* CommitChunkL(TPtr8& aChunk); 
       
    52     IMPORT_C virtual TInt NextWriteChunk(TPtr8& aChunk, TUint aDataLength);
       
    53     
       
    54     
       
    55 private: // From CMTPTypeCompoundBase
       
    56     
       
    57     const TElementInfo& ElementInfo(TInt aElementId) const;
       
    58     TInt ValidateChunkCount() const;
       
    59 
       
    60 protected:
       
    61 	CMTPTypeList(TInt aArrayType, TInt aElementType);
       
    62 	void InitListL();
       
    63 	
       
    64 private:
       
    65     void ConstructL();
       
    66     TInt UpdateWriteSequenceErr(TInt aErr);
       
    67     void AppendElementChunkL(const MMTPType* aElement);
       
    68     
       
    69 private:
       
    70 
       
    71     /**
       
    72     The write data stream states.
       
    73     */
       
    74     enum TReadWriteSequenceState
       
    75         {
       
    76         /**
       
    77         Data stream is inactive.
       
    78         */
       
    79         EIdle,
       
    80         
       
    81         /**
       
    82         Elements data stream is in progress.
       
    83         */
       
    84         EElementChunks,          
       
    85         };
       
    86 
       
    87 private:
       
    88 
       
    89     /**
       
    90     The write data stream error state. 
       
    91     */
       
    92     TUint                                           iWriteSequenceErr;
       
    93     
       
    94     /**
       
    95     The write data stream state variable. 
       
    96     */
       
    97     TUint                                           iWriteSequenceState;
       
    98 
       
    99     /**
       
   100     The NumberOfElements element metadata content.
       
   101     */
       
   102     CMTPTypeCompoundBase::TElementInfo              iInfoNumberOfElements;
       
   103     
       
   104     /**
       
   105     The Element array metadata content. Note that this is declared mutable 
       
   106     to allow state updates while processing a read data stream.
       
   107     */
       
   108     mutable CMTPTypeCompoundBase::TElementInfo      iInfoElement;
       
   109     
       
   110     TInt                                            iListType;
       
   111     TInt                                            iElementType;
       
   112     
       
   113     static const TUint                              KChunckNumberOfHeader;
       
   114     static const TUint                              KChunkNumberofElements;
       
   115     TMTPTypeUint32                                  iChunkNumberOfElements;    
       
   116     
       
   117     RPointerArray<MMTPType>                         iChunksElement;
       
   118     };
       
   119 
       
   120 
       
   121 
       
   122 #endif /* CMTPTYPELIST_H_ */