OverrideList Class Reference

An override list contains items that can override each other. More...

#include <overlist.h>

Inheritance diagram for OverrideList:

List CCObject SimpleCCObject Imagemap List of all members.

Public Member Functions

 OverrideList ()
 Default constructor.
virtual void AddHead (OverrideListItem *)
 Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.
virtual void AddTail (OverrideListItem *)
 Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.
virtual LISTPOS InsertBefore (LISTPOS here, OverrideListItem *item)
 Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.
virtual ListItemInsertBefore (OverrideListItem *here, OverrideListItem *item)
 Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.
virtual LISTPOS InsertAfter (LISTPOS here, OverrideListItem *item)
 Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.
virtual ListItemInsertAfter (OverrideListItem *here, OverrideListItem *item)
 Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.

Protected Member Functions

virtual BOOL CompareWithItemsAbove (OverrideListItem *pliStartPos, OverrideListItem *pliToInsert)
 Compares this list item with all the items above pliStartPos, inclusive.
virtual BOOL CompareWithItemsBelow (OverrideListItem *pliStartPos, OverrideListItem *pliToInsert)
 Compares this list item with all the items below pliStartPos, inclusive.

Detailed Description

An override list contains items that can override each other.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/4/97
For example, imagine we are building a list of clickable areas in an imagemap. Our list of clickable areas already contains a rectangle with bottom left corner (0,0) and top right corner (200, 200), that links to the URL "http://www.xara.com".

Now we add another clickable rectangle to the imagemap. This rectangle has bottom left corner (50,50) and top right corner (100,100) and also links to "http://www.xara.com".

But our first rectangle is contained within our second rectangle! There is no need for the second rectangle at all.

It is clear that the first rectangle overrides the second, so the second rectangle should not be added to the list.

Now imagine the small rectangle is already in the list and the large rectangle is added.

Again, the large rectangle overrides the small one. So the large rectangle should be added to the list and the smaller rectangle should be deleted.

So, this class works as follows.

When an OverrideListItem is added to this list, this function compares the item with every other item in the list.

It does this by calling either the function OverrideListItem::OverrideFromAbove (if the item in the list is before the item being added) or OverrideListItem::OverrideFromBelow(if the item in the list is below the item being added).

Then:

a. If an item in the list overrides the item being added, then the new item is not added to the list.

b. If the item being added overrides an item in the list, then the new item is added and the item in the list is deleted.

Definition at line 156 of file overlist.h.


Constructor & Destructor Documentation

OverrideList::OverrideList  ) 
 

Default constructor.

OverrideList::OverrideList()

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/4/97

Definition at line 118 of file overlist.cpp.

00118                            : List()
00119 {
00120 }


Member Function Documentation

void OverrideList::AddHead OverrideListItem poliToAdd  )  [virtual]
 

Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.

virtual void OverrideList::AddHead( OverrideListItem* poliToAdd)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/4/97
Parameters:
poliToAdd The item to add [INPUTS]
Returns:
-
If this list item overrides any items already present in the list, the items in the list are deleted and this list item is added.

If any item in the list overrides this list item, this list item is not added to the list.

This function simply calls the InsertBefore function.

See also:
OverrideList::InsertBefore()

Definition at line 149 of file overlist.cpp.

00150 {
00151     if (poliToAdd==NULL)
00152     {
00153         ERROR2RAW("OverrideList::AddHead - NULL parameter");
00154         return;
00155     }
00156 
00157     //Get the first item in the list
00158     OverrideListItem* pliFirst=(OverrideListItem*) GetHead();
00159 
00160     //Was there anything in the list?
00161     if (pliFirst!=NULL)              
00162     {
00163         //Yes. So call our InsertBefore function
00164         InsertBefore(pliFirst, poliToAdd);
00165     }
00166     else
00167     {
00168         //No. So we need do no special checking - simply insert
00169         //the list item
00170         List::AddHead(poliToAdd);
00171     }
00172     
00173 }

