; $Id: davegr__remove.pro,v 1.2 2005/02/08 17:17:34 azuah Exp $
;###############################################################################
;
; CLASS NAME:
;   DaveGr
;
; PURPOSE:
;   This DaveGr class defines an entity which consists of one or more
;   datasets and all the necessary properties or attributes to display
;   or plot the dataset(s). A dataset is contained in a DaveDat
;   object and can be manipulated using that class' methods.
;
; CATEGORY:
;   Data Browser
;
; SUPERCLASSES:
;   IDL_CONTAINER
;
; PUBLIC METHODS:
;   Add
;   Get
;   Remove
;   Set
;
; AUTHOR:
;   Richard Tumanjong Azuah
;   NIST Center for Neutron Research
;   100 Bureau Drive, Gaithersburg, MD 20899
;   United States
;   azuah@nist.gov; (301) 9755604
;   Mar, 2003
;
; LICENSE:
;  The software in this file is written by an employee of 
;  National Institute of Standards and Technology 
;  as part of the DAVE software project.
;
;  The DAVE software package is not subject to copyright protection
;  and is in the public domain. It should be considered as an
;  experimental neutron scattering data reduction, visualization, and
;  analysis system. As such, the authors assume no responsibility
;  whatsoever for its use, and make no guarantees, expressed or
;  implied, about its quality, reliability, or any other
;  characteristic. The use of certain trade names or commercial
;  products does not imply any endorsement of a particular product,
;  nor does it imply that the named product is necessarily the best
;  product for the stated purpose. We would appreciate acknowledgment
;  if the DAVE software is used or if the code in this file is
;  included in another product.
;
;###############################################################################



;===============================================================================
; DaveGr::Remove
;
; PURPOSE:
;   Overide IDL_Container::Remove method which removes an object from
;   the object's internal container. Some changes have to made to the
;   contained object before removal.
;
; PARAMETERS:
;   objRef [in] - the object reference to be removed
;
;   position [in] - Set this keyword equal to the zero-based index of
;                   the object to be removed. If objRef is specified,
;                   then this keyword is ignored.
;
;   all [in] - If this kwyeord is set, all objects from in the
;              container will be removed.
;
;   _EXTRA [in] - allows keywords to be passed to the
;                 IDL_Conatiner::Removed.
;
pro DaveGr::remove, objRef, position=pos, all=all, _EXTRA=etc

; if object is passed as a parameter
if (n_elements(objRef) gt 0) then begin
    for i=0,n_elements(objRef)-1 do begin
        void = (objRef[i])->set(/remRef) ; decrement object's int. ref. by 1
    endfor

    self->IDL_CONTAINER::remove, objRef, _EXTRA=etc
endif

; if object is passed using its position in the container
if (n_elements(pos) gt 0) then begin
    oRef = self->IDL_CONTAINER::get(position=pos)
    void = oRef->set(/remRef)   ; decrement object's int. ref. by 1

    self->IDL_CONTAINER::remove, position=pos, _EXTRA=etc
endif

; All objects are to be removed
if (keyword_set(all)) then begin
    oRef = self->IDL_CONTAINER::get(/all,count=nObj)

    for i=0,nObj-1 do begin
        void = (oRef[i])->set(/remRef) ; decrement object's int. ref. by 1
    endfor

    self->IDL_CONTAINER::remove, /all, _EXTRA=etc

endif

end
