Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Private Types | Private Attributes
nsComponentList Class Reference

#include <nsComponentList.h>

Collaboration diagram for nsComponentList:
Collaboration graph
[legend]

List of all members.

Classes

struct  _nsComponentItem

Public Member Functions

 nsComponentList ()
 ~nsComponentList ()
nsComponentGetHead ()
 

GetHead

nsComponentGetNext ()
 GetNext.
nsComponentGetTail ()
 GetTail.
int GetLength ()
 GetLength.
int GetLengthVisible ()
 GetLengthVisible.
int GetLengthSelected ()
 GetLengthSelected.
int AddComponent (nsComponent *aComponent)
 AddComponent.
int RemoveComponent (nsComponent *aComponent)
 RemoveComponent.
nsComponentGetCompByIndex (int aIndex)
 GetCompByIndex.
nsComponentGetCompByArchive (char *aArchive)
 GetCompByArchive.
nsComponentGetCompByShortDesc (char *aShortDesc)
 GetCompByShortDesc.
nsComponentGetFirstVisible ()
 GetFirstVisible.
 nsComponentList ()
 ~nsComponentList ()
nsComponentGetHead ()
 

GetHead

nsComponentGetNext ()
 GetNext.
nsComponentGetTail ()
 GetTail.
int GetLength ()
 GetLength.
int GetLengthVisible ()
 GetLengthVisible.
int GetLengthSelected ()
 GetLengthSelected.
int AddComponent (nsComponent *aComponent)
 AddComponent.
int RemoveComponent (nsComponent *aComponent)
 RemoveComponent.
nsComponentGetCompByIndex (int aIndex)
 GetCompByIndex.
nsComponentGetCompByArchive (char *aArchive)
 GetCompByArchive.
nsComponentGetCompByShortDesc (char *aShortDesc)
 GetCompByShortDesc.
nsComponentGetFirstVisible ()
 GetFirstVisible.

Private Types

typedef struct
nsComponentList::_nsComponentItem 
nsComponentItem

Private Attributes

nsComponentmHead
nsComponentmTail
nsComponentmNext
int mLength
nsComponentItemmHeadItem
nsComponentItemmTailItem
nsComponentItemmNextItem

Detailed Description

Definition at line 47 of file nsComponentList.h.


Class Documentation

struct nsComponentList::_nsComponentItem

Definition at line 175 of file nsComponentList.h.

Collaboration diagram for nsComponentList::_nsComponentItem:
Class Members
nsComponent * mComp
struct _nsComponentItem * mNext

Member Typedef Documentation


Constructor & Destructor Documentation

Definition at line 43 of file nsComponentList.cpp.

                                 :
    mHead(NULL),
    mTail(NULL),
    mNext(NULL),
    mLength(0)
{
}

Definition at line 51 of file nsComponentList.cpp.

{
    nsComponent *curr = mHead;
    nsComponent *next = NULL;

    while (curr)
    {
        next = NULL;
        next = curr->GetNext();
        curr->Release();
        curr = next;
    }

    mHead = NULL;
    mTail = NULL;
    mLength = 0;
}

Here is the call graph for this function:


Member Function Documentation

AddComponent.

Adds the supplied component to the list's tail.

Parameters:
aComponentthe component to add
Returns:
err integer err code (zero means OK)

Definition at line 156 of file nsComponentList.cpp.

