logsui/EngineInc/CLogsBaseReader.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *     Implements interface for Logs reader. Common functionality.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __Logs_Engine_CLogsBaseReader_H__
       
    21 #define __Logs_Engine_CLogsBaseReader_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <logwrap.h>
       
    26 #include <logviewchangeobserver.h>
       
    27 #include "MLogsReader.h"
       
    28 #include "MLogsStateHolder.h"
       
    29 #include "TLogsEventStrings.h"
       
    30 
       
    31 // FORWARD DECLARATION
       
    32 class CLogClient;
       
    33 class MLogsEvent;
       
    34 class MLogsEventArray;
       
    35 class CLogsEngine;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40  *  Implements interface for Logs reader. Common functionality.
       
    41  */
       
    42 class CLogsBaseReader : public CActive, 
       
    43                         public MLogsReader,
       
    44                         public MLogsStateHolder,
       
    45                         public MLogViewChangeObserver
       
    46     {
       
    47     public:
       
    48        /**
       
    49         *   Destructor.
       
    50         */
       
    51         virtual ~CLogsBaseReader();
       
    52 
       
    53     private:
       
    54        /**
       
    55         *  Default constructor
       
    56         */
       
    57         CLogsBaseReader();
       
    58       
       
    59     protected:
       
    60         /**
       
    61          *  Constructor
       
    62          *
       
    63          *  @param aFsSession   ref. to file server session
       
    64          *  @param aEventArray  array of events
       
    65          *  @param aStrings     log client constants
       
    66          *  @param aModel       model id
       
    67          *  @param aObserver    observer
       
    68          */
       
    69         CLogsBaseReader(    RFs& aFsSession
       
    70                        ,    MLogsEventArray& aEventArray
       
    71                        ,    TLogsEventStrings& aStrings
       
    72                        ,    TLogsModel aModel
       
    73                        ,    MLogsObserver* aObserver
       
    74                        ,    CLogsEngine* aLogsEngineRef
       
    75                        );
       
    76 
       
    77         /**
       
    78          *  Second phase constructor
       
    79          */
       
    80         void BaseConstructL();
       
    81 
       
    82         /**
       
    83          *  Pure virtual. Next reading operation.
       
    84          *
       
    85          *  @return ETrue to set the object active
       
    86          */
       
    87         virtual TBool DoNextL() = 0;
       
    88 
       
    89         /**
       
    90          *  Wrapper for DoNextL
       
    91          */
       
    92         void NextL();
       
    93 
       
    94         /**
       
    95          *  Base event construction
       
    96          *
       
    97          *  @param aDest    ref. to MLogsEvent implemetation object
       
    98          *  @param aSource  pointer to CLogEvent object
       
    99          */
       
   100         void BaseConstructEventL( MLogsEvent& aDest, const CLogEvent& aSource );
       
   101 
       
   102         /**
       
   103          *  Event construction
       
   104          *
       
   105          *  @param aDest    ref. to MLogsEvent implemetation object
       
   106          *  @param aSource  pointer to CLogEvent object
       
   107          */
       
   108         virtual void ConstructEventL
       
   109                         (   MLogsEvent& aDest
       
   110                         ,   const CLogEvent& aSource
       
   111                         ) = 0;
       
   112 
       
   113         /**
       
   114          *  Checks array's length against the view length and deletes
       
   115          *  extra events from the array
       
   116          */
       
   117         void CheckArrayLengthL();
       
   118 
       
   119         /**
       
   120          *  Event count getter in a view
       
   121          *
       
   122          *  @return number of events in a view
       
   123          */
       
   124         virtual TInt ViewCountL() const = 0;
       
   125 
       
   126         /**
       
   127          *  Current event getter from the view
       
   128          *
       
   129          *  @return ref. to current event
       
   130          */
       
   131         virtual CLogEvent& Event() const = 0;
       
   132 
       
   133         /**
       
   134          *  Duplicate count getter
       
   135          *
       
   136          *  @return number of duplicates of the current event
       
   137          */
       
   138         virtual TInt DuplicateCountL() const;
       
   139 
       
   140         /**
       
   141          * Operations to be done once reader has finished reading
       
   142          * If function is implemented in derived base class implementation 
       
   143          * must be called.
       
   144          */
       
   145         virtual void ReadingFinishedL();
       
   146 
       
   147         /**
       
   148          * Db change handler
       
   149          *
       
   150 	     * @param aTotalChangeCount		This is the total count of all 
       
   151          *                              changes which will be processed in this batch
       
   152          *                              default 1
       
   153 	     */
       
   154         void HandleViewChangeL( TInt aTotalChangeCount = 1 );
       
   155 
       
   156     protected: // From CActive
       
   157         void DoCancel();
       
   158         void RunL();
       
   159         TInt RunError(TInt aError);
       
   160 
       
   161     public: // from MLogsReader
       
   162         void Stop() = 0;
       
   163         void Interrupt();
       
   164         TBool IsInterrupted() const;
       
   165         void SetObserver( MLogsObserver* aObserver );
       
   166         void StartL() = 0;
       
   167         void ContinueL();
       
   168         TBool IsDirty() const;
       
   169         void SetDirty();
       
   170         void ActivateL();
       
   171         void DeActivate();
       
   172 
       
   173     public: // from MLogsStateHolder
       
   174         TLogsState State() const;
       
   175 
       
   176     public: // from MLogViewChangeObserver
       
   177         void HandleLogViewChangeEventAddedL
       
   178                         (   TLogId aId
       
   179                         ,   TInt aViewIndex
       
   180                         ,   TInt aChangeIndex
       
   181                         ,   TInt aTotalChangeCount
       
   182                         );
       
   183 
       
   184         void HandleLogViewChangeEventChangedL
       
   185                         (   TLogId aId
       
   186                         ,   TInt aViewIndex
       
   187                         ,   TInt aChangeIndex
       
   188                         ,   TInt aTotalChangeCount
       
   189                         );
       
   190 
       
   191         void HandleLogViewChangeEventDeletedL
       
   192                         (   TLogId aId
       
   193                         ,   TInt aViewIndex
       
   194                         ,   TInt aChangeIndex
       
   195                         ,   TInt aTotalChangeCount
       
   196                         );
       
   197 
       
   198     protected:
       
   199         // internal states of object
       
   200         enum TReaderPhase
       
   201             {
       
   202             EInitial = 0,
       
   203             EFilter,
       
   204             ERead,
       
   205             EDuplicate,
       
   206             EDone
       
   207             };
       
   208 
       
   209     protected:    // data
       
   210         /// ref: file session
       
   211         RFs&                    iFsSession;        
       
   212 
       
   213         /// ref: to event array
       
   214         MLogsEventArray&		iEventArray;
       
   215 
       
   216         /// own: string constants
       
   217         TLogsEventStrings&      iStrings;
       
   218 
       
   219         /// ref: log client
       
   220         CLogClient*             iLogClientRef;
       
   221 
       
   222         /// ref: observer
       
   223         MLogsObserver*          iObserver;
       
   224 
       
   225         /// Ref: Log db engine        
       
   226         CLogsEngine*            iLogsEngineRef;         
       
   227 
       
   228         /// own: phase
       
   229         TReaderPhase            iPhase;
       
   230 
       
   231         /// own: model id
       
   232         TLogsModel              iModelId;
       
   233 
       
   234         /// own: array index
       
   235         TInt                    iIndex; 
       
   236         
       
   237         /// own: flag for interruption
       
   238         TBool                   iInterrupted;        
       
   239 
       
   240         /// own: state for observer
       
   241         TLogsState              iState;
       
   242 
       
   243         /// own: dirty flag
       
   244         TBool                   iDirty;
       
   245 
       
   246         // own: activated flag
       
   247         TBool                   iActivated;  
       
   248         
       
   249         /// own:
       
   250         TInt                    iDeleteChangeCount; 
       
   251 
       
   252         /// own: const emergency nbr supported
       
   253         TBool                   iStaticEmerg;
       
   254         
       
   255         TBool                   iReadMissedDuplicateCounts;
       
   256         
       
   257     };
       
   258 
       
   259 #endif      // __Logs_Engine_CLogsBaseReader_H__
       
   260 
       
   261 // End of File