void OverrideList::AddTail OverrideListItem poliToAdd  )  [virtual]
 

Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.

virtual void OverrideList::AddTail( OverrideListItem* poliToAdd)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/4/97
Parameters:
poliToAdd The item to add [INPUTS]
Returns:
-
If this list item overrides any items already present in the list, the items in the list are deleted and this list item is added.

If any item in the list overrides this list item, this list item is not added to the list.

This function simply calls the InsertAfter function.

See also:
OverrideList::InsertAfter()

Definition at line 202 of file overlist.cpp.

00203 {
00204     if (poliToAdd==NULL)
00205     {
00206         ERROR2RAW("OverrideList::AddTail - NULL parameter");
00207         return;
00208     }
00209 
00210     //Get the last item in the list
00211     OverrideListItem* pliLast=(OverrideListItem*) GetTail();
00212 
00213     //Was there anything in the list?
00214     if (pliLast!=NULL)               
00215     {
00216         //Yes. So call our InsertAfter function
00217         InsertAfter(pliLast, poliToAdd);
00218     }
00219     else
00220     {
00221         //No. So we need do no special checking - simply insert
00222         //the list item
00223         List::AddTail(poliToAdd);
00224     }
00225 
00226     //And add our item after it
00227     InsertAfter(pliLast, poliToAdd);
00228     
00229 }

BOOL OverrideList::CompareWithItemsAbove OverrideListItem pliStartPos,
OverrideListItem pliToInsert
[protected, virtual]
 

Compares this list item with all the items above pliStartPos, inclusive.

virtual BOOL OverrideList::CompareWithItemsAbove(OverrideListItem* pliStartPos, OverrideListItem* pliToInsert);

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/4/97
Parameters:
pliStartPos The position to start searching from [INPUTS] pliToAdd The list items to add
Returns:
FALSE if pliToAdd was overridden by another item in the list
TRUE if pliToAdd was not overridden

Note that, if pliToAdd overrides another item in the list, this does not affect the result returned.

See also:
OverrideList::InsertBefore(), OverrideList::After()

Definition at line 479 of file overlist.cpp.

00480 {
00481     //This pointer will show the item we are looking at
00482     OverrideListItem* pliLook=pliStartPos;
00483 
00484     //While we are still looking at a valid item
00485     while (pliLook!=NULL)
00486     {
00487         //This will be the next item we look at
00488         //It's important to do this now - because we may delete pliLook in a moment
00489         OverrideListItem* pliNext=(OverrideListItem*) GetPrev(pliLook);
00490 
00491         //Does the item we are looking at override the item
00492         //we are about to insert?
00493         if (pliLook->OverrideFromAbove(pliToInsert))
00494         {
00495             //Yes. So return to say that we're not going to insert the
00496             //item
00497             return FALSE;
00498         }
00499 
00500         //Does the item we are about to insert override the item
00501         //we are looking at?
00502         if (pliToInsert->OverrideFromBelow(pliLook))
00503         {
00504             //Yes. So delete the item we are looking at.
00505             RemoveItem(pliLook);
00506             delete pliLook;
00507         }
00508 
00509         //And move on to the next item
00510         pliLook=pliNext;
00511     }
00512 
00513     //ANd return to say that pliToInsert has not been overridden
00514     return TRUE;
00515 }

BOOL OverrideList::CompareWithItemsBelow OverrideListItem pliStartPos,
OverrideListItem pliToInsert
[protected, virtual]
 

Compares this list item with all the items below pliStartPos, inclusive.

virtual BOOL OverrideList::CompareWithItemsBelow(OverrideListItem* pliStartPos, OverrideListItem* pliToInsert)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/4/97
Parameters:
pliStartPos The position to start searching from [INPUTS] pliToAdd The list items to add
Returns:
FALSE if pliToAdd was overridden by another item in the list
TRUE if pliToAdd was not overridden

Note that, if pliToAdd overrides another item in the list, this does not affect the result returned.

See also:
OverrideList::InsertBefore(), OverrideList::After()