{
    if (!aComponent)
        return E_PARAM;

    // empty list: head and tail are the same -- the new comp
    if (!mHead)
    {
        mHead = aComponent;
        mHead->InitNext();
        mTail = mHead;
        aComponent->AddRef();
        mLength = 1;
        mHead->SetIndex(0);

        return OK;
    }

    // non-empty list: the new comp is tacked on and tail is updated
    mTail->SetNext(aComponent);
    mTail = aComponent;
    mTail->InitNext();
    aComponent->AddRef();
    mLength++;
    mTail->SetIndex(mLength - 1);

    return OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

AddComponent.

Adds the supplied component to the list's tail.

Parameters:
aComponentthe component to add
Returns:
err integer err code (zero means OK)

GetCompByArchive.

Searches the list and returns the first component that matches the archive name supplied.

Parameters:
aArchivethe archive name of the component
Returns:
comp the component matching the archive

Definition at line 249 of file nsComponentList.cpp.

{
    nsComponent *comp = GetHead();
    int i;

    // param check
    if (!comp || mLength == 0 || !aArchive) return NULL;

    for (i=0; i<mLength; i++)
    { 
        if (0==strncmp(aArchive, comp->GetArchive(), strlen(aArchive)))
            return comp;

        comp = GetNext();
        if (!comp) break;
    }

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GetCompByArchive.

Searches the list and returns the first component that matches the archive name supplied.

Parameters:
aArchivethe archive name of the component
Returns:
comp the component matching the archive

GetCompByIndex.

Searches the list and returns the first component that matches the supplied index.

Parameters:
aIndexthe index of the component being sought
Returns:
comp the component matching the index

GetCompByIndex.

Searches the list and returns the first component that matches the supplied index.

Parameters:
aIndexthe index of the component being sought
Returns:
comp the component matching the index

Definition at line 228 of file nsComponentList.cpp.

{
    nsComponent *comp = GetHead();
    int i;

    // param check
    if (!comp || mLength == 0) return NULL;

    for (i=0; i<mLength; i++)
    { 
        if (aIndex == comp->GetIndex())
            return comp;

        comp = GetNext();
        if (!comp) break;
    }

    return NULL;
}

Here is the call graph for this function:

GetCompByShortDesc.

Searches the list and returns the first component that matches the short description supplied.

Parameters:
aShortDescthe short description of the component
Returns:
comp the component matching the short description

GetCompByShortDesc.

Searches the list and returns the first component that matches the short description supplied.

Parameters:
aShortDescthe short description of the component
Returns:
comp the component matching the short description

Definition at line 270 of file nsComponentList.cpp.

{
    nsComponent *comp = GetHead();
    int i;

    // param check
    if (!comp || mLength == 0 || !aShortDesc) return NULL;

    for (i=0; i<mLength; i++)
    { 
        if (0==strncmp(aShortDesc, comp->GetDescShort(), 
                       strlen(aShortDesc)))
            return comp;

        comp = GetNext();
        if (!comp) break;
    }

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GetFirstVisible.

Returns the first component that doesn't have the invisible attribute set.

Returns:
comp the first visible component in this list

Definition at line 292 of file nsComponentList.cpp.

{
    int i;
    nsComponent *comp = GetHead();

    // param check
    if (mLength == 0) return NULL;

    for (i=0; i<mLength; i++)
    { 
        if (!comp->IsInvisible())
            return comp;

        comp = GetNext();
        if (!comp) break;
    }

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GetFirstVisible.

Returns the first component that doesn't have the invisible attribute set.

Returns:
comp the first visible component in this list

GetHead

Initializes the next ptr to the second item and returns the head item.

Returns:
mHead the head of the singly-linked list

Definition at line 70 of file nsComponentList.cpp.

{
    if (mHead)
    {
        mNext = mHead->GetNext();
        return mHead;
    }

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GetHead

Initializes the next ptr to the second item and returns the head item.

Returns:
mHead the head of the singly-linked list

GetLength.

Returns the number of components held by this list.

Returns:
mLength the size of this list

GetLength.

Returns the number of components held by this list.

Returns:
mLength the size of this list

Definition at line 105 of file nsComponentList.cpp.

{
    return mLength;
}

Here is the caller graph for this function:

GetLengthSelected.

Returns the number of selected components held by this list.

Returns:
numSleected the number of selected components

GetLengthSelected.

Returns the number of selected components held by this list.

Returns:
numSleected the number of selected components

Definition at line 130 of file nsComponentList.cpp.

{
    int numSelected = 0;
    nsComponent *curr;

    /* NOTE:
     * ----
     * If copies of components are help by this list rather than pointers 
     * then this method will return an inaccurate number.  Due to 
     * architecture be very careful when using this method.
     */

    curr = mHead;
    if (!curr) return 0;

    while (curr)
    {
        if (!curr->IsSelected())
            numSelected++;
        curr = curr->GetNext();
    }
        
    return numSelected;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GetLengthVisible.

Returns the number of visible components held by this list.

Returns:
numVisible the number of visible components

GetLengthVisible.

Returns the number of visible components held by this list.

Returns:
numVisible the number of visible components

Definition at line 111 of file nsComponentList.cpp.

{
    int numVisible = 0;
    nsComponent *curr;

    curr = mHead;
    if (!curr) return 0;

    while (curr)
    {
        if (!curr->IsInvisible())
            numVisible++;
        curr = curr->GetNext();
    }
        
    return numVisible;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GetNext.

Returns the next available item. GetHead() has to have been called prior calling this and after the last time the entire list was iterated over.

Returns:
mNext the next available component

Definition at line 82 of file nsComponentList.cpp.

{
    nsComponent *curr = mNext;

    if (mNext)
    {
        mNext = mNext->GetNext();
        return curr;        
    }

    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GetNext.

Returns the next available item. GetHead() has to have been called prior calling this and after the last time the entire list was iterated over.

Returns:
mNext the next available component

GetTail.

Returns the tail item of the list.

Returns:
mTail the tail item of the list

Definition at line 96 of file nsComponentList.cpp.

{
    if (mTail)
        return mTail;

    return NULL;
}

GetTail.

Returns the tail item of the list.

Returns:
mTail the tail item of the list

RemoveComponent.

Searches the list and removes the first component that matches the supplied component.

Parameters:
aComponentthe component to remove
Returns:
err integer error code (zero means OK)

Definition at line 186 of file nsComponentList.cpp.

{
    int err = OK;
    nsComponent *curr = GetHead();
    nsComponent *last = NULL;

    if (!aComponent)
        return E_PARAM;

    while (curr)
    {
        if (aComponent == curr)
        {
            // remove and link last to next while deleting current
            if (last)
            {
                last->SetNext(curr->GetNext());
            }
            else
            {
                mHead = curr->GetNext();
                if (mTail == curr)
                    mTail = NULL;
            }

            aComponent->Release();
            mLength--;
            
            return OK;
        }
        else
        {
            // move on to next
            last = curr;
            curr = GetNext();
        }
    }

    return err;
}

Here is the call graph for this function:

Here is the caller graph for this function:

RemoveComponent.

Searches the list and removes the first component that matches the supplied component.

Parameters:
aComponentthe component to remove
Returns:
err integer error code (zero means OK)

Member Data Documentation

Definition at line 175 of file nsComponentList.h.

Definition at line 181 of file nsComponentList.h.

Definition at line 178 of file nsComponentList.h.

Definition at line 177 of file nsComponentList.h.

Definition at line 183 of file nsComponentList.h.

Definition at line 176 of file nsComponentList.h.

Definition at line 182 of file nsComponentList.h.


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