haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
44
45
46
47
48
49
50
51
Quintiq file version 2.0
#parent: #root
Method GetSnapshotsOnComponent (LibOpt_Component component) remote as owning LibOpt_SnapshotComponents
{
  Description:
  [*
    Return the `LibOpt_SnapshotComponents` that are created by the given component that are in an iteration with the current snapshot (the `this`).
    In other words: find the `LibOpt_SnapshotComponents` that are created by the given component that have a path containing the current snapshot.
    
    This is one of the ancestor snapshots, a set of children snapshots or neither.
  *]
  TextBody:
  [*
    result := construct( LibOpt_SnapshotComponents );
    if( this.Component().Depth() >= component.Depth() )
    {
      // Walk up until we find the correct snapshot
      parent := [LibOpt_Snapshot] this;
      while( not isnull( parent ) and 
             guard( parent.astype( LibOpt_SnapshotComponent ).Component().Depth() > component.Depth(), true ) )
      {
        parent := parent.Parent();
      }
      
      if( guard( parent.astype( LibOpt_SnapshotComponent ).Component() = component, false ) )
      {
        result.Add( parent.astype( LibOpt_SnapshotComponent ) );
      }
    }
    else
    {
      // Walk down to find the correct set of snapshots
      children := construct( LibOpt_Snapshots );
      children.Add( this );
      
      while( children.Size() > 0 )
      {
        children := selectset( children, Elements.Children, child,
                               guard( child.astype( LibOpt_SnapshotComponent ).Component().Depth() <= component.Depth(), true ) );
        component_children := selectset( children, Elements.astype( LibOpt_SnapshotComponent ), snap, snap.Component() = component );
        if( component_children.Size() > 0 )
        {
          result.AddInPlace( component_children );
        }
      }
    }
    
    return & result;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}