videocollection/mpxmyvideoscollection/inc/vcxmyvideosvideocache.h
changeset 36 8aed59de29f9
parent 35 3738fe97f027
child 39 f6d44a0cd476
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
    29 // CONSTANTS
    29 // CONSTANTS
    30 
    30 
    31 // CLASS DECLARATION
    31 // CLASS DECLARATION
    32 
    32 
    33 /**
    33 /**
       
    34  * Contains information about video.
       
    35  * These are stored to CVcxMyVideosVideoListIndex::iVideoArray.
       
    36  */
       
    37 NONSHARABLE_CLASS(TVcxMyVideosVideo)
       
    38     {
       
    39     public:
       
    40 
       
    41         /**
       
    42          * Constructor.
       
    43          */        
       
    44         TVcxMyVideosVideo();
       
    45         
       
    46         /**
       
    47         * = operator.
       
    48         */        
       
    49         TVcxMyVideosVideo& operator=( const TVcxMyVideosVideo& aVideo );
       
    50     public:
       
    51         
       
    52         /**
       
    53         * Set values.
       
    54         * 
       
    55         * @param aMdsId  MDS ID
       
    56         * @param aPos    Position in CVcxMyVideosVideoCache::iVideoList
       
    57         * @param aVideo  Pointer to CVcxMyVideosVideoCache::iVideoList item,
       
    58         *                ownership does not move.
       
    59         */
       
    60         void Set( TUint32 aMdsId, TInt aPos, CMPXMedia* aVideo );
       
    61 
       
    62     public:
       
    63         TUint32    iMdsId; // Video object ID in MDS.
       
    64         CMPXMedia* iVideo; // Pointer to CVcxMyVideosVideoCache::iVideoList item
       
    65         TInt       iPos;   // Items position in CVcxMyVideosVideoCache::iVideoList
       
    66     };
       
    67 
       
    68 /**
       
    69 * Used for keeping videos in MDS ID order for fast access.
       
    70 * (Indexes CVcxMyVideosVideoCache::iVideoList).
       
    71 *
       
    72 * @lib mpxmyvideoscollectionplugin.lib
       
    73 */
       
    74 NONSHARABLE_CLASS(CVcxMyVideosVideoListIndex) : public CBase
       
    75     {    
       
    76 public: // Constructors and destructor
       
    77 
       
    78     /**
       
    79     * Two-phased constructor
       
    80     * @return Object constructed
       
    81     */
       
    82     static CVcxMyVideosVideoListIndex* NewL();
       
    83     
       
    84     /**
       
    85     * Destructor
       
    86     */
       
    87     virtual ~CVcxMyVideosVideoListIndex();
       
    88 
       
    89 public:
       
    90     
       
    91     /**
       
    92      * Sets up iVideoArray from aVideoList. Sorting is also done.
       
    93      * 
       
    94      * @param aVideoList  Video list to use for constructing iVideoArray. 
       
    95      */
       
    96     void SetL( const CMPXMedia& aVideoList );
       
    97     
       
    98     /**
       
    99      * Finds video by MDS ID from the index. Uses bisection method.
       
   100      * 
       
   101      * @param aVideo  The found video data is written here.
       
   102      * @return        KErrNotFound if not found, index of the item in iVideoArray
       
   103      *                otherwise.
       
   104      */
       
   105     TInt Find( TUint32 aMdsId, TVcxMyVideosVideo& aVideo );
       
   106     
       
   107     /**
       
   108      * Removes video from index.
       
   109      * 
       
   110      * @param aMdsId     ID if the item to be removed.
       
   111      * @param aCompress  If ETrue, compresses the video array.
       
   112      * @return           KErrNotFound if not found, index of the removed item otherwise.
       
   113      */
       
   114     TInt Remove( TUint32 aMdsId, TBool aCompress = ETrue );
       
   115     
       
   116     /**
       
   117      * Adds video to index. Keeps sorting order.
       
   118      * 
       
   119      * @param aVideo  Video to be added, ownership does not move.
       
   120      * @param aPos    aVideo's position in CVcxMyVideosVideoCache::iVideoList.
       
   121      */
       
   122     void AddL( CMPXMedia* aVideo, TInt aPos );
       
   123 
       
   124 #ifdef _DEBUG
       
   125     /**
       
   126      * Returns reference to video array.
       
   127      */
       
   128     const RArray<TVcxMyVideosVideo>& VideoArray();
       
   129 #endif
       
   130     
       
   131 private:
       
   132     /**
       
   133     * Constructor
       
   134     */
       
   135     CVcxMyVideosVideoListIndex();
       
   136     
       
   137     /**
       
   138     * Symbian 2nd phase constructor.
       
   139     */
       
   140     void ConstructL ();
       
   141 
       
   142     /**
       
   143      * Sorts iVideoArray by MDS ID.
       
   144      */
       
   145     void Sort();
       
   146     
       
   147     /**
       
   148      * Used for keeping RArray<TVcxMyVideosVideo> in integer order by
       
   149      * TVcxMyVideosVideo::iMdsId.
       
   150      * 
       
   151      * @param aVideo1 Video to compare
       
   152      * @param aVideo2 Video to compare
       
   153      * @return -1 if aVideo1 is smaller than aVideo2, 1 if aVideo1 is larger than
       
   154      *         aVideo2.
       
   155      */
       
   156     static TInt CompareVideosByMdsId( const TVcxMyVideosVideo& aVideo1,
       
   157             const TVcxMyVideosVideo& aVideo2 );
       
   158 
       
   159 private:
       
   160     
       
   161     /**
       
   162      * Video array which is kept in order by MDS ID.
       
   163      */
       
   164     RArray<TVcxMyVideosVideo> iVideoArray;
       
   165     };
       
   166 
       
   167 /**
    34 * Used for storing MDS items to RAM for fast access.
   168 * Used for storing MDS items to RAM for fast access.
    35 *
   169 *
    36 * @lib mpxmyvideoscollectionplugin.lib
   170 * @lib mpxmyvideoscollectionplugin.lib
    37 */
   171 */
    38 NONSHARABLE_CLASS(CVcxMyVideosVideoCache) : public CBase
   172 NONSHARABLE_CLASS(CVcxMyVideosVideoCache) : public CBase
    50         /**
   184         /**
    51         * Destructor
   185         * Destructor
    52         */
   186         */
    53         virtual ~CVcxMyVideosVideoCache();
   187         virtual ~CVcxMyVideosVideoCache();
    54  
   188  
       
   189     public:
       
   190         
       
   191         /**
       
   192          * @return  ETrue if iVideoList is complete. (All items have
       
   193          *          been fetched from MDS.)
       
   194          */
       
   195         TBool IsComplete();
       
   196         
       
   197         /**
       
   198          * Set to ETrue when all items have been fetched from MDS.
       
   199          */
       
   200         void SetComplete( TBool aComplete );
       
   201 
    55     private:
   202     private:
    56         /**
   203         /**
    57         * Constructor
   204         * Constructor
    58         */
   205         */
    59         CVcxMyVideosVideoCache( CVcxMyVideosCollectionPlugin& aMyVideosCollectionPlugin );
   206         CVcxMyVideosVideoCache( CVcxMyVideosCollectionPlugin& aMyVideosCollectionPlugin );
   174         *
   321         *
   175         * @param aVideo  Video which position is searched.
   322         * @param aVideo  Video which position is searched.
   176         * @return        Position, KErrNotFound if item is not in iVideoList.
   323         * @return        Position, KErrNotFound if item is not in iVideoList.
   177         */
   324         */
   178         TInt PosOnVideoListL( CMPXMedia& aVideo );
   325         TInt PosOnVideoListL( CMPXMedia& aVideo );
   179                  
   326 
       
   327 #ifdef _DEBUG
       
   328         /**
       
   329          * Checks that iVideoListIndex is correctly formed.
       
   330          */
       
   331         void CheckVideoListIndexL();
       
   332 #endif
       
   333         
   180     public:            
   334     public:            
   181         /**
   335         /**
   182         * Creates filtered video list from iVideoList. This is used for
   336         * Creates filtered video list from iVideoList. This is used for
   183         * showing video categories by origin.
   337         * showing video categories by origin.
   184         *
   338         *
   325         * are added here. When iVideoList instance is received from MDS, it is
   479         * are added here. When iVideoList instance is received from MDS, it is
   326         * replaced by item from iPartialVideoList and instance from iPartialVideoList
   480         * replaced by item from iPartialVideoList and instance from iPartialVideoList
   327         * is removed.
   481         * is removed.
   328         */
   482         */
   329         RArray<CMPXMedia*> iPartialVideoList;
   483         RArray<CMPXMedia*> iPartialVideoList;
   330 
       
   331         /**
       
   332         * If ETrue then iVideoList does not contain all items from MDS.
       
   333         */
       
   334         TBool iVideoListIsPartial;
       
   335                                 
   484                                 
   336         /**
   485         /**
   337         * Sorting order which was used last time when list was queryed from MDS.
   486         * Sorting order which was used last time when list was queryed from MDS.
   338         */
   487         */
   339         TVcxMyVideosSortingOrder iLastSortingOrder;
   488         TVcxMyVideosSortingOrder iLastSortingOrder;
   341         /**
   490         /**
   342          * Set to ETrue when doing videolist fetching.
   491          * Set to ETrue when doing videolist fetching.
   343          */
   492          */
   344         TBool IsFetchingVideoList;
   493         TBool IsFetchingVideoList;
   345     private:
   494     private:
       
   495 
       
   496         /**
       
   497         * If ETrue then iVideoList contains all items from MDS.
       
   498         */
       
   499         TBool iVideoListIsComplete;
   346         
   500         
   347         /**
   501         /**
   348         * My Videos collection plugin, owner of this object.
   502         * My Videos collection plugin, owner of this object.
   349         */
   503         */
   350         CVcxMyVideosCollectionPlugin& iCollection;        
   504         CVcxMyVideosCollectionPlugin& iCollection;
       
   505         
       
   506         /**
       
   507          * Index which keeps TVcxMyVidesVideo items indexed in MDS ID
       
   508          * order for fast access.
       
   509          */
       
   510         CVcxMyVideosVideoListIndex* iVideoListIndex;
   351     };
   511     };
   352 
   512 
   353 #endif   // VCXMYVIDEOSVIDEOCACHE_H
   513 #endif   // VCXMYVIDEOSVIDEOCACHE_H
   354 
   514 
   355 
   515