fm_add Subroutine

private subroutine fm_add(self, f)

Add a feature instance to the manager, transferring ownership.

The f argument is moved into internal storage using move_alloc.

Type Bound

feature_manager_t

Arguments

Type IntentOptional Attributes Name
class(feature_manager_t), intent(inout) :: self
class(watch_feature_t), intent(inout), allocatable :: f

Called by

proc~~fm_add~~CalledByGraph proc~fm_add feature_manager_t%fm_add proc~add_stats add_stats proc~add_stats->proc~fm_add proc~enable_features enable_features proc~enable_features->proc~add_stats proc~watcher_init watcher_t%watcher_init proc~watcher_init->proc~enable_features

Source Code

   subroutine fm_add(self, f)
      class(feature_manager_t), intent(inout) :: self
      class(watch_feature_t), allocatable, intent(inout) :: f
      type(feature_box_t), allocatable :: tmp(:)
      integer :: n, i

      if (.not. allocated(self%feat)) then
         allocate(self%feat(1))
         call move_alloc(f, self%feat(1)%p)
         return
      end if

      n = size(self%feat)
      allocate(tmp(n+1))
      do i = 1, n
         call move_alloc(self%feat(i)%p, tmp(i)%p)
      end do
      call move_alloc(f, tmp(n+1)%p)
      call move_alloc(tmp, self%feat)
   end subroutine fm_add