lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Quintiq file version 2.0
#parent: #root
Method OnDelete
{
  Description: 'Do some post-processing upon deletion of this `LibOpt_ScopeElement`.'
  TextBody:
  [*
    details := this.Details();
    identifier := this.Identifier();
    
    replacement := null( LibOpt_ScopeElementDeleted );
    
    // Use the scope element with the same Identifier and Details
    traverse( this, ScopeElementOnScope, seos )
    {
      run := seos.Scope().Run();
      // If DebugScope is enabled, create a ScopeElementDeleted
      if( run.DebugScope() )
      {
        optimization := run.Optimization();
        if( isnull( replacement ) )
        {
          replacement := LibOpt_ScopeElementDeleted::Create( optimization, this.InternalIdentifier(), details, identifier, false );
        }
        replacement.ScopeElementOnScope( relmove, seos );
        
        // Link the `LibOpt_SuboptimizerScopeElement` of this `LibOpt_ScopeElement` to its replacement.
        traverse( this, SuboptimizerScopeElement, suboptimizerscopeelement )
        {
          suboptimizerscopeelement.ScopeElement( relset, replacement );
        }
        
        seos.ScopeAsActiveScopeElements( relflush );
        seos.ScopeAsDeletedScopeElements( relset, seos.Scope() );
      }
      // Otherwise clean up
      else
      {
        seos.Delete();
      }
    }
  *]
}