abc/src/base/main/mainFrame.c
/**Function*************************************************************

  Synopsis    [Sets the given network to be the current one.]

  Description [Takes the network and makes it the current network.
  The previous current network is attached to the given network as 
  a backup copy. In the stack of backup networks contains too many
  networks (defined by the paramater "savesteps"), the bottom
  most network is deleted.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Sets the given network to be the current one.]

Description [Takes the network and makes it the current network.
The previous current network is attached to the given network as
a backup copy. In the stack of backup networks contains too many
networks (defined by the paramater "savesteps"), the bottom
most network is deleted.]




Function Synopsis [ Sets the given network to be the current one . ] Description [ Takes the network and makes it the current network . The previous current network is attached to the given network as a backup copy . In the stack of backup networks contains too many networks ( defined by the paramater " savesteps " ) the bottom most network is deleted . ]
void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNtkNew )
{
    Abc_Ntk_t * pNtk, * pNtk2, * pNtk3;
    int nNetsPresent;
    int nNetsToSave;
    char * pValue;
    if ( p->pNtkCur == pNtkNew )
        return;
    Abc_NtkSetBackup( pNtkNew, p->pNtkCur );
    Abc_NtkSetStep( pNtkNew, ++p->nSteps );
    p->pNtkCur = pNtkNew;
    pValue = Cmd_FlagReadByName( p, "savesteps" );
    if ( pValue == NULL )
        nNetsToSave = 1;
    else 
        nNetsToSave = atoi(pValue);
    nNetsPresent = 0;
    pNtk2 = pNtk3 = NULL;
    for ( pNtk = p->pNtkCur; pNtk; pNtk = Abc_NtkBackup(pNtk2) )
    {
        nNetsPresent++;
        pNtk3 = pNtk2;
        pNtk2 = pNtk;
    }
    if ( nNetsPresent - 1 > nNetsToSave )
    { 
        Abc_NtkDelete( pNtk2 );
        Abc_NtkSetBackup( pNtk3, NULL );
    }
}
void Abc_FrameSetCurrentNetwork ( Abc_Frame_t * p , Abc_Ntk_t * pNtkNew ) { Abc_Ntk_t * pNtk , * pNtk2 , * pNtk3 ; int nNetsPresent ; int nNetsToSave ; char * pValue ; if ( p -> pNtkCur == pNtkNew ) return ; Abc_NtkSetBackup ( pNtkNew , p -> pNtkCur ) ; Abc_NtkSetStep ( pNtkNew , ++ p -> nSteps ) ; p -> pNtkCur = pNtkNew ; pValue = Cmd_FlagReadByName ( p , " " ) ; if ( pValue == NULL ) nNetsToSave = 1 ; else nNetsToSave = atoi ( pValue ) ; nNetsPresent = 0 ; pNtk2 = pNtk3 = NULL ; for ( pNtk = p -> pNtkCur ; pNtk ; pNtk = Abc_NtkBackup ( pNtk2 ) ) { nNetsPresent ++ ; pNtk3 = pNtk2 ; pNtk2 = pNtk ; } if ( nNetsPresent - 1 > nNetsToSave ) { Abc_NtkDelete ( pNtk2 ) ; Abc_NtkSetBackup ( pNtk3 , NULL ) ; } }
Function
Synopsis    [Sets the given network to be the current one.]
Function Synopsis [ Sets the given network to be the current one . ]
// link it to the previous network // set the step of this network // set this network to be the current network // remove any extra network that may happen to be in the stack // if the value of steps to save is not set, assume 1-level undo // count the network, remember the last one, and the one before the last one // remove the earliest backup network if it is more steps away than we store // delete the last network // clean the pointer of the network before the last one