      *>----------------------------------------------------------------
      *> Dependent is an abstract class which provides notification of
      *> of changed/deleted to all the registerd dependents of an
      *> object. To use the dependency mechanism, subclass Dependent and
      *> set up dependencies for the instances of your subclass.
      *> The notification scheme only works
      *> for instances and not classes.
      *>
      *>!Note
      *>
      *> This class is retained for compatibility only. We recommend
      *> that you use Components for notification schemes in new
      *> development work.
      *>
      *>#See section Components.
      *>
      *> Copyright (C) 1991-1999 Micro Focus International Ltd.
      *>
      *>----------------------------------------------------------------
      $set mfoo
       class-id. Dependent is abstract
                 data is protected
                 inherits from Base
                 with data.

        object section.
        class-control.
           Base      is class "base"
           Dependent is class "dependnt"
           IdentitySet is class "iset"
           Callback is class "callback".
       working-storage section.

       class-object.
       object-storage section.
       end class-object.
       Object.

       object-storage section.

      *>----------------------------------------------------------------
      *> Add a dependent for this object. The dependent will be notified
      *> if this object receives the changed or deleted message.
      *>----------------------------------------------------------------

       method-id. "addDependent".
       local-storage section.

       01 aSize            pic x(4) comp-5.
       01 aName            pic x(30).

       linkage section.
       01 aDependent usage object reference.

       procedure division using aDependent.
           invoke self "makeComponent"
           invoke aDependent "makeComponent"
           invoke self "defineOutSignal"      using "ASSOCIATECHANGED"
                                                       & x"00"
           invoke self "defineOutSignal"      using "ASSOCIATEDELETED"
                                                       & x"00"
           invoke aDependent "defineInSocket" using "ASSOCIATESOCKET"
                                                       & x"00"
           invoke aDependent "defineInSignal" using "ASSOCIATECHANGED"
                                                       & x"00"
                                                    "ASSOCIATESOCKET"
                                                       & x"00"
                                                    "changed"
                                                       & x"00"
           invoke aDependent "defineInSignal" using "ASSOCIATEDELETED"
                                                       & x"00"
                                                    "ASSOCIATESOCKET"
                                                       & x"00"
                                                    "deleted"
                                                       & x"00"
           invoke self "connect" using self
                                       aDependent
                                       "ASSOCIATESOCKET" & x"00"
           exit method.
       end method "addDependent".
      *>----------------------------------------------------------------
      *> Send the changed message to all the Dependents of this object.
      *>----------------------------------------------------------------

       method-id. "changed".

       local-storage section.
       01  lsBool              pic x comp-5.
           88 isTrue           value 1.
           88 isFalse          value 0.

       linkage section.
       01 aFourByteParameter   usage object reference.

       procedure division using aFourByteParameter.
           invoke self "isComponent" returning lsBool
           if isTrue
               invoke self "isOutputSignal" using "ASSOCIATECHANGED "
                       returning lsBool
               if isTrue
                   invoke self "signal" using "ASSOCIATECHANGED "
                                          aFourByteParameter
               end-if
           end-if
           exit method.
       end method "changed".
      *>----------------------------------------------------------------
      *> Send the deleted message to all the Dependents of this object.
      *>----------------------------------------------------------------

       method-id. "deleted".

       local-storage section.
       01  lsBool              pic x comp-5.
           88 isTrue           value 1.
           88 isFalse          value 0.

       linkage section.
       01 aFourByteParameter   usage object reference.

       procedure division using aFourByteParameter.
           invoke self "isComponent" returning lsBool
           if isTrue
               invoke self "isOutputSignal" using "ASSOCIATEDELETED "
                       returning lsBool
               if isTrue
                   invoke self "signal" using "ASSOCIATEDELETED "
                                          aFourByteParameter
               end-if
           end-if
           exit method.
       end method "deleted".


      *>----------------------------------------------------------------
      *> Return a list of dependents of this object
      *>----------------------------------------------------------------
       method-id. "getDependents".

       local-storage section.
       01  lsBool              pic x comp-5.
           88 isTrue           value 1.
           88 isFalse          value 0.

       linkage section.
       01  lnkDependents       object reference.

       procedure division returning lnkDependents.
           set lnkDependents to null
           invoke self "isComponent" returning lsBool
           if isTrue
               invoke self "isOutputSignal" using "ASSOCIATECHANGED "
                                        returning lsBool
               if isTrue
                   invoke self "getSignalHandlers"
                                            using "ASSOCIATECHANGED "
                                        returning lnkDependents
               end-if
           end-if
           exit method.
       end method "getDependents".
      *>----------------------------------------------------------------
      *> Remove a dependent of this object
      *>----------------------------------------------------------------
       method-id. "removeDependent".

       local-storage section.
       01  lsDependents        object reference.
       01  lsBool              pic x comp-5.
           88 isTrue           value 1.
           88 isFalse          value 0.

       linkage section.
       01 lnkDependent      usage object reference.

       procedure division using lnkDependent.
           invoke self "getDependents" returning lsDependents
           invoke lsDependents "includes" using lnkDependent
                                      returning lsBool
           if isTrue
               invoke self "disconnectSignal"
                               using "ASSOCIATECHANGED "
                                     lnkDependent
               invoke self "disconnectSignal"
                               using "ASSOCIATEDELETED "
                                     lnkDependent
           end-if
           invoke lsDependents "finalize" returning lsDependents
           exit method.
       end method "removeDependent".
      *>----------------------------------------------------------------
      *> Remove all dependencies
      *>----------------------------------------------------------------
       method-id. "removeDependencies".

       local-storage section.
       01  lsDependents        object reference.
       01  lsCallback          object reference.

       linkage section.

       procedure division.
           invoke self "getDependents" returning lsDependents
           if lsDependents <> null
               invoke Callback "new" using self
                                           "removeDependent"
                                 returning lsCallback
               invoke lsDependents "do" using lsCallback
           end-if
           invoke lsDependents "finalize" returning lsDependents
           exit method.
       end method "removeDependencies".
       end object.
       end class Dependent.
