SnapShotList Class Reference

Defines what is saved during a current attribute snap shot. More...

#include <filters.h>

List of all members.

Public Member Functions

 SnapShotList ()
 Constructs a snap shot list.
 ~SnapShotList ()
 Destroys a snapshot list. At this stage the snap shot list should be empty (if Create and Destroy have been matched correctly).
BOOL CreateSnapShot (AttributeEntry *CurrAttrs)
 Take a snap shot of the attribute list described by CurrAttrs.
void DestroySnapShot ()
 Destroy the last snap shot taken by CreateSnapShot().
SnapShotItemGetCurrentSnapShot ()
 This function is an abstracted way of finding the current snap shot created by the last CreateSnapShot() to be called (as snap shots can be stacked).
BOOL ApplyChangedAttrs (Node *pNode, AttributeEntry *CurrAttrs)
 This function uses the snapshot facility to work out which of the current attributes have changed. Obviously it expects a snap shot to have been taken some time earlier. Only those attributes that have changes will be applied to the node described on entry. Note, any changed attributes which now match defaults will not be applied as the function calls ApplyBasedOnDefaults() with the changes list.
void PushAttrsBasedOnSnapShot (AttributeEntry *CurrAttrs)
 This function uses the snap shot facility. It checks the snap shot list against the current attribute list to find attributes which differ. Those that do are obviously new attributes. ie attributes which have been parsed by the filter after the snap shot was taken. This function takes the current attrubute list and removes all those attributes which have changed in this way. It resets them to their default none temp attribute types.
void PopAttrsBasedOnSnapShot (AttributeEntry *CurrAttrs)
 This function uses the snap shot facility. It checks the snap shot list against the current attribute list to find attributes which differ. Those that do are obviously new attributes. ie attributes which have been parsed by the filter after the snap shot was taken. This function takes the current attrubute list and removes all those attributes which have changed in this way. It resets them to their default none temp attribute types.

Private Member Functions

 CC_DECLARE_MEMDUMP (SnapShotList)

Private Attributes

List SnapShot


Detailed Description

Defines what is saved during a current attribute snap shot.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/10/95

Definition at line 354 of file filters.h.


Constructor & Destructor Documentation

SnapShotList::SnapShotList  ) 
 

Constructs a snap shot list.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/95
Parameters:
- [INPUTS]

Definition at line 5581 of file filters.cpp.

05582 {
05583 }

SnapShotList::~SnapShotList  ) 
 

Destroys a snapshot list. At this stage the snap shot list should be empty (if Create and Destroy have been matched correctly).

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/95
Parameters:
- [INPUTS]
Returns:
-

Definition at line 5599 of file filters.cpp.

05600 {
05601     BOOL notempty=FALSE;
05602     SnapShotItem* pItem=NULL;
05603     while ( (pItem=(SnapShotItem*)SnapShot.RemoveTail()) !=NULL )
05604     {
05605         notempty=TRUE;
05606         delete pItem;
05607     }
05608     if (notempty)
05609     {
05610         ERROR3("Destroyed a none empty snapshot list!\n");
05611     }
05612 }


Member Function Documentation

BOOL SnapShotList::ApplyChangedAttrs Node pNode,
AttributeEntry CurrAttrs
 

This function uses the snapshot facility to work out which of the current attributes have changed. Obviously it expects a snap shot to have been taken some time earlier. Only those attributes that have changes will be applied to the node described on entry. Note, any changed attributes which now match defaults will not be applied as the function calls ApplyBasedOnDefaults() with the changes list.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/95
Parameters:
- [INPUTS]
Returns:
TRUE if the changed attributes have been applied to pNode FALSE if nothing has been applied

Definition at line 5709 of file filters.cpp.

05710 {
05711     // check that we have a snap shot attr mask
05712     SnapShotItem* pCurrItem = GetCurrentSnapShot();
05713     if (pCurrItem==NULL)
05714     {
05715         ERROR3("No snap shot taken of the current attributes in SnapShotList::ApplyChangedAttrs()");
05716         return FALSE;
05717     }
05718 
05719     // Now get a set of default attributes so we can use them to reset the
05720     // current values
05721     INT32 i, NumAttrs = AttributeManager::GetNumAttributes();
05722     AttributeEntry *pDefAtts = AttributeManager::GetDefaultAttributes();
05723     if (pDefAtts==NULL)
05724         return FALSE;
05725     
05726     // Alter the list of default attrs we've just created to include the differences
05727     // between our snap shot set and the current attributes described.
05728     for (i=0; i<NumAttrs; i++)
05729     {
05730         pDefAtts[i].Ignore = TRUE;
05731         NodeAttribute* pNodeAtt = pCurrItem->SnapShotAttrs[i];
05732         if (pNodeAtt)
05733         {
05734             AttributeValue* pSavedAttr = pNodeAtt->GetAttributeValue();
05735         
05736             if ((pSavedAttr!=NULL) && (CurrAttrs[i].pAttr->IsDifferent(pSavedAttr)))
05737             {
05738                 pDefAtts[i].pAttr  = CurrAttrs[i].pAttr;
05739                 pDefAtts[i].Temp   = FALSE;
05740                 pDefAtts[i].Ignore = FALSE;
05741             }
05742         }
05743     }
05744 
05745     // Now apply the attribute list we have built
05746     BOOL Success = AttributeManager::ApplyBasedOnDefaults(pNode, pDefAtts);
05747     
05748     // finally free up the array we have created and return
05749     CCFree(pDefAtts);
05750     return Success;
05751 }

SnapShotList::CC_DECLARE_MEMDUMP SnapShotList   )  [private]
 

BOOL SnapShotList::CreateSnapShot AttributeEntry CurrAttrs  ) 
 

Take a snap shot of the attribute list described by CurrAttrs.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/95
Parameters:
CurrAttrs = a pointer to a list of attributeentry items. There as usual [INPUTS] should be AttributeManager::NumAttributes() of them
Returns:
TRUE if a snap shot has been created FALSE if not

Definition at line 5649 of file filters.cpp.

05650 {
05651     SnapShotItem* pItem = new SnapShotItem;
05652     if (pItem==NULL)
05653         return FALSE;
05654 
05655     if (!pItem->Initialise(CurrAttrs))
05656     {
05657         delete pItem;
05658         return FALSE;
05659     }
05660 
05661     SnapShot.AddTail(pItem);
05662     return TRUE;
05663 }

void SnapShotList::DestroySnapShot  ) 
 

Destroy the last snap shot taken by CreateSnapShot().

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/95
Parameters:
- [INPUTS]
Returns:
-

Definition at line 5678 of file filters.cpp.

05679 {
05680     SnapShotItem* pItem = (SnapShotItem*)SnapShot.RemoveTail();
05681     if (pItem==NULL)
05682     {
05683         ERROR3("underflow in SnapShotList::DestroySnapShot()");
05684         return;
05685     }        
05686         
05687     delete pItem;
05688 }

SnapShotItem * SnapShotList::GetCurrentSnapShot  ) 
 

This function is an abstracted way of finding the current snap shot created by the last CreateSnapShot() to be called (as snap shots can be stacked).

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/95
Parameters:
- [INPUTS]
Returns:
A pointer to the current snap shot.

Definition at line 5629 of file filters.cpp.

05630 {
05631     return (SnapShotItem*)SnapShot.GetTail();
05632 }

void SnapShotList::PopAttrsBasedOnSnapShot AttributeEntry CurrAttrs  ) 
 

This function uses the snap shot facility. It checks the snap shot list against the current attribute list to find attributes which differ. Those that do are obviously new attributes. ie attributes which have been parsed by the filter after the snap shot was taken. This function takes the current attrubute list and removes all those attributes which have changed in this way. It resets them to their default none temp attribute types.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/95
Parameters:
- [INPUTS]
Returns:
-

Definition at line 5838 of file filters.cpp.

