SASC
DVBSoftCAM

cListBase Class Reference

#include <tools.h>

Inheritance diagram for cListBase:

List of all members.

Public Member Functions

virtual ~cListBase ()
void Add (cListObject *Object, cListObject *After=NULL)
void Ins (cListObject *Object, cListObject *Before=NULL)
void Del (cListObject *Object, bool DeleteObject=true)
virtual void Move (int From, int To)
void Move (cListObject *From, cListObject *To)
virtual void Clear (void)
cListObject * Get (int Index) const
int Count (void) const
void Sort (void)

Protected Member Functions

 cListBase (void)

Protected Attributes

cListObject * objects
cListObject * lastObject
int count

Detailed Description

Definition at line 375 of file tools.h.


Constructor & Destructor Documentation

cListBase::cListBase ( void  ) [protected]

Definition at line 955 of file tools.cpp.

References count, lastObject, NULL, and objects.

{ 
  objects = lastObject = NULL;
  count = 0;
}
cListBase::~cListBase ( ) [virtual]

Definition at line 961 of file tools.cpp.

References Clear().

{
  Clear();
}

Member Function Documentation

void cListBase::Add ( cListObject *  Object,
cListObject *  After = NULL 
)

Definition at line 966 of file tools.cpp.

References cListObject::Append(), count, cListObject::Insert(), lastObject, cListObject::Next(), and objects.

Referenced by cHashBase::Add(), cConfig< cTimer >::Load(), process_cam(), and Sort().

{ 
  if (After && After != lastObject) {
     After->Next()->Insert(Object);
     After->Append(Object);
     }
  else {
     if (lastObject)
        lastObject->Append(Object);
     else
        objects = Object;
     lastObject = Object;
     }
  count++;
}
void cListBase::Clear ( void  ) [virtual]

Reimplemented in cOsdMenu, and cSkins.

Definition at line 1039 of file tools.cpp.

References count, lastObject, cListObject::Next(), NULL, and objects.

Referenced by ~cListBase().

{
  while (objects) {
        cListObject *object = objects->Next();
        delete objects;
        objects = object;
        }
  objects = lastObject = NULL;
  count = 0;
}
int cListBase::Count ( void  ) const [inline]

Definition at line 389 of file tools.h.

References count.

Referenced by Sort().

{ return count; }
void cListBase::Del ( cListObject *  Object,
bool  DeleteObject = true 
)

Definition at line 998 of file tools.cpp.

References count, lastObject, cListObject::Next(), objects, cListObject::Prev(), and cListObject::Unlink().

Referenced by cHashBase::Del(), and process_cam().

{
  if (Object == objects)
     objects = Object->Next();
  if (Object == lastObject)
     lastObject = Object->Prev();
  Object->Unlink();
  if (DeleteObject)
     delete Object;
  count--;
}
void cListBase::Ins ( cListObject *  Object,
cListObject *  Before = NULL 
)

Definition at line 982 of file tools.cpp.

References cListObject::Append(), count, cListObject::Insert(), lastObject, objects, and cListObject::Prev().

{ 
  if (Before && Before != objects) {
     Before->Prev()->Append(Object);
     Before->Insert(Object);
     }
  else {
     if (objects)
        objects->Insert(Object);
     else
        lastObject = Object;
     objects = Object;
     }
  count++;
}
void cListBase::Move ( int  From,
int  To 
) [virtual]

Definition at line 1010 of file tools.cpp.

References Get().

{
  Move(Get(From), Get(To));
}
void cListBase::Move ( cListObject *  From,
cListObject *  To 
)

Definition at line 1015 of file tools.cpp.

References cListObject::Append(), cListObject::Index(), lastObject, cListObject::Next(), objects, cListObject::Prev(), and cListObject::Unlink().

{
  if (From && To) {
     if (From->Index() < To->Index())
        To = To->Next();
     if (From == objects)
        objects = From->Next();
     if (From == lastObject)
        lastObject = From->Prev();
     From->Unlink();
     if (To) {
        if (To->Prev())
           To->Prev()->Append(From);
        From->Append(To);
        }
     else {
        lastObject->Append(From);
        lastObject = From;
        }
     if (!From->Prev())
        objects = From;
     }
}
void cListBase::Sort ( void  )

Reimplemented in cMarks.

Definition at line 1067 of file tools.cpp.

References Add(), CompareListObjects(), count, Count(), i, lastObject, cListObject::Next(), NULL, objects, and cListObject::Unlink().

{
  int n = Count();
  cListObject *a[n];
  cListObject *object = objects;
  int i = 0;
  while (object && i < n) {
        a[i++] = object;
        object = object->Next();
        }
  qsort(a, n, sizeof(cListObject *), CompareListObjects);
  objects = lastObject = NULL;
  for (i = 0; i < n; i++) {
      a[i]->Unlink();
      count--;
      Add(a[i]);
      }
}

Member Data Documentation

int cListBase::count [protected]

Definition at line 379 of file tools.h.

Referenced by Add(), Clear(), cListBase(), Del(), Ins(), and Sort().

Definition at line 377 of file tools.h.

Referenced by Add(), Clear(), cListBase(), Del(), Ins(), Move(), and Sort().

Definition at line 377 of file tools.h.

Referenced by Add(), Clear(), cListBase(), Del(), Get(), Ins(), Move(), and Sort().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines