cbs/CbsServer/ServerInc/CCbsDbImpTopicCollection.h
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2003 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:  This file contains the header file of the CCbsDbImpTopicCollection class.
       
    15 *    
       
    16 *                This class represents the topic collection stored in the database.
       
    17 *                Topic collection keeps a record of topic identities received from
       
    18 *                the network. Topic identity includes a topic name and a topic number. 
       
    19 *                These can be accessed but not modified.
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 #ifndef     CCBSDBIMPTOPICCOLLECTION_H   
       
    25 #define     CCBSDBIMPTOPICCOLLECTION_H   
       
    26 
       
    27 //  INCLUDES
       
    28 
       
    29 #include <e32base.h>
       
    30 #include <e32std.h>
       
    31 #include <s32stor.h>
       
    32 #include <f32file.h>
       
    33 #include <s32file.h>
       
    34 
       
    35 #include "MCbsDbTopicCollectionObserver.H"
       
    36 
       
    37 //  CLASS DECLARATION 
       
    38 
       
    39 class CCbsDbImp;
       
    40 
       
    41 /**
       
    42 *   This class defines the interface for handling topic collections.
       
    43 *
       
    44 *   User's Guide for accessing stored topic identities:
       
    45 *   GetTopicIdentityCount(TInt&)
       
    46 *       Retrieves the number of topic identities currently stored in the 
       
    47 *       topic collection.
       
    48 *   GetTopicIdentityL(TInt&, TCbsDbTopicIdentity&)
       
    49 *       Retrieves a single topic identity identified with an index.
       
    50 *
       
    51 *   User's Guide for observing the topic collection.
       
    52 *   AddObserverL(MCbsDbTopicCollectionObserver*)
       
    53 *       Registers an observer which is notified of changes in the topic
       
    54 *       collection.
       
    55 *   RemoveObserverL(MCbsDbTopicCollectionObserver*)
       
    56 *       Unregisters an observer.
       
    57 *
       
    58 *   User's Guide for modifying the topic collection:
       
    59 *   Clear()
       
    60 *       Clears the current topic collection. This is called by the index
       
    61 *       message parsing routine when it's about to parse a root index
       
    62 *       message. Topic identities contained in subsequent child subindex 
       
    63 *       messages, if any, are then simply added with AddTopicIdentityL()
       
    64 *   AddTopicIdentityL(TCbsDbTopicIdentity&)
       
    65 *       Adds a topic identity into the topic collection's buffer.
       
    66 *   Apply()
       
    67 *       Writes the topic identity buffer into persistent storage.
       
    68 *       Clears the buffer.
       
    69 *   
       
    70 */
       
    71 class CCbsDbImpTopicCollection : public CBase
       
    72     {
       
    73 
       
    74     public:     // New functions.
       
    75         /**
       
    76         *   Creates a new instance of the class.
       
    77         *       
       
    78         *   @return                     A pointer to the created 
       
    79         *                               CCbsDbImpTopicCollection instance.
       
    80         */
       
    81         static CCbsDbImpTopicCollection* NewL();
       
    82 
       
    83         /**
       
    84         *   Destructor. 
       
    85         */
       
    86         ~CCbsDbImpTopicCollection();
       
    87 
       
    88     public: 
       
    89         /**
       
    90         *   Returns the total amount of topic identities 
       
    91         *   the collection contans.
       
    92         *
       
    93         *   @param aCount               The method stores the topic identity
       
    94         *                               count to this variable.
       
    95         */
       
    96         void GetTopicIdentityCount( TInt& aCount ) const;
       
    97 
       
    98         /**
       
    99         *   Stores a topic identity (index is aIndex in the list) to aIdentity.
       
   100         *   The method leaves if the parameter aIndex is invalid.
       
   101         *
       
   102         *   Exceptions:
       
   103         *   KErrNotFound                The requested topic identity was not 
       
   104         *                               found.
       
   105         *
       
   106         *   @param aIndex               Used to index identities.
       
   107         *   @param aIdentity            The method stores a topic identity to 
       
   108         *                               the parameter.
       
   109         */
       
   110         void GetTopicIdentityL( 
       
   111             TInt& aIndex, 
       
   112             TCbsDbTopicIdentity& aIdentity ) const;
       
   113 
       
   114         /**
       
   115         *   Adds a topic collection observer. 
       
   116         *
       
   117         *   Panics if aObserver is null.
       
   118         *
       
   119         *   Exceptions:
       
   120         *   KErrNoMemory                OOM
       
   121         *
       
   122         *   @param aObserver            Pointer to the new observer to be added
       
   123         */
       
   124         void AddObserverL( MCbsDbTopicCollectionObserver* aObserver );
       
   125 
       
   126         /**
       
   127         *   Removes a topic collection observer. 
       
   128         *
       
   129         *   Panics if aObserver is null or aObserver is not registered
       
   130         *   as an observer.
       
   131         *
       
   132         *   @param aObserver            Pointer to the observer to be removed
       
   133         */
       
   134         void RemoveObserver( const MCbsDbTopicCollectionObserver* aObserver );
       
   135 
       
   136         /**
       
   137         *   Clears the topic collection builder's buffered topic list.
       
   138         *   This does not have any effect on identities stored in 
       
   139         *   the database.
       
   140         *
       
   141         *   This method should be called prior to parsing a root index
       
   142         *   message. Any topic identities extracted from subindex messages
       
   143         *   should be appended into collection with AddTopicIdentityL()
       
   144         *   without any call to Clear().
       
   145         */
       
   146         void Clear();
       
   147 
       
   148         /**
       
   149         *   Stores topic identities which were added to the topic 
       
   150         *   collection with AddTopicIdentityL() after previous call to 
       
   151         *   Apply().
       
   152         *
       
   153         */
       
   154         void Apply();
       
   155 
       
   156         /**
       
   157         *   Adds a new topic identity to the buffered collection.
       
   158         *   A topic identity contains topic name and number. If the
       
   159         *   topic exists already, nothing is done.
       
   160         *   
       
   161         *   This method will return KErrAlreadyExists, if there is already 
       
   162         *   another topic identity that has the same number.
       
   163         *
       
   164         *   Exceptions:
       
   165         *   KErrNoMemory                OOM
       
   166         *   KErrArgument                Topic number of the given identity is
       
   167         *                               out of valid range.
       
   168         *
       
   169         *   @param  aIdentity           Topic identity to be added.
       
   170         */
       
   171         void AddTopicIdentityL( const TCbsDbTopicIdentity& aIdentity );
       
   172 
       
   173     private:
       
   174 
       
   175         /**
       
   176         *   Constructor. 
       
   177         *
       
   178         */
       
   179         CCbsDbImpTopicCollection();
       
   180 
       
   181         /**
       
   182         *   Finalizes the construction.
       
   183         *
       
   184         */
       
   185         void ConstructL();
       
   186 
       
   187         /**
       
   188         *   Notifies topic collection observers about changed topic 
       
   189         *   collection.
       
   190         */       
       
   191         void NotifyObservers();
       
   192 
       
   193     private:
       
   194 
       
   195         // Own: Contains the observers.
       
   196         CArrayFixFlat< MCbsDbTopicCollectionObserver* >* iObservers;
       
   197 
       
   198         // Own: Contains buffered topic identities.
       
   199         CArrayFix< TCbsDbTopicIdentity >* iIdentities;
       
   200 
       
   201     };
       
   202 
       
   203 #endif      //  CCBSDBIMPTOPICCOLLECTION_H   
       
   204             
       
   205 // End of File