mmresourcemgmt/mmresctrl/inc/mmrcutil.h
changeset 45 5accba95f577
parent 0 40261b775718
child 50 948c7f65f6d4
equal deleted inserted replaced
44:e358f888b1fe 45:5accba95f577
   269 	T* PopAndRemoveForPause( TInt aIndex );
   269 	T* PopAndRemoveForPause( TInt aIndex );
   270 	T* operator[] ( TInt aIndex ) const;
   270 	T* operator[] ( TInt aIndex ) const;
   271 
   271 
   272 
   272 
   273 private:
   273 private:
   274 	RPointerArray< T >  todo;
   274 	RPointerArray< T >  iQueue;
   275 	};
   275 	};
   276 
   276 
   277 
   277 
   278 /**
   278 /**
   279  Construct the queue.
   279  Construct the queue.
   287  Destructor.
   287  Destructor.
   288 */
   288 */
   289 template <class T>
   289 template <class T>
   290 RMMRCFifoOrderQueue<T>::~RMMRCFifoOrderQueue( )
   290 RMMRCFifoOrderQueue<T>::~RMMRCFifoOrderQueue( )
   291 	{
   291 	{
   292 	todo.Reset();
   292 	iQueue.Reset();
   293 	todo.Close();
   293 	iQueue.Close();
   294 	}
   294 	}
   295 	
   295 	
   296 /**
   296 /**
   297  Return the number of elements.
   297  Return the number of elements.
   298 */
   298 */
   299 template <class T>
   299 template <class T>
   300 TInt RMMRCFifoOrderQueue<T>::Count( ) const
   300 TInt RMMRCFifoOrderQueue<T>::Count( ) const
   301 	{
   301 	{
   302 	
   302 	
   303 	TInt iNum = todo.Count();
   303 	TInt iNum = iQueue.Count();
   304 	return iNum;
   304 	return iNum;
   305 	}	
   305 	}	
   306 
   306 
   307 /**
   307 /**
   308  Delete each node and each element.
   308  Delete each node and each element.
   309 */
   309 */
   310 template <class T>
   310 template <class T>
   311 void RMMRCFifoOrderQueue<T>::ResetAndDestroy( )
   311 void RMMRCFifoOrderQueue<T>::ResetAndDestroy( )
   312 	{
   312 	{
   313 	todo.ResetAndDestroy();
   313 	iQueue.ResetAndDestroy();
   314 	}
   314 	}
   315 
   315 
   316 /**
   316 /**
   317  Insert aElement into the queue and ordered.
   317  Insert aElement into the queue and ordered.
   318 */
   318 */
   319 template <class T>
   319 template <class T>
   320 void RMMRCFifoOrderQueue<T>::PushL( T const* const aElement )
   320 void RMMRCFifoOrderQueue<T>::PushL( T const* const aElement )
   321 	{
   321 	{
   322 	TInt numElements = todo.Count();
   322 	TInt numElements = iQueue.Count();
   323 	
   323 	
   324 	if( numElements == 0 )
   324 	if( numElements == 0 )
   325 		{
   325 		{
   326 		todo.Append(aElement); //TODO: We need to check the error here
   326 		iQueue.Append(aElement); //iQueue: We need to check the error here
   327 		return;
   327 		return;
   328 		}
   328 		}
   329 	
   329 	
   330 	for(TInt i(0); i<numElements ; ++i)
   330 	for(TInt i(0); i<numElements ; ++i)
   331 		{
   331 		{
   332 		if(aElement->HasMultimediaCapability() && !(todo[i]->HasMultimediaCapability()))
   332 		if(aElement->HasMultimediaCapability() && !(iQueue[i]->HasMultimediaCapability()))
   333 			{
   333 			{
   334 			todo.Insert(aElement, i);
   334 			iQueue.Insert(aElement, i);
   335 			return;
   335 			return;
   336 			}
   336 			}
   337 		else if(aElement->HasMultimediaCapability() == todo[i]->HasMultimediaCapability())	
   337 		else if(aElement->HasMultimediaCapability() == iQueue[i]->HasMultimediaCapability())	
   338 			{
   338 			{
   339 			if (aElement->GetPriority() > todo[i]->GetPriority())
   339 			if (aElement->GetPriority() > iQueue[i]->GetPriority())
   340 			 	{
   340 			 	{
   341 				todo.Insert(aElement,i);
   341 				iQueue.Insert(aElement,i);
   342 				return;
   342 				return;
   343 			 	}			
   343 			 	}			
   344 			}
   344 			}
   345 		}
   345 		}
   346 	todo.Insert(aElement,numElements);
   346 	iQueue.Insert(aElement,numElements);
   347 	}
   347 	}
   348 	
   348 	
   349 /**
   349 /**
   350  Return and remove the inserted item from the queue.
   350  Return and remove the inserted item from the queue.
   351 */
   351 */
   352 template <class T>
   352 template <class T>
   353 T* RMMRCFifoOrderQueue<T>::PopAndRemoveForPause( TInt aIndex )
   353 T* RMMRCFifoOrderQueue<T>::PopAndRemoveForPause( TInt aIndex )
   354 	{
   354 	{
   355 	T* aux = NULL;
   355 	T* aux = NULL;
   356 	aux = todo[aIndex];
   356 	aux = iQueue[aIndex];
   357 	todo.Remove(aIndex);	
   357 	iQueue.Remove(aIndex);	
   358 	return aux;
   358 	return aux;
   359 	}
   359 	}
   360 
   360 
   361 
   361 
   362 /**
   362 /**
   363  Pop a pointer of the aIndex elements.
   363  Pop a pointer of the aIndex elements.
   364 */
   364 */
   365 template <class T>
   365 template <class T>
   366 T* RMMRCFifoOrderQueue<T>::operator[] ( TInt aIndex ) const
   366 T* RMMRCFifoOrderQueue<T>::operator[] ( TInt aIndex ) const
   367 	{
   367 	{
   368 	if(todo.Count() != 0)
   368 	if(iQueue.Count() != 0)
   369 		{
   369 		{
   370 		return todo[aIndex];
   370 		return iQueue[aIndex];
   371 		}
   371 		}
   372 	else
   372 	else
   373 		{
   373 		{
   374 		return NULL;
   374 		return NULL;
   375 		}
   375 		}