001package jmri.jmrit.operations.rollingstock.cars;
002
003import java.util.ArrayList;
004import java.util.List;
005import jmri.jmrit.operations.rollingstock.RollingStockGroup;
006import org.slf4j.Logger;
007import org.slf4j.LoggerFactory;
008
009/**
010 * A Kernel is a group of cars that is managed as one car.
011 *
012 * @author Daniel Boudreau Copyright (C) 2008, 2010
013 */
014public class Kernel extends RollingStockGroup<Car> {
015
016    public Kernel(String name) {
017        super(name);
018        log.debug("New Kernel ({})", name);
019    }
020
021    public List<Car> getCars() {
022        return new ArrayList<>(getGroup());
023    }
024
025    @Override
026    public void dispose() {
027        while (getGroup().size() > 0) {
028            Car car = getGroup().get(0);
029            if (car != null) {
030                car.setKernel(null);
031            }
032        }
033        super.dispose();
034    }
035
036    private final static Logger log = LoggerFactory.getLogger(Kernel.class);
037}