/* file: default_tolerance_table_cell_wr3.swift 	 generated: Mon Jan  3 16:32:52 2022 */

/* This file was generated by the EXPRESS to Swift translator "exp2swift", 
  derived from STEPcode (formerly NIST's SCL).
 exp2swift version: v.1.0.1, derived from stepcode v0.8 as of 2019/11/23 
 WARNING: You probably don't want to edit it since your modifications 
  will be lost if exp2swift is used to regenerate it.
 */

 
import SwiftSDAIcore

extension AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF {
//MARK: -FUNCTION DEFINITION in EXPRESS
/*

  FUNCTION default_tolerance_table_cell_wr3(
               agg : compound_item_definition
           ) : BOOLEAN;

    BEGIN
      IF ( SIZEOF( QUERY ( i <* agg | ( ( 'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.'
          + 'MEASURE_REPRESENTATION_ITEM'  IN TYPEOF( i ) ) AND ( i\representation_item.name = 
          'significant number of digits'  ) ) ) ) = 1 ) OR ( ( SIZEOF( QUERY ( i <* agg | ( ( 
          'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.MEASURE_REPRESENTATION_ITEM'  IN TYPEOF( i ) ) AND
          ( i\representation_item.name = 'lower limit' ) ) ) ) = 1 ) AND ( SIZEOF( QUERY ( i <* agg | ( ( 
          'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.MEASURE_REPRESENTATION_ITEM'  IN TYPEOF( i ) ) AND
          ( i\representation_item.name = 'upper limit' ) ) ) ) = 1 ) ) THEN
        RETURN( TRUE );
      ELSE
        RETURN( FALSE );
      END_IF;
    END;

  END_FUNCTION; -- default_tolerance_table_cell_wr3 (line:37362 file:ap242ed2_mim_lf_v1.101.TY.exp)

*/

  public static 
  func DEFAULT_TOLERANCE_TABLE_CELL_WR3(
    _ AGG: sCOMPOUND_ITEM_DEFINITION? ) 
    -> SDAI.BOOLEAN? {

    // CACHE LOOKUP
    let _params = SDAI.ParameterList( AGG )
    if case .available(let _cached_value) = _default_tolerance_table_cell_wr3__cache.cachedValue(params: _params) {
      return _cached_value as? SDAI.BOOLEAN
    }

    var AGG = AGG; SDAI.TOUCH(var: &AGG)

    //BEGIN
    
    let _TEMP1 = AGG?.QUERY{ I in 

        let _TEMP1 = SDAI.TYPEOF(I, IS: eMEASURE_REPRESENTATION_ITEM.self)
        let _TEMP2 = I.GROUP_REF(eREPRESENTATION_ITEM.self)
        let _TEMP3 = _TEMP2?.NAME
        let _TEMP4 = _TEMP3 .==. SDAI.FORCE_OPTIONAL(SDAI.STRING("significant number of digits"))
        let _TEMP5 = _TEMP1 && _TEMP4
        return _TEMP5 }
    let _TEMP2 = SDAI.SIZEOF(SDAI.AGGREGATE<SDAI.GENERIC>(/*sCOMPOUND_ITEM_DEFINITION*/_TEMP1))
    let _TEMP3 = _TEMP2 .==. SDAI.FORCE_OPTIONAL(SDAI.INTEGER(1))
    let _TEMP4 = AGG?.QUERY{ I in 

        let _TEMP1 = SDAI.TYPEOF(I, IS: eMEASURE_REPRESENTATION_ITEM.self)
        let _TEMP2 = I.GROUP_REF(eREPRESENTATION_ITEM.self)
        let _TEMP3 = _TEMP2?.NAME
        let _TEMP4 = _TEMP3 .==. SDAI.FORCE_OPTIONAL(SDAI.STRING("lower limit"))
        let _TEMP5 = _TEMP1 && _TEMP4
        return _TEMP5 }
    let _TEMP5 = SDAI.SIZEOF(SDAI.AGGREGATE<SDAI.GENERIC>(/*sCOMPOUND_ITEM_DEFINITION*/_TEMP4))
    let _TEMP6 = _TEMP5 .==. SDAI.FORCE_OPTIONAL(SDAI.INTEGER(1))
    let _TEMP7 = AGG?.QUERY{ I in 

        let _TEMP1 = SDAI.TYPEOF(I, IS: eMEASURE_REPRESENTATION_ITEM.self)
        let _TEMP2 = I.GROUP_REF(eREPRESENTATION_ITEM.self)
        let _TEMP3 = _TEMP2?.NAME
        let _TEMP4 = _TEMP3 .==. SDAI.FORCE_OPTIONAL(SDAI.STRING("upper limit"))
        let _TEMP5 = _TEMP1 && _TEMP4
        return _TEMP5 }
    let _TEMP8 = SDAI.SIZEOF(SDAI.AGGREGATE<SDAI.GENERIC>(/*sCOMPOUND_ITEM_DEFINITION*/_TEMP7))
    let _TEMP9 = _TEMP8 .==. SDAI.FORCE_OPTIONAL(SDAI.INTEGER(1))
    let _TEMP10 = _TEMP6 && _TEMP9
    let _TEMP11 = _TEMP3 || _TEMP10
    if SDAI.IS_TRUE( _TEMP11 ) {
      return _default_tolerance_table_cell_wr3__cache.updateCache(params: _params, value: SDAI.BOOLEAN(
        SDAI.TRUE))
    }
    else {
      return _default_tolerance_table_cell_wr3__cache.updateCache(params: _params, value: SDAI.BOOLEAN(
        SDAI.FALSE))
    }
    //END
  }

}

//MARK: - function result cache
private var _default_tolerance_table_cell_wr3__cache = SDAI.FunctionResultCache(
  controller: AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF.schemaDefinition)

