      *>----------------------------------------------------------------
      *> RecursiveSet is a private class which is used by the class
      *> library to prevent recursive display of collections.
      *>
      *> Copyright (C) 1991-1999 Micro Focus International Ltd
      *>
      *>----------------------------------------------------------------
      $set mfoo

       class-id. RecursiveSet  data is protected
               inherits from base with data.
       special-names.
           call-convention 66 is WAPI.

        object section.
        class-control.
           base is class "base"
           identitySet is class "iset"
           IdentityDictionary is class "idictnry"
           CobolComp5Assoc is class "compasoc"
           RecursiveSet is class "recurset".

       class-object.

       object-storage section.
       01 ThreadDict       usage object reference.
       01 critSect         pointer.
      *>---------------------------------------------------------------
      *> Adds an object to the recursive set.
      *>---------------------------------------------------------------
       method-id. "add".
       local-storage section.
       01 localSet usage object reference.
       linkage section.
       01 lnkObject    usage object reference.
       procedure division using lnkObject.
           invoke self "getSet" returning localSet
           invoke localSet "add" using lnkObject
       end method "add".
      *>---------------------------------------------------------------
      *> Removes an object from the recursive set.
      *>---------------------------------------------------------------

       method-id. "remove".
       local-storage section.
       01 localSet usage object reference.
       linkage section.
       01 lnkObject    usage object reference.
       procedure division using lnkObject.
           invoke self "getSet" returning localSet
           invoke localSet "remove" using lnkObject
       end method "remove".
      *>---------------------------------------------------------------
      *> Returns the actual set used for the implementation of this
      *> class.
      *>---------------------------------------------------------------

       method-id. "getSet".
       local-storage section.
       01 localSet usage object reference.
       01 i        pic x(4) comp-5.
       01 threadId pointer.
       linkage section.
       01 result    usage object reference.
       procedure division returning result.
           copy "csenter".
           if ThreadDict = null
               move 50 to i
               invoke IdentityDictionary "ofValues" using 
                                                       CobolCOmp5Assoc
                                                       i
                       returning ThreadDict
           end-if
           set threadId to null
           call "CBL_THREAD_SELF" using threadId
           invoke ThreadDict "atOrNil" using threadId
                           returning result
           if result = null
               invoke self "new" returning result
               invoke threadDict "atPut" using threadId result
           end-if
           copy "csleave".
       end method "getSet".
      *>---------------------------------------------------------------
      *> PRIVATE. Initialize this class.
      *>---------------------------------------------------------------

       method-id. "initializeClass".
       procedure division.
           copy "csinit".
           exit program.
       end method "initializeClass".
      *>---------------------------------------------------------------
      *> Returns true if this set includes lnkObject.
      *>---------------------------------------------------------------
       method-id. "includes".
       local-storage section.
       01 localSet usage object reference.
       linkage section.
       01 lnkObject    usage object reference.
       01 lnkBool      pic x comp-5.
       procedure division using lnkObject returning lnkBool.
           invoke self "getSet" returning localSet
           invoke localSet "includes" using lnkObject returning lnkBool
       end method "includes".
       end class-object.

       Object.
       object-storage section.
       01 aSet              usage object reference value null.
       01 critSect          pointer.
      *>---------------------------------------------------------------
      *> Adds an object to the recursive set.
      *>---------------------------------------------------------------
       method-id. "add".
       local-storage section.
       01 localSet usage object reference.
       linkage section.
       01 lnkObject    usage object reference.
       procedure division using lnkObject.
           copy "csenter".
           invoke self "getSet" returning localSet
           invoke localSet "add" using lnkObject
           copy "csleave".
       end method "add".
      *>---------------------------------------------------------------
      *> Returns the actual set used for the implementation of this
      *> class.
      *>---------------------------------------------------------------

       method-id. "getSet".
       local-storage section.
       01 localSet usage object reference.
       01 i        pic x(4) comp-5.
       linkage section.
       01 result    usage object reference.
       procedure division returning result.
           copy "csenter".
           if aSet = null
               move 50 to i
               invoke IdentitySet "ofReferences" using i
                       returning aSet
           end-if
           set result to aSet
           copy "csleave".
       end method "getSet".
      *>---------------------------------------------------------------
      *> Returns true if this set includes lnkObject.
      *>---------------------------------------------------------------
       method-id. "includes".
       local-storage section.
       01 localSet usage object reference.
       linkage section.
       01 lnkObject    usage object reference.
       01 lnkBool      pic x comp-5.
       procedure division using lnkObject returning lnkBool.
           copy "csenter".
           invoke self "getSet" returning localSet
           invoke localSet "includes" using lnkObject returning lnkBool
           copy "csleave".
       end method "includes".
      *>---------------------------------------------------------------
      *> Removes an object from the recursive set.
      *>---------------------------------------------------------------

       method-id. "remove".
       local-storage section.
       01 localSet usage object reference.
       linkage section.
       01 lnkObject    usage object reference.
       procedure division using lnkObject.
           copy "csenter".
           invoke self "getSet" returning localSet
           invoke localSet "remove" using lnkObject
           copy "csleave".
       end method "remove".
       end object.
       end class RecursiveSet.
