Object management

SIDL-specified objects are managed through explicit creation and reference counting. Babel automatically generates a new() method for concrete classes. The method is used to instantiate the class and return the associated reference. The following example illustrates the instantiation and casting of an object to an interface$:$


  use sidl_BaseClass
  use sidl_BaseInterface
  type(sidl_BaseClass_t)     :: object
  type(sidl_BaseInterface_t) :: interface
  type(sidl_BaseInterface_t) :: exception
  ! perhaps other code here
  call new(object, exception)
  call cast(object, interface, exception)

The owner of the instance is responsible for its proper disposal. In other words, when processing with the object is done, the owner must invoke deleteRef() on it. Similarly, any object references returned by a subroutine call must be deleted or given to another part of the code that will take ownership of and, therefore, responsibility for deleteRef'ing it. The following example illustrates calling deleteRef() using the sidl.BaseInterface method$:$


  use sidl_BaseInterface
  type(sidl_BaseInterface_t) :: interface1, interface2
  type(sidl_BaseInterface_t) :: exception
  logical                    :: areSame
  !
  ! code to initialize interface1 & interface 2 here
  !
  call deleteRef(interface1, exception)

When it is necessary to determine if two references point to the same object, the built-in isSame method can be used. For example, the following attempts to determine if interface1 and interface2 point to the same object$:$


  use sidl_BaseInterface
  ! later in the code
  call isSame(interface1, interface2, areSame, exception)
  ! areSame holds the return value



babel-1.4.0
users_guide Last Modified 2008-10-16

http://www.llnl.gov/CASC/components
components@llnl.gov