Definition at line 541 of file overlist.cpp.

00542 {
00543     //This pointer will show the item we are looking at
00544     OverrideListItem* pliLook=pliStartPos;
00545 
00546     //While we are still looking at a valid item
00547     while (pliLook!=NULL)
00548     {
00549         //This will be the next item we look at
00550         //It's important to do this now - because we may delete pliLook in a moment
00551         OverrideListItem* pliNext=(OverrideListItem*) GetNext(pliLook);
00552 
00553         //Does the item we are looking at override the item
00554         //we are about to insert?
00555         if (pliLook->OverrideFromBelow(pliToInsert))
00556         {
00557             //Yes. So return to say that we're not going to insert the
00558             //item
00559             return FALSE;
00560         }
00561 
00562         //Does the item we are about to insert override the item
00563         //we are looking at?
00564         if (pliToInsert->OverrideFromAbove(pliLook))
00565         {
00566             //Yes. So delete the item we are looking at.
00567             RemoveItem(pliLook);
00568             delete pliLook;
00569         }
00570                 
00571         //And move on to the next item
00572         pliLook=pliNext;
00573     }
00574 
00575     //And return to say that pliToInsert has not been overridden
00576     return TRUE;
00577 }

ListItem * OverrideList::InsertAfter OverrideListItem pliInsertPoint,
OverrideListItem pliToInsert
[virtual]
 

Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.

virtual ListItem* OverrideList::InsertAfter(OverrideListItem* here, OverrideListItem* item);

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/4/97
Parameters:
poliToAdd The item to add [INPUTS]
Returns:
-
It does this by calling the function MergeListItem::OverrideFromBelow on all items below the insertion position, and MergeListItem::OverrideFromAbove on all items above the insertion position.

If this list item overrides any items already present in the list, the items in the list are deleted and this list item is added.

If any item in the list overrides this list item, this list item is not added to the list.

This function simply calls the InsertBefore function.

See also:
OverrideList::InsertBefore()

Definition at line 372 of file overlist.cpp.

00373 {
00374     ERROR2IF(pliToInsert==NULL, NULL, "OverrideList::InsertAfter - NULL parameter");
00375 
00376     //This variable will tell us whether to insert pliToInsert
00377     //into the list
00378     BOOL fInsert=TRUE;
00379 
00380     //First compare pliToInsert with everything above pliInsertPoint in the list
00381     fInsert=CompareWithItemsAbove(pliInsertPoint, pliToInsert);
00382 
00383     //Now get the list item after pliInsertPoint
00384     OverrideListItem* pliTest=(OverrideListItem*) GetNext(pliInsertPoint);
00385 
00386     //If there is anything before pliInsertPoint
00387     if (fInsert && pliTest!=NULL)
00388     {
00389         //Then test everything before pliInsertPoint
00390         fInsert=CompareWithItemsBelow(pliInsertPoint, pliToInsert);
00391     }
00392 
00393     //So, should we insert pliToInsert?
00394     if (fInsert)
00395         //Yes. So do it.
00396         return List::InsertAfter(pliInsertPoint, pliToInsert);
00397     else
00398         //No. So return an error value.
00399         return NULL;
00400 
00401 
00402     
00403 }

LISTPOS OverrideList::InsertAfter LISTPOS  here,
OverrideListItem item
[virtual]
 

Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.

virtual ListItem* OverrideList::InsertAfter(OverrideListItem* here, OverrideListItem* item);

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/4/97
Parameters:
poliToAdd The item to add [INPUTS]
Returns:
-
This function simply calls the other InsertAfter override.

See also:
OverrideList::InsertAfter()

Definition at line 425 of file overlist.cpp.

