Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CDoubleEventHandler.f90 1.2 KiB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. module CDoubleEventHandler
  2. use CIActionReference
  3. implicit none
  4. public
  5. type :: DoubleEventHandler
  6. procedure(ActionDouble), pointer, nopass :: Delegate => null()
  7. contains
  8. procedure :: AssignTo => AssignTo
  9. procedure :: MakeNull => MakeNull
  10. procedure :: IsNull => IsNull
  11. procedure :: Run => Run
  12. end type DoubleEventHandler
  13. contains
  14. subroutine AssignTo(this, proc)
  15. implicit none
  16. class(DoubleEventHandler), intent(inout) :: this
  17. procedure (ActionDouble), pointer, intent(in) :: proc
  18. this%Delegate => proc
  19. end subroutine
  20. subroutine MakeNull(this)
  21. implicit none
  22. class(DoubleEventHandler), intent(inout) :: this
  23. this%Delegate => null()
  24. end subroutine
  25. logical function IsNull(this)
  26. implicit none
  27. class(DoubleEventHandler), intent(in) :: this
  28. IsNull = .not.associated(this%Delegate)
  29. end function
  30. subroutine Run(this, arg)
  31. implicit none
  32. class(DoubleEventHandler), intent(inout) :: this
  33. real(8), intent(in) :: arg
  34. if(.not.this%IsNull()) call this%Delegate(arg)
  35. end subroutine
  36. end module CDoubleEventHandler