05839 {
05840     // check that we have a snap shot attr mask
05841     SnapShotItem* pCurrItem = GetCurrentSnapShot();
05842     if (pCurrItem==NULL)
05843     {
05844         ERROR3("No snap shot taken of the current attributes in SnapShotList::PopAttrsBasedOnSnapShot()");  
05845         return;
05846     }
05847 
05848     INT32 i, NumAttrs = AttributeManager::GetNumAttributes();
05849     AttributeEntry *pDefAtts = AttributeManager::GetDefaultAttributes();
05850     if (pDefAtts==NULL)
05851         return;
05852     
05853     for (i=0; i<NumAttrs; i++)
05854     {
05855         if (pCurrItem->SnapShotAttrsStack[i].pAttr != NULL)
05856         {
05857             if ( !(CurrAttrs[i].pAttr->IsDifferent(pDefAtts[i].pAttr)) )
05858             {           
05859                 CurrAttrs[i].pAttr  = pCurrItem->SnapShotAttrsStack[i].pAttr;
05860                 CurrAttrs[i].Temp   = pCurrItem->SnapShotAttrsStack[i].Temp;
05861                 CurrAttrs[i].Ignore = pCurrItem->SnapShotAttrsStack[i].Ignore;
05862             }
05863         }
05864     }
05865 
05866     CCFree(pDefAtts);
05867 }

void SnapShotList::PushAttrsBasedOnSnapShot AttributeEntry CurrAttrs  ) 
 

This function uses the snap shot facility. It checks the snap shot list against the current attribute list to find attributes which differ. Those that do are obviously new attributes. ie attributes which have been parsed by the filter after the snap shot was taken. This function takes the current attrubute list and removes all those attributes which have changed in this way. It resets them to their default none temp attribute types.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/95
Parameters:
- [INPUTS]
Returns:
-

Definition at line 5773 of file filters.cpp.

05774 {
05775     // check that we have a snap shot attr mask
05776     SnapShotItem* pCurrItem = GetCurrentSnapShot();
05777     if (pCurrItem==NULL)
05778     {
05779         ERROR3("No snap shot taken of the current attributes in SnapShotList::PushAttrsBasedOnSnapShot()");
05780         return;
05781     }
05782 
05783     // Now get a set of default attributes so we can use them to reset the
05784     // current values
05785     INT32 i, NumAttrs = AttributeManager::GetNumAttributes();
05786     AttributeEntry *pDefAtts = AttributeManager::GetDefaultAttributes();
05787     if (pDefAtts==NULL)
05788         return;
05789     
05790     for (i=0; i<NumAttrs; i++)
05791     {
05792         pCurrItem->SnapShotAttrsStack[i].pAttr  = NULL;
05793         pCurrItem->SnapShotAttrsStack[i].Temp   = FALSE;
05794         pCurrItem->SnapShotAttrsStack[i].Ignore = TRUE;
05795         
05796         NodeAttribute* pNodeAtt = pCurrItem->SnapShotAttrs[i];
05797         
05798         if (pNodeAtt)
05799         {
05800             AttributeValue* pSavedAttr = pNodeAtt->GetAttributeValue();
05801         
05802             if ((pSavedAttr!=NULL) && (CurrAttrs[i].pAttr->IsDifferent(pSavedAttr)))
05803             {
05804                 // we don't want to apply this attr!
05805                 pCurrItem->SnapShotAttrsStack[i].pAttr  = CurrAttrs[i].pAttr;
05806                 pCurrItem->SnapShotAttrsStack[i].Temp   = CurrAttrs[i].Temp;
05807                 pCurrItem->SnapShotAttrsStack[i].Ignore = CurrAttrs[i].Ignore;  
05808                 
05809                 CurrAttrs[i].pAttr  = pDefAtts[i].pAttr;
05810                 CurrAttrs[i].Temp   = pDefAtts[i].Temp;
05811                 CurrAttrs[i].Ignore = pDefAtts[i].Ignore;
05812             }
05813         }
05814     }
05815 
05816     CCFree(pDefAtts);
05817 }


Member Data Documentation

List SnapShotList::SnapShot [private]
 

Definition at line 371 of file filters.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:01:20 2007 for Camelot by  doxygen 1.4.4