00426 {
00427     ERROR2IF(item==NULL, 0, "OverrideList::InsertAfter - NULL parameter");
00428 
00429     //First find the list item at the position we have been given
00430     OverrideListItem* pliInsertionPoint=(OverrideListItem*) FindItem(here);
00431 
00432     //If we have not found it, return -1
00433     if (pliInsertionPoint==NULL)
00434         return -1;
00435 
00436     //Otherwise, call our other function to do the insertion
00437     OverrideListItem* pliResult=(OverrideListItem*) InsertAfter(pliInsertionPoint, item);
00438 
00439     //If we have been returned NULL, then return an error value
00440     if (pliResult==NULL)
00441         return -1;
00442 
00443     //Otherwise, find our newly returned list item in the list
00444     //and return it
00445     return FindPosition(pliResult);
00446     
00447 }

ListItem * OverrideList::InsertBefore OverrideListItem pliInsertPoint,
OverrideListItem pliToInsert
[virtual]
 

Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.

virtual ListItem* OverrideList::InsertBefore(OverrideListItem* here, OverrideListItem* item);

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/4/97
Parameters:
poliToAdd The item to add [INPUTS]
Returns:
-
It does this by calling the function OverrideListItem::OverrideFromBelow on all items below the insertion position, and MergeListItem::OverrideFromAbove on all items above the insertion position.

If this list item overrides any items already present in the list, the items in the list are deleted and this list item is added.

If any item in the list overrides this list item, this list item is not added to the list.

This function simply calls the InsertBefore function.

See also:
OverrideList::InsertBefore()

Definition at line 263 of file overlist.cpp.

00264 {
00265     ERROR2IF(pliToInsert==NULL, NULL, "OverrideList::InsertBefore - NULL parameter");
00266         
00267     //This variable will tell us whether to insert pliToInsert
00268     //into the list
00269     BOOL fInsert=TRUE;
00270 
00271     //First compare pliToInsert with everything below pliInsertPoint in the list
00272     fInsert=CompareWithItemsBelow(pliInsertPoint, pliToInsert);
00273 
00274     //Now get the list item above pliInsertPoint
00275     OverrideListItem* pliTest=(OverrideListItem*) GetPrev(pliInsertPoint);
00276 
00277     //If there is anything above pliInsertPoint
00278     if (fInsert && pliTest!=NULL)
00279     {
00280         //Then test everything above pliInsertPoint
00281         fInsert=CompareWithItemsAbove(pliInsertPoint, pliToInsert);
00282     }
00283 
00284     //So, should we insert pliToInsert?
00285     if (fInsert)
00286         //Yes. So do it.
00287         return List::InsertBefore(pliInsertPoint, pliToInsert);
00288     else
00289         //No. So return an error value.
00290         return NULL;
00291     
00292 }

LISTPOS OverrideList::InsertBefore LISTPOS  here,
OverrideListItem item
[virtual]
 

Compares this list item with all the items in the list, to find out whether they override this list item or whether this list item overrides them.

virtual ListItem* OverrideList::InsertBefore(OverrideListItem* here, OverrideListItem* item);

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/4/97
Parameters:
poliToAdd The item to add [INPUTS]
Returns:
-
This function simply calls the other InsertBefore override.

See also:
OverrideList::InsertBefore()

Definition at line 314 of file overlist.cpp.

00315 {
00316 
00317     ERROR2IF(item==NULL, NULL, "OverrideList::InsertBefore - NULL parameter");
00318         
00319 
00320     //First find the list item at the position we have been given
00321     OverrideListItem* pliInsertionPoint=(OverrideListItem*) FindItem(here);
00322 
00323     //If we have not found it, return -1
00324     if (pliInsertionPoint==NULL)
00325         return -1;
00326 
00327     //Otherwise, call our other function to do the insertion
00328     OverrideListItem* pliResult=(OverrideListItem*) InsertBefore(pliInsertionPoint, item);
00329 
00330     //If we have been returned NULL, then return an error value
00331     if (pliResult==NULL)
00332         return -1;
00333 
00334     //Otherwise, find our newly returned list item in the list
00335     //and return it
00336     return FindPosition(pliResult);
00337     
00338 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:59:21 2007 for Camelot by  doxygen 1.4.4