Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method FindOrCreateScopeShared (String type, LibOpt_Group group) as LibOpt_ScopeShared 
 | 
{ 
 | 
  Description: 
 | 
  [* 
 | 
    Get the `LibOpt_ScopeShared` that is only linked to this `LibOpt_ScopeThin` and no others. 
 | 
     
 | 
    If it does not exist, create it. 
 | 
  *] 
 | 
  TextBody: 
 | 
  [* 
 | 
    result := null( LibOpt_ScopeShared ); 
 | 
     
 | 
    group_vector := null( NumberVector, owning ); 
 | 
    if( isnull( group ) ) 
 | 
    { 
 | 
      group_vector := NumberVector::Construct( 0 ); 
 | 
    } 
 | 
    else 
 | 
    { 
 | 
      group_vector := NumberVector::Construct( this.ID() + 1 ); 
 | 
      group_vector.Set( this.ID(), group.ID() ); 
 | 
    } 
 | 
    group_vector_bv := group_vector.AsBinaryValue(); 
 | 
    if( this.Index() = 0 ) 
 | 
    { 
 | 
      result := LibOpt_ScopeShared32::FindSet32( this.Mask(), type, group_vector_bv ); 
 | 
       
 | 
      if( isnull( result ) ) 
 | 
      { 
 | 
        result := this.ScopeSharedOwned( relnew, 
 | 
                                         LibOpt_ScopeShared32, 
 | 
                                         Set := this.Mask(), 
 | 
                                         Type := type, 
 | 
                                         GroupVector := group_vector_bv 
 | 
                                         ); 
 | 
       
 | 
        LibOpt_ScopeSharedOnScope::Create( this, group, result ); 
 | 
      } 
 | 
    } 
 | 
    else 
 | 
    { 
 | 
      vector := NumberVector::Construct( this.Index() + 1 ); 
 | 
      vector.Set( this.Index(), this.Mask() ) 
 | 
      vector_bv := vector.AsBinaryValue(); 
 | 
      result := LibOpt_ScopeSharedVector::FindSetVector( vector_bv, type, group_vector_bv ); 
 | 
       
 | 
      if( isnull( result ) ) 
 | 
      { 
 | 
        result := this.ScopeSharedOwned( relnew, 
 | 
                                         LibOpt_ScopeSharedVector, 
 | 
                                         Set := vector_bv, 
 | 
                                         Type := type, 
 | 
                                         GroupVector := group_vector_bv 
 | 
                                         ); 
 | 
       
 | 
        LibOpt_ScopeSharedOnScope::Create( this, group, result ); 
 | 
      } 
 | 
    } 
 | 
     
 | 
     
 | 
    return result; 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |