TodoList Class Reference

#include <PageInfo.h>

List of all members.

Public Member Functions

 TodoList ()
 ~TodoList ()
void clear ()
void pushItem (TodoItem *item, GBool bHead=gFalse, GBool bRemoveDup=gTrue)
TodoItempopItem ()

Private Member Functions

void initialize ()
void removeDup (TodoItem *item)

Private Attributes

pthread_mutex_t mutex
GooList * list


Detailed Description

Definition at line 120 of file PageInfo.h.


Constructor & Destructor Documentation

TodoList::TodoList (  ) 

Definition at line 296 of file PageInfo.cpp.

00297 {
00298     initialize();
00299 }

Here is the call graph for this function:

TodoList::~TodoList (  ) 

Definition at line 301 of file PageInfo.cpp.

00302 {
00303     clear();
00304     delete list; list = NULL;
00305     pthread_mutex_destroy(&mutex); 
00306 }

Here is the call graph for this function:


Member Function Documentation

void TodoList::initialize (  )  [private]

Definition at line 308 of file PageInfo.cpp.

00309 {
00310     pthread_mutex_init(&mutex, NULL);
00311     list = new GooList();
00312 }

void TodoList::removeDup ( TodoItem item  )  [private]

Definition at line 326 of file PageInfo.cpp.

00327 {
00328     int i = 0, length = list->getLength();
00329     TodoItem * p = NULL;
00330     while (i < length)
00331     {
00332         p = (TodoItem *)list->get(i); 
00333         if ( p && item && p->pageNumber == item->pageNumber && item->timeStamp > p->timeStamp)
00334         {
00335             // PV_LOGPRINTF("Remove duplicated item %d", item->pageNumber);
00336             list->del(i); --length;
00337         }
00338         else
00339         {
00340             ++i;
00341         }
00342     }        
00343 }

void TodoList::clear (  ) 

Definition at line 314 of file PageInfo.cpp.

00315 {
00316     pthread_mutex_lock(&mutex);
00317     TodoItem *pItem = NULL;
00318     while (list->getLength())
00319     {
00320         pItem = (TodoItem *)list->del(0);
00321         delete pItem;
00322     }
00323     pthread_mutex_unlock(&mutex);
00324 }

void TodoList::pushItem ( TodoItem item,
GBool  bHead = gFalse,
GBool  bRemoveDup = gTrue 
)

Definition at line 345 of file PageInfo.cpp.

00346 {
00347     if (NULL == item) return;
00348     pthread_mutex_lock(&mutex);
00349 
00350     if (bRemoveDup)
00351     {
00352         removeDup(item);
00353     }
00354     if (bHead)
00355     {
00356         list->insert(0, item);
00357     }
00358     else
00359     {
00360         list->append(item);
00361     }
00362     pthread_mutex_unlock(&mutex);
00363 }

Here is the call graph for this function:

TodoItem * TodoList::popItem (  ) 

Definition at line 365 of file PageInfo.cpp.

00366 {
00367     TodoItem * item = NULL;
00368     pthread_mutex_lock(&mutex);
00369     if (list->getLength() > 0) 
00370     {
00371         item = (TodoItem *)list->del(0);
00372     }
00373     pthread_mutex_unlock(&mutex);
00374     return item;
00375 }


Member Data Documentation

pthread_mutex_t TodoList::mutex [private]

Definition at line 123 of file PageInfo.h.

GooList* TodoList::list [private]

Definition at line 124 of file PageInfo.h.


The documentation for this class was generated from the following files:

Generated on Wed Feb 4 18:26:36 2009 by  doxygen 1.5.6