mmappfw_plat/mpx_common_api/inc/mpxmediabase.h
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2006, 2007 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:  Encapsulates media base class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CMPXMEDIABASE_H
       
    21 #define CMPXMEDIABASE_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <s32strm.h>
       
    25 #include <mpxdata.h>
       
    26 #include <e32hashtab.h>
       
    27 
       
    28 //  FORWARD DECLARATIONS
       
    29 
       
    30 /**
       
    31 *  Base class of global data classes.
       
    32 *
       
    33 *  @lib mpxcommon.lib
       
    34 */
       
    35 NONSHARABLE_CLASS(CMPXMediaBase) : public CBase
       
    36     {
       
    37 protected:
       
    38     /**
       
    39     * Encapsulates a local value, uid and corresponding attribute type.
       
    40     *
       
    41     * @lib mpxcommon.lib
       
    42     */
       
    43     class TValue
       
    44         {
       
    45     public:
       
    46         /**
       
    47          * C++ constuctor.
       
    48          *
       
    49          * @since S60 3.2.3
       
    50          * @param aValue pointer to the object of the media attribute
       
    51          * @param aUid uid of the object
       
    52          * @param aType type of the media attribute
       
    53          */
       
    54         inline TValue(TAny* aValue,TInt aUid,TMPXAttributeType aType);
       
    55         
       
    56     public:
       
    57         TAny* iValue;
       
    58         TInt iUid;
       
    59         TMPXAttributeType iType;
       
    60         };
       
    61 protected:
       
    62      /**
       
    63      * C++ default constructor.
       
    64      *
       
    65      * @since S60 3.2.3
       
    66      */
       
    67     CMPXMediaBase();
       
    68 
       
    69     /**
       
    70      * Destructor.
       
    71      *
       
    72      * @since S60 3.2.3
       
    73      */
       
    74     ~CMPXMediaBase();
       
    75 
       
    76     /**
       
    77     *  2nd phase contructor.
       
    78     *
       
    79     *  @since S60 3.2.3
       
    80     */
       
    81     void ConstructL();
       
    82 
       
    83     /**
       
    84     *  2nd phase contructor.
       
    85     *
       
    86     *  @since S60 3.2.3
       
    87     *  @param aBase media base object to be copied
       
    88     */
       
    89     void ConstructL(const CMPXMediaBase& aBase);
       
    90 
       
    91     /**
       
    92     *  2nd phase contructor.
       
    93     *
       
    94     *  @since S60 3.2.3
       
    95     *  @param aDataHandle data handle to the global object to be copied
       
    96     */
       
    97     void ConstructL(TInt aDataHandle);
       
    98 
       
    99     /**
       
   100     *  2nd phase contructor.
       
   101     *
       
   102     *  @since S60 3.2.3
       
   103     *  @param aDataHandle data handle to the global oject to be copied
       
   104     *  @param aData data object to be copied
       
   105     *  @leave KErrArgument DataHandle is zero
       
   106     */
       
   107     void ConstructL(TInt aDataHandle,MMPXData& aData);
       
   108 
       
   109     /**
       
   110     *  2nd phase contructor.
       
   111     *
       
   112     *  @since S60 3.2.3
       
   113     *  @param aBase media base object to be copied. Deep copy.
       
   114     */
       
   115     void CopyConstructL(const CMPXMediaBase& aBase);
       
   116 
       
   117 protected:
       
   118     /**
       
   119     * Clears all data associated with this object; ready to
       
   120     * be assigned new data.
       
   121     *
       
   122     * @since S60 3.2.3
       
   123     */
       
   124     void Clear();
       
   125 
       
   126     /**
       
   127     * Clears locally cached contents.
       
   128     *
       
   129     * @since S60 3.2.3
       
   130     */
       
   131     virtual void ResetLocal();
       
   132 
       
   133     /**
       
   134     * Locally stored value, or NULL if not stored locally.
       
   135     *
       
   136     * @since S60 3.2.3
       
   137     * @param aUid uid of the media attribute
       
   138     * @return TValue object which holds local copy of the object
       
   139     */
       
   140     const TValue* LocalValue(TInt aUid) const;
       
   141     
       
   142     /**
       
   143     * Set locally held data.
       
   144     * 
       
   145     * @since S60 3.2.3
       
   146     * @param aValue value to be held
       
   147     * @return KErrNone or KErrNoMemory
       
   148     */
       
   149     int SetLocal(const TValue& aValue);
       
   150 
       
   151     /**
       
   152      * Delete locally by index.
       
   153      *
       
   154      * @since S60 3.2.3
       
   155      * @param aIndex index to the values array
       
   156      */
       
   157     void DeleteLocal(TInt aIndex);
       
   158 
       
   159     /**
       
   160     * Delete a pointer.
       
   161     *
       
   162     * @since S60 3.2.3
       
   163     * @param aValue value to be deleted
       
   164     * @aType media attribute type
       
   165     */
       
   166     void DeletePtr(TAny* aValue,TMPXAttributeType aType);
       
   167 
       
   168     /**
       
   169     * Externalize media object.
       
   170     *
       
   171     * @since S60 3.2.3
       
   172     * @param aStream reference to the stream object
       
   173     * @param aType object type
       
   174     */
       
   175     void DoExternalizeL(RWriteStream& aStream,MMPXData::TMPXObjectType aType) const;
       
   176 
       
   177     /**
       
   178     * Internalize media object.
       
   179     *
       
   180     * @since S60 3.2.3
       
   181     * @param aStream reference to the stream object
       
   182     * @param aType object type
       
   183     * @leave KErrArgument aType is invalid
       
   184     */
       
   185     void DoInternalizeL(RReadStream& aStream,MMPXData::TMPXObjectType aType);
       
   186 
       
   187     /**
       
   188     * Number of values.
       
   189     *
       
   190     * @since S60 3.2.3
       
   191     * @return number of media attributes in the global data
       
   192     */
       
   193     inline TInt Count() const;
       
   194 
       
   195     /**
       
   196     *  Lock heap and push UnlockHeap into cleanupstack.
       
   197     *
       
   198     * @since S60 3.2.3
       
   199     */
       
   200     void LockHeapLC() const;
       
   201 
       
   202     /**
       
   203     *  Cleanup operation which will be invoked by the CleanupStack::PopAndDestroy().
       
   204     *
       
   205     *  @since S60 3.2.3
       
   206     *  @param aMediaBase a media based object
       
   207     */
       
   208     static void UnlockHeap(TAny* aMediaBase);
       
   209 
       
   210 private:
       
   211     /**
       
   212     * Delete locally held data.
       
   213     * 
       
   214     * @since S60 3.2.3
       
   215     * @param aUid Uid of the value to be deleted
       
   216     */
       
   217     void DeleteLocalByUid(const TInt aUid);
       
   218 
       
   219 protected:
       
   220     TUint iClientHandle; // Thread relative
       
   221     TUint iDataHandle; // Global
       
   222     MMPXData* iData; // Thread relative
       
   223 private:    
       
   224     RHashMap<TInt, TValue> iValues;
       
   225     };
       
   226 
       
   227 #include "mpxmediabase.inl"
       
   228 
       
   229 #endif // CMPXMEDIABASE_H