smf/smfservermodule/smfclient/common/smfmusicrating.cpp
changeset 18 013a02bf2bb0
parent 17 106a4bfcb866
child 19 c412f0526c34
equal deleted inserted replaced
17:106a4bfcb866 18:013a02bf2bb0
     1 /**
       
     2  * Copyright (c) 2010 Sasken Communication Technologies Ltd.
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the "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  * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
       
    11  *
       
    12  * Contributors:
       
    13  * Manasij Roy, Nalina Hariharan
       
    14  * 
       
    15  * Description:
       
    16  * The music rating class represents an instance of rating 
       
    17  * about a music track
       
    18  *
       
    19  */
       
    20 
       
    21 #include "smfmusicrating.h"
       
    22 #include "smfmusicrating_p.h"
       
    23 
       
    24 /**
       
    25  * Constructor with default argument
       
    26  * @param aParent The SmfTrackInfo instance
       
    27  */
       
    28 SmfMusicRating::SmfMusicRating( SmfTrackInfo *aParent )
       
    29 	{
       
    30 	Q_UNUSED(aParent)
       
    31 	d = new SmfMusicRatingPrivate();
       
    32 	}
       
    33 
       
    34 /**
       
    35  * Copy Constructor
       
    36  * @param aOther The reference object
       
    37  */
       
    38 SmfMusicRating::SmfMusicRating( const SmfMusicRating &aOther )
       
    39 	: d( aOther.d )
       
    40 	{
       
    41 	}
       
    42 
       
    43 /**
       
    44  * Overloaded = operator 
       
    45  * @param aOther The reference object
       
    46  */
       
    47 SmfMusicRating& SmfMusicRating::operator=( const SmfMusicRating &aOther )
       
    48 	{
       
    49 	d->m_rating = aOther.d->m_rating;
       
    50 	d->m_max = aOther.d->m_max;
       
    51 	d->m_min = aOther.d->m_min;
       
    52 	return *this;
       
    53 	}
       
    54 
       
    55 /**
       
    56  * Destructor
       
    57  */
       
    58 SmfMusicRating::~SmfMusicRating( )
       
    59 	{
       
    60 	}
       
    61 
       
    62 /**
       
    63  * Method to get the rating
       
    64  * @return The rating value
       
    65  */
       
    66 int SmfMusicRating::rating( ) const
       
    67 	{
       
    68 	return d->m_rating;
       
    69 	}
       
    70 
       
    71 /**
       
    72  * Method to get the max rating
       
    73  * @return The max rating value
       
    74  */
       
    75 int SmfMusicRating::maxRating( ) const
       
    76 	{
       
    77 	return d->m_max;
       
    78 	}
       
    79 
       
    80 /**
       
    81  * Method to get the min rating
       
    82  * @return The min rating value
       
    83  */
       
    84 int SmfMusicRating::minRating( ) const
       
    85 	{
       
    86 	return d->m_min;
       
    87 	}
       
    88 
       
    89 /**
       
    90  * Method to set the rating
       
    91  * @param aRating The rating value
       
    92  */
       
    93 void SmfMusicRating::setRating( const int &aRating )
       
    94 	{
       
    95 	d->m_rating = aRating;
       
    96 	}
       
    97 
       
    98 /**
       
    99  * Method to set the max rating
       
   100  * @param aMax The max rating value
       
   101  */
       
   102 void SmfMusicRating::setMaxRating( const int &aMax )
       
   103 	{
       
   104 	d->m_max = aMax;
       
   105 	}
       
   106 
       
   107 /**
       
   108  * Method to set the min rating
       
   109  * @param aMin The min rating value
       
   110  */
       
   111 void SmfMusicRating::setMinRating( const int &aMin )
       
   112 	{
       
   113 	d->m_min = aMin;
       
   114 	}
       
   115 
       
   116 
       
   117 /**
       
   118  * Method for Externalization. Writes the SmfMusicRating object to 
       
   119  * the stream and returns a reference to the stream.
       
   120  * @param aDataStream Stream to be written
       
   121  * @param aMusicRating The SmfMusicRating object to be externalized
       
   122  * @return reference to the written stream
       
   123  */
       
   124 QDataStream &operator<<( QDataStream &aDataStream, 
       
   125 		const SmfMusicRating &aMusicRating )
       
   126 	{
       
   127 	// Serialize d->m_rating
       
   128 	aDataStream<<aMusicRating.d->m_rating;
       
   129 	
       
   130 	// Serialize d->m_max
       
   131 	aDataStream<<aMusicRating.d->m_max;
       
   132 	
       
   133 	// Serialize d->m_min
       
   134 	aDataStream<<aMusicRating.d->m_min;
       
   135 	
       
   136 	return aDataStream;
       
   137 	}
       
   138 
       
   139 /**
       
   140  * Method for Internalization. Reads a SmfMusicRating object from 
       
   141  * the stream and returns a reference to the stream.
       
   142  * @param aDataStream Stream to be read
       
   143  * @param aMusicRating The SmfMusicRating object to be internalized
       
   144  * @return reference to the stream
       
   145  */
       
   146 QDataStream &operator>>( QDataStream &aDataStream, 
       
   147 		SmfMusicRating &aMusicRating)
       
   148 	{
       
   149 	// Deserialize d->m_rating
       
   150 	aDataStream>>aMusicRating.d->m_rating;
       
   151 	
       
   152 	// Deserialize d->m_max
       
   153 	aDataStream>>aMusicRating.d->m_max;
       
   154 	
       
   155 	// Deserialize d->m_min
       
   156 	aDataStream>>aMusicRating.d->m_min;
       
   157 	
       
   158 	return aDataStream;
       
   159 	}
       
   160